You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spot.apache.org by ra...@apache.org on 2017/06/09 21:53:04 UTC
[1/3] incubator-spot git commit: doc_restructuring
Repository: incubator-spot
Updated Branches:
refs/heads/master c0f80c56e -> 283493c4d
doc_restructuring
updated documentation, added separate sections for the data schema, the jar, and the ml_ops.sh script
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/76538775
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/76538775
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/76538775
Branch: refs/heads/master
Commit: 765387756b8a722e74a4e5df5f91a49107b1c7ef
Parents: c0f80c5
Author: nlsegerl <na...@intel.com>
Authored: Thu Jun 8 15:48:46 2017 -0700
Committer: nlsegerl <na...@intel.com>
Committed: Thu Jun 8 15:48:46 2017 -0700
----------------------------------------------------------------------
spot-ml/INSTALL.md | 2 +-
spot-ml/ML_OPS.md | 59 +++++++++++++
spot-ml/README.md | 130 +++++------------------------
spot-ml/SPOT-ML-JAR.md | 45 ++++++++++
spot-ml/SUSPICIOUS_CONNECTS_SCHEMA.md | 46 ++++++++++
spot-ml/ml_ops.sh | 5 +-
6 files changed, 177 insertions(+), 110 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/76538775/spot-ml/INSTALL.md
----------------------------------------------------------------------
diff --git a/spot-ml/INSTALL.md b/spot-ml/INSTALL.md
index 0ca8ef2..59e4b06 100644
--- a/spot-ml/INSTALL.md
+++ b/spot-ml/INSTALL.md
@@ -7,7 +7,7 @@ Machine learning routines for Apache Spot (incubating).
Install and configure spot-ml as a part of the Spot project, per the instruction at
[the Spot wiki].
-The spot-ml routines must be built into a jar stored at `target/scala-2.10/spot-ml-assembly-1.1.jar` on the master node. This requires Scala 2.10 or later to be installed on the system building the jar. To build the jar, from the top-level of the spot-ml repo, execute the command `sbt assembly`.
+The spot-ml routines must be built into a jar stored at `target/scala-2.10/spot-ml-assembly-1.1.jar` on the ML node. This requires Scala 2.10 or later to be installed on the system building the jar. To build the jar, from the top-level of the spot-ml repo, execute the command `sbt assembly`.
Names and language that we will use from the configuration variables for Spot (that are set in the file [spot.conf])
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/76538775/spot-ml/ML_OPS.md
----------------------------------------------------------------------
diff --git a/spot-ml/ML_OPS.md b/spot-ml/ML_OPS.md
new file mode 100644
index 0000000..df974e0
--- /dev/null
+++ b/spot-ml/ML_OPS.md
@@ -0,0 +1,59 @@
+# The ml_ops.sh script
+
+ml_ops.sh is a helper script for invoking the suspicious connects analysis in the common case of its use in Spot.
+
+It loads environment variables from `/etc/spot.conf`, parses some arguments from the CLI, invokes the Suspicous Connects analysis from
+the spot-ml jar stored in `target/scala-2.10/spot-ml-assembly-1.1.jar`.
+
+
+## Usage
+
+The ml_ops script is meant to be used as part of a full spot deployment. Data is expected to reside in the locations used by
+Spot ingest and in a schema extending the [schema used by the suspicious connects analyses](SUSPICIOUS_CONNECTS_SCHEMA.md).
+
+To run a suspicious connects analysis, execute the `ml_ops.sh` from the directory where the spot-ml jar is
+stored in the relativae path `target/scala-2.10/spot-ml-assembly-1.1.jar`
+
+```
+./ml_ops.sh YYYMMDD <type> <suspicion threshold> <max results>
+```
+
+* **YYYYMMDD** The date of the collected data that has been ingested and stored into the Spot's data repository. Eg., 20170129
+
+* **type** is one is of flow, proxy or dns.
+
+* **suspicion threshold** is an optional floating-point value in the range [0,1]. All records that receive a score strictly greater than
+the threshold are not reported. It defaults to 1 (no filter).
+
+* **max results** is an optional integer value value greater than or equal to 0. If provided, results are ordered by score from least to greatest and
+the _max results_ smallest are returned in an ascending list. If not provided, all results with a score below the given threshold are returned in an ascending list.
+
+## Example Usage
+
+```
+./ml_ops.sh 19731231 flow 1e-20 200
+```
+
+If the max results returned argument is not provided, all results with scores below the threshold will be returned, for example:
+```
+./ml_ops.sh 20150101 dns 1e-4
+```
+
+As the maximum probability of an event is 1, a threshold of 1 can be used to select a fixed number of most suspicious items regardless of their exact scores:
+```
+./ml_ops.sh 20150101 proxy 1 2000
+```
+## ml_ops.sh output
+
+Final results are stored in the following file on HDFS.
+
+Depending on which data source is analyzed,
+spot-ml output will be found under the ``HPATH`` at one of
+
+ $HPATH/dns/scored_results/YYYYMMDD/scores/dns_results.csv
+ $HPATH/proxy/scored_results/YYYYMMDD/scores/results.csv
+ $HPATH/flow/scored_results/YYYYMMDD/scores/flow_results.csv
+
+
+It is a csv file in which network events annotated with estimated probabilities and sorted in ascending order.
+
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/76538775/spot-ml/README.md
----------------------------------------------------------------------
diff --git a/spot-ml/README.md b/spot-ml/README.md
index 3200c06..4e48837 100644
--- a/spot-ml/README.md
+++ b/spot-ml/README.md
@@ -2,100 +2,34 @@
Machine learning routines for Apache Spot (incubating).
-At present, spot-ml contains routines for performing *suspicious connections* analyses on netflow, DNS or proxy data gathered from a network. These
-analyses consume a (possibly very lage) collection of network events and produces a list of the events that considered to be the least probable (most suspicious).
+spot-ml contains routines for performing *suspicious connections* analyses on netflow, DNS or proxy data gathered from a network. These
+analyses consume collections of network events and produce lists of the events that are considered to be the least probable (most suspicious).
-spot-ml is designed to be run as a component of Spot. It relies on the ingest component of Spot to collect and load
-netflow and DNS records, and spot-ml will try to load data to the operational analytics component of Spot. It is suggested that when experimenting with spot-ml, you do so as a part of the unified Spot system: Please see [the Spot wiki]
+The suspicious connects analysis assigns to each record a score in the range 0 to 1, with smaller scores being viewed as more suspicious or anomalous than larger scores.
-The remaining instructions in this README file treat spot-ml in a stand-alone fashion that might be helpful for customizing and troubleshooting the
-component.
+These routines are contained in a jar file and there is a shell script ml_ops.sh for a simplified the invocation of the analyses.
+
+
+* [jar documentation here](SPOT-ML-JAR.md)
+* [ml_ops.sh documentation here](ML_OPS.md)
## Prepare data for input
-Load data for consumption by spot-ml by running [spot-ingest].
-
-The data format and location where the data is stored differs for netflow and DNS analyses.
-
-**Netflow Data**
-
-Netflow data for the year YEAR, month MONTH, and day DAY is stored in in a Parquet table at `HUSER/flow/csv/y=YEAR/m=MONTH/d=DAY/*` according to
- the following schema:
-
-- time: String
-- year: Double
-- month: Double
-- day: Double
-- hour: Double
-- minute: Double
-- second: Double
-- time of duration: Double
-- source IP: String
-- destination IP: String
-- source port: Double
-- dport: Double
-- proto: String
-- flag: String
-- fwd: Double
-- stos: Double
-- ipkt: Double.
-- ibyt: Double
-- opkt: Double
-- obyt: Double
-- input: Double
-- output: Double
-- sas: String
-- das: Sring
-- dtos: String
-- dir: String
-- rip: String
-
-**DNS Data**
-
-DNS data for the year YEAR, month MONTH and day DAY is stored in Parquet at `HUSER/dns/hive/y=YEAR/m=MONTH/d=DAY/` using the following schema:
-
-- frame_time: STRING
-- unix_tstamp: BIGINT
-- frame_len: INT3. ip_dst: STRING
-- ip_src: STRING
-- dns_qry_name: STRING
-- dns_qry_class: STRING
-- dns_qry_type: INT
-- dns_qry_rcode: INT
-- dns_a: STRING
-
-**PROXY DATA**
-Proxy data for the year YEAR, month MONTH and day DAY is stored in Parquet at `HUSER/dns/hive/y=YEAR/m=MONTH/d=DAY/` using the following schema:
-
-- p_date: STRING
-- p_time: STRING
-- clientip: STRING
-- host: STRING
-- reqmethod: STRING
-- useragent: STRING
-- resconttype: STRING
-- duration: INT
-- username: STRING
-- authgroup: STRING
-- exceptionid: STRING
-- filterresult: STRING
-- webcat: STRING
-- referer: STRING
-- respcode: STRING
-- action: STRING
-- urischeme: STRING
-- uriport: STRING
-- uripath: STRING
-- uriquery: STRING
-- uriextension: STRING
-- serverip: STRING
-- scbytes: INT
-- csbytes: INT
-- virusid: STRING
-- bcappname: STRING
-- bcappoper: STRING
-- fulluri: STRING
+Whether suspicious connects is called by ml_ops.sh or through the ml-ops jar, data must be in the [schema used by the suspicious connects analyses](SUSPICIOUS_CONNECTS_SCHEMA.md). Ingesting data via the Spot ingest tools will store data in an appropriate schema.
+
+
+### Data locations for ml_ops.sh
+
+ml_ops.sh expects data to be in particular locations. The environment variable `HUSER` defined in /etc/spot.conf is the Hadoop user executing the analysis.
+
+- Netflow data for the year YEAR, month MONTH, and day DAY is stored in in a Parquet table at `HUSER/flow/csv/y=YEAR/m=MONTH/d=DAY/*`
+
+- DNS data for the year YEAR, month MONTH and day DAY is stored in Parquet at `HUSER/dns/hive/y=YEAR/m=MONTH/d=DAY/`
+
+- Proxy data for the year YEAR, month MONTH and day DAY is stored in Parquet at `HUSER/dns/hive/y=YEAR/m=MONTH/d=DAY/`
+
+Ingesting data with the Spot ingestion tools (and a shared /etc/spot.conf file) will save data in these locations.
### Run a suspicious connects analysis
@@ -111,26 +45,8 @@ For example:
./ml_ops.sh 19731231 flow 1e-20 200
```
-If the max results returned argument is not provided, all results with scores below the threshold will be returned, for example:
-```
-./ml_ops.sh 20150101 dns 1e-4
-```
-
-As the maximum probability of an event is 1, a threshold of 1 can be used to select a fixed number of most suspicious items regardless of their exact scores:
-```
-./ml_ops.sh 20150101 proxy 1 2000
-```
-
-
-### spot-ml output
-
-Final results are stored in the following file on HDFS.
-
-Depending on which data source is analyzed,
-spot-ml output will be found under the ``HPATH`` at one of
+You should have a list of the 200 most suspiciouc flow events from
- $HPATH/dns/scored_results/YYYYMMDD/scores/dns_results.csv
- $HPATH/proxy/scored_results/YYYYMMDD/scores/results.csv
$HPATH/flow/scored_results/YYYYMMDD/scores/flow_results.csv
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/76538775/spot-ml/SPOT-ML-JAR.md
----------------------------------------------------------------------
diff --git a/spot-ml/SPOT-ML-JAR.md b/spot-ml/SPOT-ML-JAR.md
new file mode 100644
index 0000000..1171812
--- /dev/null
+++ b/spot-ml/SPOT-ML-JAR.md
@@ -0,0 +1,45 @@
+# The spot-ml jar
+
+
+The spot-ml jar contains one main routine and it is in the class `SuspiciousConnects`;
+it is by submitting this class to Spark that the Suspicious Connects analyses are invoked.
+
+
+
+# Command line arguments
+
+
+* **analysis** The analysis to perform. One of flow, proxy, dns
+* **input** Path to data on HDFS. Data is expected to be stored in parquet with schema consistent with
+[schema used by the suspicious connects analyses](SUSPICIOUS_CONNECTS_SCHEMA.md).
+* **feedback** Local path of file containing feedback scores.
+* **dupfactor** Duplication factor controlling how to downrate non-threatening events from the feedback file.
+* **ldatopiccount** Number of topics in the topic model.
+* **userdomain** The user domain of the network being analyzed.
+* **scored** The HDFS path where results will be stored.
+* **threshold** Threshold for determination of anomalies. Records with scores above the threshold will not be returned.
+* **maxresults** Maximum number of record to return. If -1, all records are returned. Results are filtered by the threshold and sorted and the most suspicous (lowest score) records are returned first.
+* **delimiter** Separation character used for CSVs containing most suspicious results.
+* **prgseed** Seed for the pseudorandom generator used in topic modelling.
+* **ldamaxiteration** Maximum number of iterations to execute the LDA topic modelling procedure.
+* **ldaalpha** Document concentration for LDA, default 1.02
+* **ldabeta** Topic concentration for LDA, default 1.001
+
+# Example
+
+
+<pre><code>
+
+spark-submit --class "org.apache.spot.SuspiciousConnects" target/scala-2.10/spot-ml-assembly-1.1.jar \
+ --analysis proxy \
+ --input /user/spot/proxy/hive/y=2016/m=11/d=11/ \
+ --dupfactor 1000 \
+ --feedback /home/spot/ml/proxy/20161111/feedback.csv \
+ --ldatopiccount 20 \
+ --scored /user/spot/proxy/scored_results/20161111/scores \
+ --threshold 1e-6 \
+ --maxresults 2000 \
+ --ldamaxiterations 20
+
+</code></pre>
+
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/76538775/spot-ml/SUSPICIOUS_CONNECTS_SCHEMA.md
----------------------------------------------------------------------
diff --git a/spot-ml/SUSPICIOUS_CONNECTS_SCHEMA.md b/spot-ml/SUSPICIOUS_CONNECTS_SCHEMA.md
new file mode 100644
index 0000000..4afc6f2
--- /dev/null
+++ b/spot-ml/SUSPICIOUS_CONNECTS_SCHEMA.md
@@ -0,0 +1,46 @@
+# Data Schema for the Spot Suspicious Connects Analyses
+
+
+
+Three kinds of network logs can be analyzed by the Spot Suspicious Connects analyses: Netflow records, DNS queriess, and proxy logs.
+
+Data from these logs is expected to have been stored in parquet files on HDFS with column structure extending the following schema.
+
+
+## Netflow Data
+
+- trhour: The hour of the day in which the flow was logged, Integer.
+- sip: The source IP address of the flow, String.
+- dip: The destination IP address of the flow, String.
+- sport: The source port of the flow, Integer
+- dport: The destination port of the flow, Integer
+- proto: The protocol used by the flow, String
+- ipkt: The flow's packet count, Long.
+- ibyt: The flow's byte count, Long.
+
+## DNS Data
+
+- frame_time: Frame timestamp of query, String.
+- unix_tstamp: Unix timestamp of query, String.
+- frame_len: Frame length, Integer.
+- ip_dst: IP address of client making query, String.
+- dns_qry_name: Name of DNS query, String.
+- dns_qry_class: Class of DNS query, String.
+- dns_qry_type: Type of DNS query, Integer.
+- dns_qry_rcode: DNS query response code, Integer.
+
+## Proxy Data
+
+
+- p_date: Date of the query, String.
+- p_time: Time of the query, String. (FORMAT?)
+- clientip: IP address of client making proxy request, String.
+- host: Host of reuest, String.
+- reqmethod: Request method, String.
+- useragent: User agent, String.
+- resconttype: Response content type, String.
+- respcode: Response code, String.
+- fulluri: Full URI of request, String.
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/76538775/spot-ml/ml_ops.sh
----------------------------------------------------------------------
diff --git a/spot-ml/ml_ops.sh b/spot-ml/ml_ops.sh
index 7bf98d7..c204a97 100755
--- a/spot-ml/ml_ops.sh
+++ b/spot-ml/ml_ops.sh
@@ -29,10 +29,11 @@ DY=${FDATE:6:2}
if [[ "${#FDATE}" != "8" || -z "${DSOURCE}" ]]; then
echo "ml_ops.sh syntax error"
echo "Please run ml_ops.sh again with the correct syntax:"
- echo "./ml_ops.sh YYYYMMDD TYPE [TOL]"
+ echo "./ml_ops.sh YYYYMMDD TYPE [MAX RESULTS] [TOL]"
echo "for example:"
- echo "./ml_ops.sh 20160122 dns 1e-6"
+ echo "./ml_ops.sh 20160122 dns 1000 1e-6"
echo "./ml_ops.sh 20160122 flow"
+ echo "./ml_ops.sh 20160122 proxy 100"
exit
fi
[2/3] incubator-spot git commit: doc_restructuring
Posted by ra...@apache.org.
doc_restructuring
added documentation on the parameters that ml_ops.sh grabs from /etc/spot.conf
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/bf3283ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/bf3283ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/bf3283ba
Branch: refs/heads/master
Commit: bf3283ba237c6451c8d2e56ca5482d16e20847ed
Parents: 7653877
Author: nlsegerl <na...@intel.com>
Authored: Fri Jun 9 09:48:58 2017 -0700
Committer: nlsegerl <na...@intel.com>
Committed: Fri Jun 9 09:48:58 2017 -0700
----------------------------------------------------------------------
spot-ml/ML_OPS.md | 13 +++++++++++--
spot-ml/README.md | 5 +++++
2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/bf3283ba/spot-ml/ML_OPS.md
----------------------------------------------------------------------
diff --git a/spot-ml/ML_OPS.md b/spot-ml/ML_OPS.md
index df974e0..585a9c1 100644
--- a/spot-ml/ML_OPS.md
+++ b/spot-ml/ML_OPS.md
@@ -45,8 +45,7 @@ As the maximum probability of an event is 1, a threshold of 1 can be used to sel
```
## ml_ops.sh output
-Final results are stored in the following file on HDFS.
-
+Final results are stored in the following file on HDFS
Depending on which data source is analyzed,
spot-ml output will be found under the ``HPATH`` at one of
@@ -57,3 +56,13 @@ spot-ml output will be found under the ``HPATH`` at one of
It is a csv file in which network events annotated with estimated probabilities and sorted in ascending order.
+## Parameters taken from the /etc/spot.conf file
+
+The ml_ops.sh script takes its values for the following parameters from the /etc/spot.conf file:
+
+* **All spark settings** Among them driver memory, number of executors, spark.driever.MaxResultSize, etc.
+* **Paths to storage locations for Spot ingested data**
+* **USER_DOMAIN** The domain name for the network being analyzed. Used to denote "internal" URLs during proxy and dns analyses.
+* **TOPIC_COUNT** Number of topics used for the topic modelling at the heart of the Suspicious Connects anomaly detection. Roughly, the analysis attempts to generate TOPIC_COUNT many profiles of common traffic in the cluster.
+* **DUPFACTOR** Used to downgrade the threat level of records similar to those marked as non-threatening by the feedback function of Spot UI. DUPFACTOR inflate the frequency of such records to make them appear less anomalous. A DUPFACTOR of 1 has no effect, and a DUPFACTOR of 1000 increases the frequency of the connection's pattern by a factor of 1000, increasing its estimated probability accordingly.
+
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/bf3283ba/spot-ml/README.md
----------------------------------------------------------------------
diff --git a/spot-ml/README.md b/spot-ml/README.md
index 4e48837..876ee77 100644
--- a/spot-ml/README.md
+++ b/spot-ml/README.md
@@ -13,6 +13,11 @@ These routines are contained in a jar file and there is a shell script ml_ops.
* [jar documentation here](SPOT-ML-JAR.md)
* [ml_ops.sh documentation here](ML_OPS.md)
+## Configure the /etc/spot.conf file
+
+If using spot-ml as part of the integrated spot solution (or if you simply wish to use the ml_ops.sh script to invoke the suspicious connects analysis),
+the /etc/spot.conf file must be correctly configured.
+
## Prepare data for input
Whether suspicious connects is called by ml_ops.sh or through the ml-ops jar, data must be in the [schema used by the suspicious connects analyses](SUSPICIOUS_CONNECTS_SCHEMA.md). Ingesting data via the Spot ingest tools will store data in an appropriate schema.
[3/3] incubator-spot git commit: doc_restructuring
Posted by ra...@apache.org.
doc_restructuring
Added documentation for how ml_ops.sh used the TOL parameter from /etc/spot.conf as a default value for the suspicion threshold.
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/283493c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/283493c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/283493c4
Branch: refs/heads/master
Commit: 283493c4dde304a27ccf031f499ccacb6483e115
Parents: bf3283b
Author: nlsegerl <na...@intel.com>
Authored: Fri Jun 9 10:01:39 2017 -0700
Committer: nlsegerl <na...@intel.com>
Committed: Fri Jun 9 10:01:39 2017 -0700
----------------------------------------------------------------------
spot-ml/ML_OPS.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/283493c4/spot-ml/ML_OPS.md
----------------------------------------------------------------------
diff --git a/spot-ml/ML_OPS.md b/spot-ml/ML_OPS.md
index 585a9c1..06a6548 100644
--- a/spot-ml/ML_OPS.md
+++ b/spot-ml/ML_OPS.md
@@ -65,4 +65,5 @@ The ml_ops.sh script takes its values for the following parameters from the /etc
* **USER_DOMAIN** The domain name for the network being analyzed. Used to denote "internal" URLs during proxy and dns analyses.
* **TOPIC_COUNT** Number of topics used for the topic modelling at the heart of the Suspicious Connects anomaly detection. Roughly, the analysis attempts to generate TOPIC_COUNT many profiles of common traffic in the cluster.
* **DUPFACTOR** Used to downgrade the threat level of records similar to those marked as non-threatening by the feedback function of Spot UI. DUPFACTOR inflate the frequency of such records to make them appear less anomalous. A DUPFACTOR of 1 has no effect, and a DUPFACTOR of 1000 increases the frequency of the connection's pattern by a factor of 1000, increasing its estimated probability accordingly.
+* **TOL** The default value for the _suspicion threshold_ described above. In particular: If no third argument is provided to ml_ops.sh, the suspicion threshold is filled in with the TOL value from /etc/spot.conf. If a third argument is provided to ml_ops.sh, that is the supicion threshold used.