You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spot.apache.org by ev...@apache.org on 2017/01/10 23:02:31 UTC
[1/7] incubator-spot git commit: fixup! Ingest summary supporting 3
use cases, Netflow, DNS and Proxy
Repository: incubator-spot
Updated Branches:
refs/heads/master 8830127b1 -> db87a2de2
fixup! Ingest summary supporting 3 use cases, Netflow, DNS and Proxy
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/db87a2de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/db87a2de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/db87a2de
Branch: refs/heads/master
Commit: db87a2de2e3766b85e5d88a321d03404e30db9d0
Parents: 466ff0a
Author: Diego Ortiz Huerta <di...@intel.com>
Authored: Mon Dec 12 10:34:04 2016 -0800
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.local>
Committed: Tue Jan 10 10:41:13 2017 -0600
----------------------------------------------------------------------
spot-oa/ui/ingest-summary.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/db87a2de/spot-oa/ui/ingest-summary.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/ingest-summary.html b/spot-oa/ui/ingest-summary.html
index 1c4a100..0bfc189 100755
--- a/spot-oa/ui/ingest-summary.html
+++ b/spot-oa/ui/ingest-summary.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Netflow :: Ingest Summary</title>
+ <title>Ingest Summary</title>
<meta charset="UTF-8">
@@ -84,7 +84,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
- <span class="navbar-brand">Apache Spot :: Netflow :: Ingest Summary</span>
+ <span class="navbar-brand">Apache Spot :: Ingest Summary</span>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="main-menu">
[3/7] incubator-spot git commit: Ingest summary links updated
Posted by ev...@apache.org.
Ingest summary links updated
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/8446e363
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/8446e363
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/8446e363
Branch: refs/heads/master
Commit: 8446e363f13b5a59efae55f87622a2c33762fd9f
Parents: 86d1552
Author: Diego Ortiz Huerta <di...@intel.com>
Authored: Wed Dec 7 15:22:02 2016 -0800
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.local>
Committed: Tue Jan 10 10:41:13 2017 -0600
----------------------------------------------------------------------
spot-oa/ui/dns/storyboard.html | 5 +++--
spot-oa/ui/dns/suspicious.html | 5 +++--
spot-oa/ui/dns/threat-investigation.html | 5 +++--
spot-oa/ui/flow/storyboard.html | 5 +++--
spot-oa/ui/flow/suspicious.html | 5 +++--
spot-oa/ui/flow/threat-investigation.html | 5 +++--
spot-oa/ui/proxy/storyboard.html | 5 +++--
spot-oa/ui/proxy/suspicious.html | 5 +++--
spot-oa/ui/proxy/threat-investigation.html | 5 +++--
9 files changed, 27 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/dns/storyboard.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/dns/storyboard.html b/spot-oa/ui/dns/storyboard.html
index 5f9f725..c5dbc0f 100755
--- a/spot-oa/ui/dns/storyboard.html
+++ b/spot-oa/ui/dns/storyboard.html
@@ -69,8 +69,6 @@
<li>
<a data-href="../flow/storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="../flow/ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -107,6 +105,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/dns/suspicious.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/dns/suspicious.html b/spot-oa/ui/dns/suspicious.html
index 6d008b3..845e5e2 100755
--- a/spot-oa/ui/dns/suspicious.html
+++ b/spot-oa/ui/dns/suspicious.html
@@ -79,8 +79,6 @@
<li>
<a data-href="../flow/storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="../flow/ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -117,6 +115,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/dns/threat-investigation.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/dns/threat-investigation.html b/spot-oa/ui/dns/threat-investigation.html
index cf5966d..08218fd 100755
--- a/spot-oa/ui/dns/threat-investigation.html
+++ b/spot-oa/ui/dns/threat-investigation.html
@@ -67,8 +67,6 @@
<li>
<a data-href="../flow/storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="../flow/ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -105,6 +103,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/flow/storyboard.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/storyboard.html b/spot-oa/ui/flow/storyboard.html
index 8596eea..f0dccb7 100755
--- a/spot-oa/ui/flow/storyboard.html
+++ b/spot-oa/ui/flow/storyboard.html
@@ -69,8 +69,6 @@
<li>
<a data-href="storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -107,6 +105,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/flow/suspicious.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/suspicious.html b/spot-oa/ui/flow/suspicious.html
index 9bd47c8..d755474 100755
--- a/spot-oa/ui/flow/suspicious.html
+++ b/spot-oa/ui/flow/suspicious.html
@@ -73,8 +73,6 @@
<li>
<a data-href="storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -111,6 +109,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/flow/threat-investigation.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/threat-investigation.html b/spot-oa/ui/flow/threat-investigation.html
index d80ccc6..b5bb053 100755
--- a/spot-oa/ui/flow/threat-investigation.html
+++ b/spot-oa/ui/flow/threat-investigation.html
@@ -67,8 +67,6 @@
<li>
<a data-href="storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -105,6 +103,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/proxy/storyboard.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/proxy/storyboard.html b/spot-oa/ui/proxy/storyboard.html
index 6968566..2ed4a08 100755
--- a/spot-oa/ui/proxy/storyboard.html
+++ b/spot-oa/ui/proxy/storyboard.html
@@ -147,8 +147,6 @@
<li>
<a data-href="../flow/storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="../flow/ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -185,6 +183,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/proxy/suspicious.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/proxy/suspicious.html b/spot-oa/ui/proxy/suspicious.html
index 828a42c..74145f3 100755
--- a/spot-oa/ui/proxy/suspicious.html
+++ b/spot-oa/ui/proxy/suspicious.html
@@ -137,8 +137,6 @@
<li>
<a data-href="../flow/storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="../flow/ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -175,6 +173,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/8446e363/spot-oa/ui/proxy/threat-investigation.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/proxy/threat-investigation.html b/spot-oa/ui/proxy/threat-investigation.html
index ae740a9..45c5326 100755
--- a/spot-oa/ui/proxy/threat-investigation.html
+++ b/spot-oa/ui/proxy/threat-investigation.html
@@ -66,8 +66,6 @@
<li>
<a data-href="../flow/storyboard.html#date=${date}">Storyboard</a>
</li>
- <li>
- <a data-href="../flow/ingest-summary.html#end-date=${date}">Ingest Summary</a>
</ul>
</li>
<li class="dropdown">
@@ -104,6 +102,9 @@
</li>
</ul>
</li>
+ <li>
+ <a data-href="../ingest-summary.html#end-date=${date}">Ingest Summary</a>
+ </li>
</ul>
</div>
<div id="search-box" class="row text-right">
[2/7] incubator-spot git commit: Ingest summary supporting 3 use
cases, Netflow, DNS and Proxy
Posted by ev...@apache.org.
Ingest summary supporting 3 use cases, Netflow, DNS and Proxy
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/0d9bd5e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/0d9bd5e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/0d9bd5e0
Branch: refs/heads/master
Commit: 0d9bd5e0f10ff1569f4e10798ca6d83e00758c4d
Parents: f410dd8
Author: Diego Ortiz Huerta <di...@intel.com>
Authored: Mon Dec 12 10:08:56 2016 -0800
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.local>
Committed: Tue Jan 10 10:41:13 2017 -0600
----------------------------------------------------------------------
.../ui/flow/js/constants/NetflowConstants.js | 1 -
spot-oa/ui/ingest-summary.html | 37 +-
.../js/components/IngestSummaryPanel.react.js | 418 +++++++++----------
spot-oa/ui/js/components/OptionPicker.react.js | 43 ++
spot-oa/ui/js/constants/SpotConstants.js | 10 +-
spot-oa/ui/js/ingest-summary.js | 66 +--
spot-oa/ui/js/stores/IngestSummaryStore.js | 107 +++--
spot-oa/ui/package.json | 2 +-
8 files changed, 378 insertions(+), 306 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/flow/js/constants/NetflowConstants.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/constants/NetflowConstants.js b/spot-oa/ui/flow/js/constants/NetflowConstants.js
index 3ee8099..f9ac657 100755
--- a/spot-oa/ui/flow/js/constants/NetflowConstants.js
+++ b/spot-oa/ui/flow/js/constants/NetflowConstants.js
@@ -5,7 +5,6 @@ var NetflowConstants = {
API_VISUAL_DETAILS: '../../data/flow/${date}/chord-${ip}.tsv',
API_COMMENTS: '../../data/flow/${date}/threats.csv',
API_INCIDENT_PROGRESSION: '../../data/flow/${date}/threat-dendro-${ip}.json',
- API_INGEST_SUMMARY: '../data/flow/ingest_summary/is_${year}${month}.csv',
API_IMPACT_ANALYSIS: '../../data/flow/${date}/stats-${ip}.json',
API_GLOBE_VIEW: '../../data/flow/${date}/globe-${ip}.json',
API_TIMELINE: '../../data/flow/${date}/sbdet-${ip}.tsv'
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/ingest-summary.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/ingest-summary.html b/spot-oa/ui/ingest-summary.html
index e694609..1c4a100 100755
--- a/spot-oa/ui/ingest-summary.html
+++ b/spot-oa/ui/ingest-summary.html
@@ -34,32 +34,43 @@
height: 100%;
}
- #spot-is-header {
+ .is-chart svg {
width: 100%;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 2;
- height: auto;
+ height: 100%;
}
- #spot-is, #spot-is-summary {
- height: 100%;
+ .is-chart svg .header text {
+ text-anchor: middle;
+ fill: #82837e;
+ }
+
+ .is-chart svg .header text tspan.bold {
+ font-weight: bold;
}
- .axis {
+ .is-chart .axis {
shape-rendering: crispEdges;
}
- .axis path, .axis line {
+ .is-chart .axis path, .is-chart .axis line {
fill: none;
}
- rect.pane {
- cursor: e-resize;
- fill: none;
+ .is-chart .pipeline {
pointer-events: all;
}
+
+ .is-chart .pipeline.zoom-in {
+ cursor: zoom-in;
+ }
+
+ .is-chart .pipeline.zoom-out {
+ cursor: zoom-out;
+ }
+
+ .is-chart .pipeline.e-resize {
+ cursor: e-resize;
+ }
</style>
</head>
<body>
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/js/components/IngestSummaryPanel.react.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/components/IngestSummaryPanel.react.js b/spot-oa/ui/js/components/IngestSummaryPanel.react.js
index cc951ad..06c83bd 100755
--- a/spot-oa/ui/js/components/IngestSummaryPanel.react.js
+++ b/spot-oa/ui/js/components/IngestSummaryPanel.react.js
@@ -3,234 +3,216 @@ const d3 = require('d3');
const React = require('react');
const ReactDOM = require('react-dom');
+const ContentLoaderMixin = require('./ContentLoaderMixin.react');
+const ChartMixin = require('./ChartMixin.react');
const DateUtils = require('../utils/DateUtils');
const InSumActions = require('../actions/InSumActions');
-const NetflowIngestSummaryStore = require('../../flow/js/stores/IngestSummaryStore');
-
-function initialDraw() {
- var rootNode, format, x, y, xAxis, yAxis, area, svg, rect, total, minDate, maxDate, maxFlows, numberFormat;
-
- rootNode = d3.select(ReactDOM.findDOMNode(this));
-
- // graph dimensions
- var m = [100, 50, 50, 80], // Margin
- w = $(rootNode.node()).width() - m[1] - m[3], // Width
- h = $(rootNode.node()).height() - m[0] - m[2]; // Height
-
- format = d3.time.format("%Y-%m-%d %H:%M");
-
- // Scales.
- x = d3.time.scale().range([0, w]); // get X function
- y = d3.scale.linear().range([h, 0]); // get Y function
- xAxis = d3.svg.axis().scale(x).orient("bottom"); // Get the X axis (Time)
- yAxis = d3.svg.axis().scale(y).orient("left"); // Get Y Axis (Netflows)
-
- // An area generator.
- area = d3.svg.area()
- .x(function (d) {
- return x(d.date);
- })
- .y0(h)
- .y1(function (d) {
- if (!isNaN(d.total))
- return y(d.total);
- else
- return y(0);
- });
+const IngestSummaryStore = require('../stores/IngestSummaryStore');
- rootNode.select('svg').remove();
-
- // define the Main SVG
- svg = rootNode.select('#' + this.props.id + '-summary').append("svg")
- .attr("width", w + m[1] + m[3])
- .attr("height", h + m[0] + m[2])
- .append("g")
- .attr("transform", "translate(" + m[3] + "," + m[0] + ")")
-
- // Append the clipPath to avoid the Area overlapping
- svg.append("clipPath")
- .attr("id", "clip")
- .append("rect")
- .attr("x", x(0))
- .attr("y", y(1))
- .attr("width", x(1) - x(0))
- .attr("height", y(0) - y(1));
-
- // Append the Y Axis group
- svg.append("g")
- .attr("class", "y axis");
-
- // Append the X axis group
- svg.append("g")
- .attr("class", "x axis")
- .attr("transform", "translate(0," + h + ")");
-
- // Append a pane rect, which will help us to add the zoom functionality
- rect = svg.append("rect")
- .attr("class", "pane")
- .attr("width", w)
- .attr("height", h);
-
- this.state.data.forEach(function (dataSet)
- {
- var a;
-
- a = [{date: minDate}];
- a.push.apply(a, dataSet);
- minDate = d3.min(a, function (d) { return d.date; });
- a[0] = {date: maxDate, flows: maxFlows};
- maxDate = d3.max(a, function (d) { return d.date; });
- maxFlows = d3.max(a, function (d) { return d.total; })
- });
-
- !minDate && (minDate = DateUtils.parseDate(NetflowIngestSummaryStore.getStartDate()));
- !maxDate && (maxDate = DateUtils.parseDate(NetflowIngestSummaryStore.getEndDate()));
-
- // bind the data to the X and Y generators
- x.domain([minDate, maxDate]);
- y.domain([0, maxFlows]);
-
- // Bind the data to our path element.
- svg.selectAll("path.area").data(this.state.data).enter().insert('path', 'g')
- .attr('class', 'area')
- .attr('clip-path', 'url(#clip)')
- .style('fill', '#0071c5')
- .attr('d', function (d) {
- return area(d);
- });
-
- //Add the pane rect the zoom behavior
- rect.call(d3.behavior.zoom().x(x)
- .scaleExtent([0.3, 2300]) // these are magic numbers to avoid the grap be zoomable in/out to the infinity
- .on("zoom", zoom.bind(this)));
-
- function draw () {
- var total, minDate, maxDate, numberFormat;
-
- svg.select("g.x.axis").call(xAxis);
- svg.select("g.y.axis").call(yAxis);
- svg.selectAll("path.area").attr("d", function (d) { return area(d); });
- numberFormat = d3.format(",d"); // number formatter (comma separated number i.e. 100,000,000)
-
- rootNode.select('#' + this.props.id + '-range').html("Seeing total flows <strong>from:</strong> " + x.domain().map(format).join(" <strong>to:</strong> "));
-
- //Calculate the total flows between the displayed date range
-
- total = 0;
- minDate = x.domain()[0];
- maxDate = x.domain()[1];
-
- // Go to the first millisecond on dates
- minDate.setSeconds(0);minDate.setMilliseconds(0);
- maxDate.setSeconds(59);maxDate.setMilliseconds(0);
-
- svg.selectAll("path.area").data().forEach(function (pathData)
- {
- pathData.forEach(function (record)
- {
- // Discard records outside displayed date range
- if (record.date >= minDate && record.date <= maxDate) {
- total += +record.total;
- }
- });
- });
-
- rootNode.select('#' + this.props.id + '-total').html("<strong>Total netflows in range:</strong> " + numberFormat(total));
- }
-
- /*
- Zoom event handler
- */
- function zoom() {
- if (d3.event.sourceEvent.type == "wheel") {
- if (d3.event.sourceEvent.wheelDelta < 0)
- rect.style("cursor", "zoom-out");
- else
- rect.style("cursor", "zoom-in");
- }
- else if (d3.event.sourceEvent.type == "mousemove") {
- rect.style("cursor", "e-resize");
- }
+const MARGIN = [80, 50, 50, 100];
+const TIME_FORMATER = d3.time.format('%Y-%m-%d %H:%M');
+const NUMBER_FORMATER = d3.format(',d');
- draw.call(this);
- }
+const IngestSummaryPanel = React.createClass({
+ mixins: [ContentLoaderMixin, ChartMixin],
+ buildChart() {
+ // Scales
+ this.xScale = d3.time.scale();
+ this.yScale = d3.scale.linear();
- draw.call(this);
-}
+ // Axis
+ this.xAxis = d3.svg.axis().scale(this.xScale).orient('bottom'); // Time
+ this.yAxis = d3.svg.axis().scale(this.yScale).orient('left'); // Totals
-var IngestSummaryPanel = React.createClass({
- propTypes: {
- id: React.PropTypes.string
- },
- getDefaultProperties: function () {
- return {
- id: 'spot-is'
- };
- },
- getInitialState: function ()
- {
- return {loading: true};
- },
- render:function()
- {
- var content;
-
- if (this.state.error)
- {
- content = (
- <div className="text-center text-danger">
- {this.state.error}
- </div>
- );
- }
- else if (this.state.loading)
- {
- content = (
- <div className="spot-loader">
- Loading <span className="spinner"></span>
- </div>
- );
- }
- else
- {
- content = (
- <div id={this.props.id} className="text-center">
- <div id={this.props.id + '-header'}>
- <p id={this.props.id + '-range'}></p>
- <p id={this.props.id + '-total'}></p>
- <p id={this.props.id + '-istructions'} className="small">** Zoom in/out using mouse wheel or two fingers in track pad <br /> ** Move across the x-axis by clicking anywhere in the graph and dragging to left or right</p>
- </div>
- <div id={this.props.id + '-summary'}></div>
- </div>
- );
- }
+ // An area generator.
+ this.area = d3.svg.area()
+ .x(d => this.xScale(d.date))
+ .y1(d => (isNaN(d.total) ? this.yScale(0) : this.yScale(d.total)));
- return (
- <div>{content}</div>
- )
- },
- componentDidMount: function()
- {
- NetflowIngestSummaryStore.addChangeDataListener(this._onChange);
- window.addEventListener('resize', this.buildGraph);
- },
- componentWillUnmount: function ()
- {
- NetflowIngestSummaryStore.removeChangeDataListener(this._onChange);
- window.removeEventListener('resize', this.buildGraph);
+ let d3svg = d3.select(this.svg);
+
+ const d3header = d3svg.append('g').attr('class', 'header');
+
+ d3header.append('text')
+ .attr('transform', 'translate(0,15)')
+ .html('Seeing data <tspan class="bold">from</tspan > <tspan class="min-date" /> <tspan class="bold"> to </tspan> <tspan class="max-date" />');
+
+ d3header.append('text')
+ .attr('transform', 'translate(0,30)')
+ .html('<tspan class="bold">Total</tspan> records ingested: <tspan class="total" />');
+
+ d3header.append('text')
+ .attr('transform', 'translate(0,45)')
+ .text('** Zoom in/out using mouse wheel or two fingers in track pad');
+ d3header.append('text')
+ .attr('transform', 'translate(0,60)')
+ .text('** ** Move across the x-axis by clicking anywhere in the graph and dragging to left or right');
+
+ this.updateLegends(this.state.minDate, this.state.maxDate, this.state.total);
+
+ this.canvas = d3svg.append('g')
+ .attr('transform', `translate(${MARGIN[3]},${MARGIN[0]})`);
+
+ // Append the clipPath to avoid drawing not seen data
+ this.clipRect = d3svg.append('defs')
+ .append('clipPath')
+ .attr('id', 'clip')
+ .append('rect')
+ .attr('x',0)
+ .attr('y', 0);
+
+ this.d3xAxis = this.canvas.append('g').attr('class', 'x axis');
+ this.d3yAxis = this.canvas.append('g').attr('class', 'y axis');
+ this.pipelineCanvas = this.canvas.append('g').attr('class', 'pipeline');
+
+ this.d3zoom = d3.behavior.zoom()
+ .scaleExtent([0.3, 2300]) // these are magic numbers to avoid the grap be zoomable in/out to the infinity
+ .on('zoom', this.zoom)
+
+ this.pipelineCanvas.call(this.d3zoom);
+
+ this.pipelineColor = d3.scale.category10().domain(Object.keys(IngestSummaryStore.PIPELINES));
+ },
+ draw() {
+ let $svg = $(this.svg);
+
+ this.width = $svg.width() - MARGIN[1] - MARGIN[3];
+ this.height = $svg.height() - MARGIN[0] - MARGIN[2];
+
+ d3.select(this.svg).select('.header').attr('transform', `translate(${this.width/2},0)`);
+
+ this.xScale.range([0, this.width]).domain([this.state.minDate, this.state.maxDate]);
+ this.yScale.range([this.height, 0]).domain([0, this.state.maxTotal]);
+
+ this.d3zoom.x(this.xScale)
+
+ this.area.y0(this.height);
+
+ this.clipRect
+ .attr('width', this.width)
+ .attr('height', this.height);
+
+ this.d3xAxis.attr('transform', `translate(0,${this.height})`);
+
+ this.drawPaths();
+ },
+ drawPaths() {
+ this.d3xAxis.call(this.xAxis);
+ this.d3yAxis.call(this.yAxis);
+
+ let total = 0;
+ const [minDate, maxDate] = this.xScale.domain();
+
+ // Go to the first millisecond on dates
+ minDate.setSeconds(0);minDate.setMilliseconds(0);
+ maxDate.setSeconds(59);maxDate.setMilliseconds(0);
+
+ const pipelineData = this.state.data.map(currentMonthData => {
+ // Filter records outside current date range
+ return currentMonthData.filter(record => {
+ const included = record.date>=minDate && record.date<=maxDate;
+
+ // Sum records included in range only
+ if (included) total += record.total;
+
+ return included;
+ });
+ }).filter(monthData => monthData.length>0); // Filter out empty months
+
+ this.drawPipeline(pipelineData);
+
+ this.updateLegends(minDate, maxDate, total);
+ },
+ drawPipeline(data) {
+ const pipelineSel = {};
+
+ pipelineSel.update = this.pipelineCanvas.selectAll('path.area').data(data);
+
+ pipelineSel.enter = pipelineSel.update.enter();
+ pipelineSel.exit = pipelineSel.update.exit();
+
+ pipelineSel.enter.append('path')
+ .attr('class', 'area')
+ .style('fill', this.pipelineColor(IngestSummaryStore.getPipeline()));
+
+ pipelineSel.update.attr('d', d => this.area(d));
+
+ pipelineSel.exit.remove();
+ },
+ updateLegends(minDate, maxDate, total) {
+ const minDateStr = TIME_FORMATER(minDate);
+ const maxDateStr = TIME_FORMATER(maxDate);
+ const totalStr = NUMBER_FORMATER(total);
+
+ const d3header = d3.select(this.svg).select('.header');
+
+ d3header.select('.min-date').text(minDateStr);
+ d3header.select('.max-date').text(maxDateStr);
+ d3header.select('.total').text(totalStr);
+ },
+ zoom() {
+ if (d3.event.sourceEvent.type == 'wheel') {
+ this.pipelineCanvas.classed('zoom-out', d3.event.sourceEvent.wheelDelta < 0);
+ this.pipelineCanvas.classed('zoom-in', d3.event.sourceEvent.wheelDelta >= 0);
+ this.pipelineCanvas.classed('e-resize', false);
+ }
+ else if (d3.event.sourceEvent.type == 'mousemove') {
+ this.pipelineCanvas.classed('e-resize', true);
+ this.pipelineCanvas.classed('zoom-out', false);
+ this.pipelineCanvas.classed('zoom-in', false);
+ }
+
+ this.drawPaths();
},
- componentDidUpdate: function ()
- {
- if (!this.state.loading && !this.state.error && this.state.data)
- {
- this.buildGraph();
+ componentDidMount() {
+ IngestSummaryStore.addChangeDataListener(this._onChange);
+ },
+ componentWillUnmount() {
+ IngestSummaryStore.removeChangeDataListener(this._onChange);
+ },
+ _onChange() {
+ const storeData = IngestSummaryStore.getData();
+
+ if (storeData.error) {
+ this.replaceState({error: storeData.error});
+ }
+ else if (!storeData.loading && storeData.data) {
+ this.replaceState(this._getStateFromData(storeData.data));
+ }
+ else {
+ this.replaceState({loading: storeData.loading});
+ }
+ },
+ _getStateFromData(data) {
+ let total, maxTotal, minDate, maxDate;
+
+ total = 0;
+ maxTotal = 0;
+ minDate = null;
+ maxDate = null;
+
+ data.forEach(function (monthData) {
+ monthData.forEach(function (record) {
+ minDate = d3.min([minDate, record.date]);
+ maxDate = d3.max([maxDate, record.date]);
+ maxTotal = d3.max([maxTotal, +record.total]);
+ total += +record.total;
+ });
+ });
+
+ !minDate && (minDate = DateUtils.parseDate(IngestSummaryStore.getStartDate()));
+ !maxDate && (maxDate = DateUtils.parseDate(IngestSummaryStore.getEndDate()));
+
+ return {
+ loading: false,
+ total,
+ maxTotal,
+ minDate,
+ maxDate,
+ data: data
+ };
}
- },
- buildGraph: initialDraw,
- _onChange: function () {
- this.replaceState(NetflowIngestSummaryStore.getData());
- }
});
module.exports = IngestSummaryPanel;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/js/components/OptionPicker.react.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/components/OptionPicker.react.js b/spot-oa/ui/js/components/OptionPicker.react.js
new file mode 100644
index 0000000..f8e748d
--- /dev/null
+++ b/spot-oa/ui/js/components/OptionPicker.react.js
@@ -0,0 +1,43 @@
+const React = require('react');
+
+const RadioPicker = React.createClass({
+ propTypes: {
+ id: React.PropTypes.string,
+ name: React.PropTypes.string,
+ options: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
+ value: React.PropTypes.string
+ },
+ getDefaultProps() {
+ return {
+ id: null,
+ name: null,
+ value: null
+ };
+ },
+ getInitialState() {
+ const state = {};
+
+ state.value = this.props.value || (this.props.options.length>0 ? this.props.options[0] : null);
+
+ return state;
+ },
+ render() {
+ const options = Object.keys(this.props.options).map(option => {
+ return <option value={option} selected={this.state.value==option}>
+ {this.props.options[option]}
+ </option>;
+ });
+
+ return <select id={this.props.id} className="form-control" name={this.props.name} onChange={this.onChange}>
+ {options}
+ </select>;
+ },
+ onChange(e) {
+ const value = e.target.value;
+ this.setState({value});
+
+ this.props.onChange && this.props.onChange(value);
+ }
+});
+
+module.exports = RadioPicker;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/js/constants/SpotConstants.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/constants/SpotConstants.js b/spot-oa/ui/js/constants/SpotConstants.js
index 35e23c4..e4a711d 100755
--- a/spot-oa/ui/js/constants/SpotConstants.js
+++ b/spot-oa/ui/js/constants/SpotConstants.js
@@ -1,4 +1,7 @@
-var SpotConstants = {
+const SpotConstants = {
+ PIPELINE_NETFLOW: 'flow',
+ PIPELINE_DNS: 'dns',
+ PIPELINE_PROXY: 'proxy',
// Search Actions
UPDATE_FILTER: 'UPDATE_FILTER',
UPDATE_DATE: 'UPDATE_DATE',
@@ -18,6 +21,7 @@ var SpotConstants = {
IMPACT_ANALYSIS_PANEL:'Impact Analysis',
GLOBE_VIEW_PANEL:'Map View | Globe',
TIMELINE_PANEL:'Timeline',
+ INGEST_SUMMARY_PANEL:'Ingest Summary',
// Edge Investigation
MAX_SUSPICIOUS_ROWS: 250,
RELOAD_SUSPICIOUS: 'RELOAD_SUSPICIOUS',
@@ -31,10 +35,10 @@ var SpotConstants = {
RELOAD_COMMENTS: 'RELOAD_COMMENTS',
SELECT_COMMENT: 'SELECT_COMMENT',
// INGEST SUMMARY
+ API_INGEST_SUMMARY: '../data/${pipeline}/ingest_summary/is_${year}${month}.csv',
+ RELOAD_INGEST_SUMMARY: 'RELOAD_INGEST_SUMMARY',
START_DATE: 'start-date',
END_DATE: 'end-date',
- // Ingest summary Actions
- RELOAD_INGEST_SUMMARY: 'RELOAD_INGEST_SUMMARY',
// Server Paths
NOTEBOOKS_PATH: '/notebooks/ipynb'
};
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/js/ingest-summary.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/ingest-summary.js b/spot-oa/ui/js/ingest-summary.js
index c42ed41..04f2872 100755
--- a/spot-oa/ui/js/ingest-summary.js
+++ b/spot-oa/ui/js/ingest-summary.js
@@ -3,12 +3,14 @@ const ReactDOM = require('react-dom');
const SpotActions = require('./actions/SpotActions');
const InSumActions = require('./actions/InSumActions');
+const IngestSummaryStore = require('./stores/IngestSummaryStore');
const SpotConstants = require('./constants/SpotConstants');
const SpotUtils = require('./utils/SpotUtils');
const DateUtils = require('./utils/DateUtils');
// Build and Render Toolbar
const DateInput = require('./components/DateInput.react');
+const OptionPicker = require('./components/OptionPicker.react');
// Find out period
var startDate, endDate, today;
@@ -41,32 +43,48 @@ if (endDate < startDate)
endDate = today;
}
+const PIPELINES = IngestSummaryStore.PIPELINES;
+const DEFAULT_PIPELINE = Object.keys(PIPELINES)[0];
+
+const loadPipeline = function loadPipeline(pipeline) {
+ IngestSummaryStore.setPipeline(pipeline);
+ InSumActions.reloadSummary();
+}
+
ReactDOM.render(
- (
<form className="form-inline">
- <div className="form-group">
- <label htmlFor="startDatePicker">Period:</label>
- <div className="input-group input-group-xs">
- <div className="input-group-addon">
- <span className="glyphicon glyphicon-calendar" aria-hidden="true"></span>
- </div>
- <DateInput id="startDatePicker" name={SpotConstants.START_DATE} value={startDate}/>
+ <div className="form-group">
+ <label htmlFor="pipeline-picker">Source: </label>
+ <div className="input-group input-group-xs">
+ <OptionPicker
+ id="pipeline-picker"
+ options={PIPELINES}
+ value={DEFAULT_PIPELINE}
+ onChange={loadPipeline} />
+ </div>
+ </div>
+ <div className="form-group">
+ <label htmlFor="startDatePicker">Period:</label>
+ <div className="input-group input-group-xs">
+ <div className="input-group-addon">
+ <span className="glyphicon glyphicon-calendar" aria-hidden="true"></span>
+ </div>
+ <DateInput id="startDatePicker" name={SpotConstants.START_DATE} value={startDate}/>
+ </div>
</div>
- </div>
- <div className="form-group">
- <label htmlFor="endDatePicker"> - </label>
- <div className="input-group input-group-xs">
- <DateInput id="endDatePicker" name={SpotConstants.END_DATE} value={endDate} />
- <div className="input-group-btn">
- <button className="btn btn-default" type="button" title="Reload" onClick={InSumActions.reloadSummary}>
- <span className="glyphicon glyphicon-repeat" aria-hidden="true"></span>
- </button>
- </div>
+ <div className="form-group">
+ <label htmlFor="endDatePicker"> - </label>
+ <div className="input-group input-group-xs">
+ <DateInput id="endDatePicker" name={SpotConstants.END_DATE} value={endDate} />
+ <div className="input-group-btn">
+ <button className="btn btn-default" type="button" title="Reload" onClick={InSumActions.reloadSummary}>
+ <span className="glyphicon glyphicon-repeat" aria-hidden="true"></span>
+ </button>
+ </div>
+ </div>
</div>
- </div>
- </form>
- ),
- document.getElementById('nav_form')
+ </form>,
+ document.getElementById('nav_form')
);
// Build and Render Edge Investigation's panels
@@ -79,7 +97,7 @@ ReactDOM.render(
<div id="spot-content">
<PanelRow maximized>
<Panel title="Ingest Summary" container header={false} className="col-md-12">
- <IngestSummaryPanel id="spot-is" />
+ <IngestSummaryPanel className="is-chart" />
</Panel>
</PanelRow>
</div>,
@@ -91,4 +109,4 @@ SpotActions.setDate(startDate, SpotConstants.START_DATE);
SpotActions.setDate(endDate, SpotConstants.END_DATE);
// Load data
-InSumActions.reloadSummary();
+loadPipeline(DEFAULT_PIPELINE);
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/js/stores/IngestSummaryStore.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/stores/IngestSummaryStore.js b/spot-oa/ui/js/stores/IngestSummaryStore.js
index 9e4ccb5..ca8a439 100755
--- a/spot-oa/ui/js/stores/IngestSummaryStore.js
+++ b/spot-oa/ui/js/stores/IngestSummaryStore.js
@@ -1,34 +1,55 @@
-var assign = require('object-assign');
-var d3 = require('d3');
-
-var SpotDispatcher = require('../../../js/dispatchers/SpotDispatcher');
-var SpotConstants = require('../../../js/constants/SpotConstants');
-var NetflowConstants = require('../constants/NetflowConstants');
-var DateUtils = require('../../../js/utils/DateUtils');
-var RestStore = require('../../../js/stores/RestStore');
-
-var START_DATE_FILTER = NetflowConstants.START_DATE;
-var END_DATE_FILTER = NetflowConstants.END_DATE;
-var CURRENT_DATE_FILTER = 'current_date';
-
-var requestQueue = [];
-var requestErrors = [];
-
-var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMARY), {
+const assign = require('object-assign');
+const d3 = require('d3');
+
+const SpotDispatcher = require('../dispatchers/SpotDispatcher');
+const SpotConstants = require('../constants/SpotConstants');
+const DateUtils = require('../utils/DateUtils');
+const RestStore = require('../stores/RestStore');
+
+const PIPELINE_FILTER = 'pipeline';
+const CURRENT_YEAR_FILTER = 'year';
+const CURRENT_MONTH_FILTER = 'month';
+
+const requestQueue = [];
+const requestErrors = [];
+
+const IngestSummaryStore = assign(new RestStore(SpotConstants.API_INGEST_SUMMARY), {
+ PIPELINES: {
+ [SpotConstants.PIPELINE_NETFLOW]: 'Netflow',
+ [SpotConstants.PIPELINE_DNS]: 'Dns',
+ [SpotConstants.PIPELINE_PROXY]: 'Proxy'
+ },
errorMessages: {
404: 'No details available'
},
- setStartDate: function (date) {
- this.setRestFilter(START_DATE_FILTER, date);
+ setStartDate(date) {
+ this._startDate = date;
+ },
+ getStartDate() {
+ return this._startDate;
+ },
+ setEndDate(date) {
+ this._endDate = date;
},
- getStartDate: function () {
- return this.getRestFilter(START_DATE_FILTER);
+ getEndDate() {
+ return this._endDate;
},
- setEndDate: function (date) {
- this.setRestFilter(END_DATE_FILTER, date);
+ setPipeline(pipeline) {
+ this.setRestFilter(PIPELINE_FILTER, pipeline);
},
- getEndDate: function () {
- return this.getRestFilter(END_DATE_FILTER);
+ getPipeline() {
+ return this.getRestFilter(PIPELINE_FILTER);
+ },
+ setCurrentDate(date) {
+ this.setRestFilter(CURRENT_YEAR_FILTER, date.getFullYear())
+
+ const month = date.getMonth() + 1 + "";
+ this.setRestFilter(CURRENT_MONTH_FILTER, month.length==1 ? `0${month}`:month);
+
+ this._currentDate = date;
+ },
+ getCurrentDate() {
+ return this._currentDate;
},
/**
* Start asking the server for CSV data to create the chart
@@ -36,8 +57,8 @@ var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMAR
requestSummary: function () {
var startDate, endDate, date, delta, startRequests, i, month;
- startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
- endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
+ startDate = DateUtils.parseDate(this.getStartDate());
+ endDate = DateUtils.parseDate(this.getEndDate());
// Find out how many request need to be made
delta = (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
@@ -58,17 +79,10 @@ var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMAR
startRequests && this.dequeue();
},
dequeue: function () {
- var date, year, month;
-
if (requestQueue.length == 0) return;
- date = requestQueue.shift();
- this.setRestFilter(CURRENT_DATE_FILTER, date);
- year = date.getFullYear();
- month = date.getMonth() + 1 + "";
- month = month.length == 1 ? "0" + month : month;
-
- this.setEndpoint(NetflowConstants.API_INGEST_SUMMARY.replace('${year}', year).replace('${month}', month));
+ const date = requestQueue.shift();
+ this.setCurrentDate(date);
this.reload();
},
@@ -91,10 +105,10 @@ var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMAR
requestErrors.push(data);
}
else if (data.data) {
- parse = d3.time.format("%Y-%m-%d %H:%M").parse; // Date formatting parser
- startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
- endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
- date = DateUtils.parseDate(this.getRestFilter(CURRENT_DATE_FILTER));
+ parse = d3.time.format("%Y-%m-%d %H:%M:%S%Z").parse; // Date formatting parser
+ startDate = DateUtils.parseDate(this.getStartDate());
+ endDate = DateUtils.parseDate(this.getEndDate());
+ date = DateUtils.parseDate(this.getCurrentDate());
if (date.getFullYear() == startDate.getFullYear() && date.getMonth() == startDate.getMonth()) {
dayFilter = startDate.getDate();
@@ -112,8 +126,8 @@ var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMAR
// Parse dates and numbers.
data.data.forEach(function (d) {
- d.date = parse(d.date);
- d.flows = +d.flows;
+ d.date = parse(`${d.date}:00-0000`);
+ d.total = +d.total;
});
// Sort the data by date ASC
@@ -122,13 +136,14 @@ var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMAR
});
if (!this._data.data) this._data.data = [];
+
this._data.data.push(data.data);
}
this._data.loading = requestQueue.length > 0;
if (!this._data.loading) {
- if (this._data.data.length==0) {
+ if (this._data.data && this._data.data.length==0) {
// Broadcast first found error
this._data = requestErrors[0];
}
@@ -144,15 +159,15 @@ SpotDispatcher.register(function (action) {
switch (action.actionType) {
case SpotConstants.UPDATE_DATE:
switch (action.name) {
- case NetflowConstants.START_DATE:
+ case SpotConstants.START_DATE:
IngestSummaryStore.setStartDate(action.date);
break;
- case NetflowConstants.END_DATE:
+ case SpotConstants.END_DATE:
IngestSummaryStore.setEndDate(action.date);
break;
}
break;
- case NetflowConstants.RELOAD_INGEST_SUMMARY:
+ case SpotConstants.RELOAD_INGEST_SUMMARY:
IngestSummaryStore.requestSummary();
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/0d9bd5e0/spot-oa/ui/package.json
----------------------------------------------------------------------
diff --git a/spot-oa/ui/package.json b/spot-oa/ui/package.json
index 9e76f09..5a7002e 100644
--- a/spot-oa/ui/package.json
+++ b/spot-oa/ui/package.json
@@ -37,7 +37,7 @@
"scripts": {
"test": "jest",
"postinstall": "npm run build-all",
- "watch-ingest-summary": "watchify js/ingest-summary.js -o js/ingest-summary.bundle.min.js -v -d",
+ "watch-ingest-summary": "NODE_ENV=development watchify js/ingest-summary.js -o js/ingest-summary.bundle.min.js -v -d",
"build-all": "npm run build-flow && npm run build-dns && npm run build-proxy && npm run build-ingest-summary",
"build-flow": "cd flow/ && npm run build-all && cd ../",
"build-dns": "cd dns/ && npm run build-all && cd ../",
[6/7] incubator-spot git commit: flow/js/stores/IngestSummaryStore.js
is not needed anymore
Posted by ev...@apache.org.
flow/js/stores/IngestSummaryStore.js is not needed anymore
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/466ff0aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/466ff0aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/466ff0aa
Branch: refs/heads/master
Commit: 466ff0aa400e9897bc9cb70095290313ace3d773
Parents: 0d9bd5e
Author: Diego Ortiz Huerta <di...@intel.com>
Authored: Mon Dec 12 10:20:15 2016 -0800
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.local>
Committed: Tue Jan 10 10:41:13 2017 -0600
----------------------------------------------------------------------
spot-oa/ui/flow/js/stores/IngestSummaryStore.js | 161 -------------------
1 file changed, 161 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/466ff0aa/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/stores/IngestSummaryStore.js b/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
deleted file mode 100755
index 55f2106..0000000
--- a/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
+++ /dev/null
@@ -1,161 +0,0 @@
-const assign = require('object-assign');
-const d3 = require('d3');
-
-const SpotDispatcher = require('../../../js/dispatchers/SpotDispatcher');
-const SpotConstants = require('../../../js/constants/SpotConstants');
-const NetflowConstants = require('../constants/NetflowConstants');
-const DateUtils = require('../../../js/utils/DateUtils');
-const RestStore = require('../../../js/stores/RestStore');
-
-const START_DATE_FILTER = SpotConstants.START_DATE;
-const END_DATE_FILTER = SpotConstants.END_DATE;
-const CURRENT_DATE_FILTER = 'current_date';
-
-const requestQueue = [];
-const requestErrors = [];
-
-const IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMARY), {
- errorMessages: {
- 404: 'No details available'
- },
- setStartDate: function (date) {
- this.setRestFilter(START_DATE_FILTER, date);
- },
- getStartDate: function () {
- return this.getRestFilter(START_DATE_FILTER);
- },
- setEndDate: function (date) {
- this.setRestFilter(END_DATE_FILTER, date);
- },
- getEndDate: function () {
- return this.getRestFilter(END_DATE_FILTER);
- },
- /**
- * Start asking the server for CSV data to create the chart
- **/
- requestSummary: function () {
- var startDate, endDate, date, delta, startRequests, i, month;
-
- startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
- endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
-
- // Find out how many request need to be made
- delta = (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
-
- startRequests = requestQueue.length == 0;
-
- // Go to first day in month
- date = new Date(startDate);
- date.setDate(1);
-
- // Queue date requests
- requestQueue.push(date);
- for (i = 1; i <= delta; i++) {
- requestQueue.push(DateUtils.calcDate(date, i, 'month'));
- }
-
- // dequeue is no request is running
- startRequests && this.dequeue();
- },
- dequeue: function () {
- var date, year, month;
-
- if (requestQueue.length == 0) return;
-
- date = requestQueue.shift();
- this.setRestFilter(CURRENT_DATE_FILTER, date);
- year = date.getFullYear();
- month = date.getMonth() + 1 + "";
- month = month.length == 1 ? "0" + month : month;
-
- this.setEndpoint(NetflowConstants.API_INGEST_SUMMARY.replace('${year}', year).replace('${month}', month));
-
- this.reload();
- },
- setData: function (data) {
- var startDate, endDate, date, dayFilter, parse;
-
- // Does the loading indicator needs to be displayed?
- if (data.loading) {
- if (!this._data.loading) {
- this._data = data;
- this.emitChangeData();
- }
-
- // Do nothing when loading is in progress
- return;
- }
-
- // Store errors for later usage
- if (data.error) {
- requestErrors.push(data);
- }
- else if (data.data) {
- parse = d3.time.format("%Y-%m-%d %H:%M").parse; // Date formatting parser
- startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
- endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
- date = DateUtils.parseDate(this.getRestFilter(CURRENT_DATE_FILTER));
-
- if (date.getFullYear() == startDate.getFullYear() && date.getMonth() == startDate.getMonth()) {
- dayFilter = startDate.getDate();
- data.data = data.data.filter(function (row) {
- return DateUtils.parseDate(row.date, true).getDate() >= dayFilter
- });
- }
-
- if (date.getFullYear() == endDate.getFullYear() && date.getMonth() == endDate.getMonth()) {
- dayFilter = endDate.getDate();
- data.data = data.data.filter(function (row) {
- return DateUtils.parseDate(row.date, true).getDate() <= dayFilter
- });
- }
-
- // Parse dates and numbers.
- data.data.forEach(function (d) {
- d.date = parse(d.date);
- d.flows = +d.flows;
- });
-
- // Sort the data by date ASC
- data.data.sort(function (a, b) {
- return a.date - b.date;
- });
-
- if (!this._data.data) this._data.data = [];
- this._data.data.push(data.data);
- }
-
- this._data.loading = requestQueue.length > 0;
-
- if (!this._data.loading) {
- if (this._data.data && this._data.data.length==0) {
- // Broadcast first found error
- this._data = requestErrors[0];
- }
- this.emitChangeData();
- }
- else {
- setTimeout(this.dequeue.bind(this), 1);
- }
- }
-});
-
-SpotDispatcher.register(function (action) {
- switch (action.actionType) {
- case SpotConstants.UPDATE_DATE:
- switch (action.name) {
- case SpotConstants.START_DATE:
- IngestSummaryStore.setStartDate(action.date);
- break;
- case SpotConstants.END_DATE:
- IngestSummaryStore.setEndDate(action.date);
- break;
- }
- break;
- case SpotConstants.RELOAD_INGEST_SUMMARY:
- IngestSummaryStore.requestSummary();
- break;
- }
-});
-
-module.exports = IngestSummaryStore;
[5/7] incubator-spot git commit: Added Ingest summary method to dns
and proxy, added validations to flows ingest summary method
Posted by ev...@apache.org.
Added Ingest summary method to dns and proxy, added validations to flows ingest summary method
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/ae3fca38
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/ae3fca38
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/ae3fca38
Branch: refs/heads/master
Commit: ae3fca389930b4ea3ff1f1c7cbb0965c794ca563
Parents: 8446e36
Author: LedaLima <ga...@intel.com>
Authored: Mon Dec 12 10:56:25 2016 -0600
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.local>
Committed: Tue Jan 10 10:41:13 2017 -0600
----------------------------------------------------------------------
spot-oa/oa/dns/dns_oa.py | 74 +++++++++++++++++++++++++++++++++++++--
spot-oa/oa/flow/flow_oa.py | 73 +++++++++++++++++++++-----------------
spot-oa/oa/proxy/proxy_oa.py | 58 +++++++++++++++++++++++++++++-
3 files changed, 169 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/ae3fca38/spot-oa/oa/dns/dns_oa.py
----------------------------------------------------------------------
diff --git a/spot-oa/oa/dns/dns_oa.py b/spot-oa/oa/dns/dns_oa.py
index 884d46c..4f0dab9 100644
--- a/spot-oa/oa/dns/dns_oa.py
+++ b/spot-oa/oa/dns/dns_oa.py
@@ -5,7 +5,7 @@ import json
import shutil
import sys
import datetime
-import csv
+import csv, math
from tld import get_tld
from collections import OrderedDict
@@ -14,7 +14,7 @@ from components.data.data import Data
from components.iana.iana_transform import IanaTransform
from components.nc.network_context import NetworkContext
from multiprocessing import Process
-
+import pandas as pd
import time
class OA(object):
@@ -70,6 +70,7 @@ class OA(object):
self._add_network_context()
self._create_dns_scores_csv()
self._get_oa_details()
+ self._ingest_summary()
##################
end = time.time()
@@ -151,7 +152,15 @@ class OA(object):
def _add_tld_column(self):
qry_name_col = self._conf['dns_results_fields']['dns_qry_name']
- self._dns_scores = [conn + [ get_tld("http://" + str(conn[qry_name_col]), fail_silently=True) if "http://" not in str(conn[qry_name_col]) else get_tld(str(conn[qry_name_col]), fail_silently=True)] for conn in self._dns_scores ]
+ for conn in self._dns_scores:
+ try:
+ tld = get_tld("http://" + str(conn[qry_name_col]))
+ except ValueError:
+ print conn[qry_name_col]
+
+
+ # self._dns_scores = [conn + [ get_tld("http://" + str(conn[qry_name_col]), fail_silently=True) if "http://" not in str(conn[qry_name_col]) else get_tld(str(conn[qry_name_col]), fail_silently=True)] for conn in self._dns_scores ]
+
def _add_reputation(self):
@@ -326,3 +335,62 @@ class OA(object):
dndro_qry = ("SELECT dns_a, dns_qry_name, ip_dst FROM (SELECT susp.ip_dst, susp.dns_qry_name, susp.dns_a FROM {0}.{1} as susp WHERE susp.y={2} AND susp.m={3} AND susp.d={4} AND susp.ip_dst='{5}' LIMIT {6}) AS tmp GROUP BY dns_a, dns_qry_name, ip_dst").format(db,table,year,month,day,ip_dst,limit)
# execute query
self._engine.query(dndro_qry,dendro_file)
+
+
+ def _ingest_summary(self):
+ # get date parameters.
+ yr = self._date[:4]
+ mn = self._date[4:6]
+ dy = self._date[6:]
+
+ self._logger.info("Getting ingest summary data for the day")
+
+ ingest_summary_cols = ["date","total"]
+ result_rows = []
+ df_filtered = pd.DataFrame()
+
+ ingest_summary_file = "{0}/is_{1}{2}.csv".format(self._ingest_summary_path,yr,mn)
+ ingest_summary_tmp = "{0}.tmp".format(ingest_summary_file)
+
+ if os.path.isfile(ingest_summary_file):
+ df = pd.read_csv(ingest_summary_file, delimiter=',')
+ #discards previous rows from the same date
+ df_filtered = df[df['date'].str.contains("{0}-{1}-{2}".format(yr, mn, dy)) == False]
+ else:
+ df = pd.DataFrame()
+
+ # get ingest summary.
+ ingest_summary_qry = ("SELECT frame_time, COUNT(*) as total "
+ " FROM {0}.{1}"
+ " WHERE y={2} AND m={3} AND d={4} "
+ " AND unix_tstamp IS NOT NULL AND frame_time IS NOT NULL"
+ " AND frame_len IS NOT NULL AND dns_qry_name IS NOT NULL"
+ " AND ip_src IS NOT NULL "
+ " AND (dns_qry_class IS NOT NULL AND dns_qry_type IS NOT NULL AND dns_qry_rcode IS NOT NULL ) "
+ " GROUP BY frame_time;")
+
+ ingest_summary_qry = ingest_summary_qry.format(self._db,self._table_name, yr, mn, dy)
+
+ results_file = "{0}/results_{1}.csv".format(self._ingest_summary_path,self._date)
+ self._engine.query(ingest_summary_qry,output_file=results_file,delimiter=",")
+
+
+ if os.path.isfile(results_file):
+ df_results = pd.read_csv(results_file, delimiter=',')
+
+ # Forms a new dataframe splitting the minutes from the time column
+ df_new = pd.DataFrame([["{0}-{1}-{2} {3}:{4}".format(yr, mn, dy,val['frame_time'].split(" ")[3].split(":")[0].zfill(2),val['frame_time'].split(" ")[3].split(":")[1].zfill(2)), int(val['total']) if not math.isnan(val['total']) else 0 ] for key,val in df_results.iterrows()],columns = ingest_summary_cols)
+
+ #Groups the data by minute
+ sf = df_new.groupby(by=['date'])['total'].sum()
+
+ df_per_min = pd.DataFrame({'date':sf.index, 'total':sf.values})
+
+ df_final = df_filtered.append(df_per_min, ignore_index=True)
+ df_final.to_csv(ingest_summary_tmp,sep=',', index=False)
+
+ os.remove(results_file)
+ os.rename(ingest_summary_tmp,ingest_summary_file)
+ else:
+ self._logger.info("No data found for the ingest summary")
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/ae3fca38/spot-oa/oa/flow/flow_oa.py
----------------------------------------------------------------------
diff --git a/spot-oa/oa/flow/flow_oa.py b/spot-oa/oa/flow/flow_oa.py
index 870251b..7c1013a 100644
--- a/spot-oa/oa/flow/flow_oa.py
+++ b/spot-oa/oa/flow/flow_oa.py
@@ -7,6 +7,7 @@ import json
import numpy as np
import linecache, bisect
import csv
+import pandas as pd
from collections import OrderedDict
from multiprocessing import Process
@@ -51,7 +52,7 @@ class OA(object):
# initialize data engine
self._db = self._spot_conf.get('conf', 'DBNAME').replace("'", "").replace('"', '')
self._engine = Data(self._db, self._table_name,self._logger)
-
+
def start(self):
####################
@@ -386,47 +387,55 @@ class OA(object):
self._engine.query(ch_query.format(self._db,self._table_name,yr,mn,dy,ip,ips_filter),chord_file,delimiter="\\t")
- def _ingest_summary(self):
-
+ def _ingest_summary(self):
# get date parameters.
yr = self._date[:4]
mn = self._date[4:6]
dy = self._date[6:]
+ self._logger.info("Getting ingest summary data for the day")
+
+ ingest_summary_cols = ["date","total"]
+ result_rows = []
+ df_filtered = pd.DataFrame()
+
+ ingest_summary_file = "{0}/is_{1}{2}.csv".format(self._ingest_summary_path,yr,mn)
+ ingest_summary_tmp = "{0}.tmp".format(ingest_summary_file)
+ if os.path.isfile(ingest_summary_file):
+ df = pd.read_csv(ingest_summary_file, delimiter=',',names=ingest_summary_cols, skiprows=1)
+ df_filtered = df[df['date'].str.contains("{0}-{1}-{2}".format(yr, mn, dy)) == False]
+ else:
+ df = pd.DataFrame()
+
# get ingest summary.
- ingest_summary_qry = ("SELECT tryear, trmonth, trday, trhour, trminute, COUNT(*) flows"
- " FROM {0}.flow "
- " WHERE "
- " y={1} "
- " AND m={2} "
- " AND d={3} "
- " AND unix_tstamp IS NOT NULL "
- " GROUP BY tryear, trmonth, trday, trhour, trminute;")
-
- ingest_summary_qry = ingest_summary_qry.format(self._db, yr, mn, dy)
-
+ ingest_summary_qry = ("SELECT tryear, trmonth, trday, trhour, trminute, COUNT(*) total"
+ " FROM {0}.{1} "
+ " WHERE "
+ " y={2} "
+ " AND m={3} "
+ " AND d={4} "
+ " AND unix_tstamp IS NOT NULL AND sip IS NOT NULL "
+ " AND sport IS NOT NULL AND dip IS NOT NULL "
+ " AND dport IS NOT NULL AND ibyt IS NOT NULL "
+ " AND ipkt IS NOT NULL "
+ " GROUP BY tryear, trmonth, trday, trhour, trminute;")
+
+
+ ingest_summary_qry = ingest_summary_qry.format(self._db,self._table_name, yr, mn, dy)
results_file = "{0}/results_{1}.csv".format(self._ingest_summary_path,self._date)
self._engine.query(ingest_summary_qry,output_file=results_file,delimiter=",")
-
- result_rows = []
- with open(results_file, 'rb') as rf:
- csv_reader = csv.reader(rf, delimiter = ",")
- result_rows = list(csv_reader)
-
- result_rows = iter(result_rows)
- next(result_rows)
- ingest_summary_results = [ ["date","flows"] ]
- ingest_summary_results.extend([ ["{0}-{1}-{2} {3}:{4}".format(yr, mn, dy, row[3].zfill(2) ,row[4].zfill(2)), row[5]] for row in result_rows ])
- ingest_summay_file = "{0}/is_{1}{2}.csv".format(self._ingest_summary_path,yr,mn)
+ if os.path.isfile(results_file):
+ result_rows = pd.read_csv(results_file, delimiter=',')
+ df_new = pd.DataFrame([["{0}-{1}-{2} {3}:{4}".format(yr, mn, dy, str(val['trhour']).zfill(2), str(val['trminute']).zfill(2)), int(val[5])] for key,val in result_rows.iterrows()],columns = ingest_summary_cols)
- write_format = 'a' if os.path.isfile(ingest_summay_file) else 'w+'
- with open(ingest_summay_file, write_format) as u_file:
- writer = csv.writer(u_file, quoting=csv.QUOTE_NONE, delimiter=",")
- writer.writerows(ingest_summary_results)
+ df_filtered = df_filtered.append(df_new, ignore_index=True)
+ df_filtered.to_csv(ingest_summary_tmp,sep=',', index=False)
- rm_big_file = "rm {0}".format(results_file)
- os.remove(results_file)
-
+ os.remove(results_file)
+ os.rename(ingest_summary_tmp,ingest_summary_file)
+ else:
+ self._logger.info("No data found for the ingest summary")
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/ae3fca38/spot-oa/oa/proxy/proxy_oa.py
----------------------------------------------------------------------
diff --git a/spot-oa/oa/proxy/proxy_oa.py b/spot-oa/oa/proxy/proxy_oa.py
index d9b0362..7359ba1 100644
--- a/spot-oa/oa/proxy/proxy_oa.py
+++ b/spot-oa/oa/proxy/proxy_oa.py
@@ -5,13 +5,14 @@ import json
import shutil
import sys
import datetime
-import csv
+import csv, math
from collections import OrderedDict
from utils import Util
from components.data.data import Data
from components.iana.iana_transform import IanaTransform
from components.nc.network_context import NetworkContext
from multiprocessing import Process
+import pandas as pd
import time
import md5
@@ -70,6 +71,7 @@ class OA(object):
self._add_hash()
self._create_proxy_scores_csv()
self._get_oa_details()
+ self._ingest_summary()
##################
@@ -292,3 +294,57 @@ class OA(object):
except OSError:
pass
+
+ def _ingest_summary(self):
+ # get date parameters.
+ yr = self._date[:4]
+ mn = self._date[4:6]
+ dy = self._date[6:]
+
+ self._logger.info("Getting ingest summary data for the day")
+
+ ingest_summary_cols = ["date","total"]
+ result_rows = []
+ df_filtered = pd.DataFrame()
+
+ ingest_summary_file = "{0}/is_{1}{2}.csv".format(self._ingest_summary_path,yr,mn)
+ ingest_summary_tmp = "{0}.tmp".format(ingest_summary_file)
+
+ if os.path.isfile(ingest_summary_file):
+ df = pd.read_csv(ingest_summary_file, delimiter=',')
+ #discards previous rows from the same date
+ df_filtered = df[df['date'].str.contains("{0}-{1}-{2}".format(yr, mn, dy)) == False]
+ else:
+ df = pd.DataFrame()
+
+ # get ingest summary.
+ ingest_summary_qry = ("SELECT p_date, p_time, COUNT(*) as total "
+ " FROM {0}.{1}"
+ " WHERE y='{2}' AND m='{3}' AND d='{4}' "
+ " AND p_date IS NOT NULL AND p_time IS NOT NULL "
+ " AND clientip IS NOT NULL AND p_time != '' "
+ " AND host IS NOT NULL AND fulluri IS NOT NULL "
+ " GROUP BY p_date, p_time;")
+
+ ingest_summary_qry = ingest_summary_qry.format(self._db,self._table_name, yr, mn, dy)
+ results_file = "{0}/results_{1}.csv".format(self._ingest_summary_path,self._date)
+ self._engine.query(ingest_summary_qry,output_file=results_file,delimiter=",")
+
+ if os.path.isfile(results_file):
+ df_results = pd.read_csv(results_file, delimiter=',')
+
+ #Forms a new dataframe splitting the minutes from the time column/
+ df_new = pd.DataFrame([["{0} {1}:{2}".format(val['p_date'], val['p_time'].split(":")[0].zfill(2), val['p_time'].split(":")[1].zfill(2)), int(val['total']) if not math.isnan(val['total']) else 0 ] for key,val in df_results.iterrows()],columns = ingest_summary_cols)
+
+ #Groups the data by minute
+ sf = df_new.groupby(by=['date'])['total'].sum()
+ df_per_min = pd.DataFrame({'date':sf.index, 'total':sf.values})
+
+ df_final = df_filtered.append(df_per_min, ignore_index=True)
+ df_final.to_csv(ingest_summary_tmp,sep=',', index=False)
+
+ os.remove(results_file)
+ os.rename(ingest_summary_tmp,ingest_summary_file)
+ else:
+ self._logger.info("No data found for the ingest summary")
+
\ No newline at end of file
[7/7] incubator-spot git commit: Removed test code from dns_oa.py
Posted by ev...@apache.org.
Removed test code from dns_oa.py
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/f410dd8f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/f410dd8f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/f410dd8f
Branch: refs/heads/master
Commit: f410dd8f6e61b247e508ba754dbce0663666fcfd
Parents: ae3fca3
Author: LedaLima <ga...@intel.com>
Authored: Mon Dec 12 11:31:50 2016 -0600
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.local>
Committed: Tue Jan 10 10:41:13 2017 -0600
----------------------------------------------------------------------
spot-oa/oa/dns/dns_oa.py | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/f410dd8f/spot-oa/oa/dns/dns_oa.py
----------------------------------------------------------------------
diff --git a/spot-oa/oa/dns/dns_oa.py b/spot-oa/oa/dns/dns_oa.py
index 4f0dab9..2f8687f 100644
--- a/spot-oa/oa/dns/dns_oa.py
+++ b/spot-oa/oa/dns/dns_oa.py
@@ -152,14 +152,7 @@ class OA(object):
def _add_tld_column(self):
qry_name_col = self._conf['dns_results_fields']['dns_qry_name']
- for conn in self._dns_scores:
- try:
- tld = get_tld("http://" + str(conn[qry_name_col]))
- except ValueError:
- print conn[qry_name_col]
-
-
- # self._dns_scores = [conn + [ get_tld("http://" + str(conn[qry_name_col]), fail_silently=True) if "http://" not in str(conn[qry_name_col]) else get_tld(str(conn[qry_name_col]), fail_silently=True)] for conn in self._dns_scores ]
+ self._dns_scores = [conn + [ get_tld("http://" + str(conn[qry_name_col]), fail_silently=True) if "http://" not in str(conn[qry_name_col]) else get_tld(str(conn[qry_name_col]), fail_silently=True)] for conn in self._dns_scores ]
def _add_reputation(self):
[4/7] incubator-spot git commit: Ingest summary is now a top level
section
Posted by ev...@apache.org.
Ingest summary is now a top level section
Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/86d15527
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/86d15527
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/86d15527
Branch: refs/heads/master
Commit: 86d155278ebfad036599f58d6b7bf94493e1d713
Parents: 8830127
Author: Diego Ortiz Huerta <di...@intel.com>
Authored: Tue Dec 6 08:53:11 2016 -0800
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.local>
Committed: Tue Jan 10 10:41:13 2017 -0600
----------------------------------------------------------------------
spot-oa/ui/flow/ingest-summary.html | 158 -------------
spot-oa/ui/flow/js/actions/InSumActions.js | 12 -
.../js/components/IngestSummaryPanel.react.js | 235 ------------------
.../ui/flow/js/constants/NetflowConstants.js | 9 +-
spot-oa/ui/flow/js/ingest-summary.js | 94 --------
spot-oa/ui/flow/js/stores/IngestSummaryStore.js | 34 +--
spot-oa/ui/flow/package.json | 6 +-
spot-oa/ui/ingest-summary.html | 155 ++++++++++++
spot-oa/ui/js/actions/InSumActions.js | 12 +
.../js/components/IngestSummaryPanel.react.js | 236 +++++++++++++++++++
spot-oa/ui/js/constants/SpotConstants.js | 5 +
spot-oa/ui/js/ingest-summary.js | 94 ++++++++
spot-oa/ui/js/stores/IngestSummaryStore.js | 161 +++++++++++++
spot-oa/ui/package.json | 6 +-
14 files changed, 688 insertions(+), 529 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/flow/ingest-summary.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/ingest-summary.html b/spot-oa/ui/flow/ingest-summary.html
deleted file mode 100755
index c13ab9f..0000000
--- a/spot-oa/ui/flow/ingest-summary.html
+++ /dev/null
@@ -1,158 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Netflow :: Ingest Summary</title>
-
- <meta charset="UTF-8">
-
- <!--Bootstrap styles-->
- <link rel="stylesheet" type="text/css" href="../css/bootstrap-spot.min.css" />
- <!--Bootstrap Date picker styles-->
- <link rel="stylesheet" type="text/css" href="../node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css" />
- <!-- Spot styles -->
- <link rel="stylesheet" type="text/css" href="../css/main.css" />
- <!-- Favicon -->
- <link rel="apple-touch-icon" sizes="57x57" href="../images/favicon/apple-icon-57x57.png">
- <link rel="apple-touch-icon" sizes="60x60" href="../images/favicon/apple-icon-60x60.png"
- <link rel="apple-touch-icon" sizes="72x72" href="../images/favicon/apple-icon-72x72.png">
- <link rel="apple-touch-icon" sizes="76x76" href="../images/favicon/apple-icon-76x76.png">
- <link rel="apple-touch-icon" sizes="114x114" href="../images/favicon/apple-icon-114x114.png">
- <link rel="apple-touch-icon" sizes="120x120" href="../images/favicon/apple-icon-120x120.png">
- <link rel="apple-touch-icon" sizes="144x144" href="../images/favicon/apple-icon-144x144.png">
- <link rel="apple-touch-icon" sizes="152x152" href="../images/favicon/apple-icon-152x152.png">
- <link rel="apple-touch-icon" sizes="180x180" href="../images/favicon/apple-icon-180x180.png">
- <link rel="icon" type="image/png" sizes="192x192" href="../images/favicon/android-icon-192x192.png">
- <link rel="icon" type="image/png" sizes="32x32" href="../images/favicon/favicon-32x32.png">
- <link rel="icon" type="image/png" sizes="96x96" href="../images/favicon/favicon-96x96.png">
- <link rel="icon" type="image/png" sizes="16x16" href="../images/favicon/favicon-16x16.png">
- <link rel="manifest" href="../images/favicon/manifest.json">
- <meta name="msapplication-TileColor" content="#ffffff">
- <meta name="msapplication-TileImage" content="../images/favicon/ms-icon-144x144.png">
- <meta name="theme-color" content="#ffffff">
- <style type="text/css">
- .spot-row {
- height: 100%;
- }
-
- #spot-is-header {
- width: 100%;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 2;
- height: auto;
- }
-
- #spot-is, #spot-is-summary {
- height: 100%;
- }
-
- .axis {
- shape-rendering: crispEdges;
- }
-
- .axis path, .axis line {
- fill: none;
- }
-
- rect.pane {
- cursor: e-resize;
- fill: none;
- pointer-events: all;
- }
- </style>
-</head>
-<body>
- <nav id="spot-nav" class="navbar navbar-default">
- <div class="container-fluid">
- <!-- App name and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <span class="navbar-brand">Apache Spot :: Netflow :: Ingest Summary</span>
- </div>
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="main-menu">
- <ul class="nav navbar-nav navbar-right">
- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
- Flows
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu" aria-labelledby="flowsMenu">
- <li>
- <a data-href="suspicious.html#date=${end-date}">Suspicious</a>
- </li>
- <li>
- <a data-href="threat-investigation.html#date=${end-date}">Threat Investigation</a>
- </li>
- <li>
- <a data-href="storyboard.html#date=${end-date}">Storyboard</a>
- </li>
- <li>
- <a data-href="ingest-summary.html#end-date=${end-date}">Ingest Summary</a>
- </li>
- </ul>
- </li>
- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
- DNS
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu" aria-labelledby="dnsMenu">
- <li>
- <a data-href="../dns/suspicious.html#date=${end-date}">Suspicious</a>
- </li>
- <li>
- <a data-href="../dns/threat-investigation.html#date=${end-date}">Threat Investigation</a>
- </li>
- <li>
- <a data-href="../dns/storyboard.html#date=${end-date}">Storyboard</a>
- </li>
- </ul>
- </li>
- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
- Proxy
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu" aria-labelledby="proxyMenu">
- <li>
- <a data-href="../proxy/suspicious.html#date=${end-date}">Suspicious</a>
- </li>
- <li>
- <a data-href="../proxy/threat-investigation.html#date=${end-date}">Threat Investigation</a>
- </li>
- <li>
- <a data-href="../proxy/storyboard.html#date=${end-date}">Storyboard</a>
- </li>
- </ul>
- </li>
- </ul>
- </div>
- <div id="search-box" class="row text-right">
- <!--Tools Buttons-->
- <div id="nav_form" class="col-md-12">
- <!-- Search form placeholder -->
- </div>
- </div> <!-- /Tools Buttons-->
- </div>
- </nav>
- <div id="spot-content-wrapper" class="container-fluid">
- <!-- Main Content Placeholder -->
- </div>
-
- <!-- SCRIPTS -->
- <script type="application/javascript" src="../node_modules/jquery/dist/jquery.min.js"></script>
- <script type="application/javascript" src="../node_modules/d3/d3.min.js"></script>
- <script type="application/javascript" src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
- <script type="application/javascript" src="../node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
- <script type="application/javascript" src="../node_modules/react/dist/react.min.js"></script>
- <script type="application/javascript" src="../node_modules/react-dom/dist/react-dom.min.js"></script>
- <script type="application/javascript" src="js/ingest-summary.bundle.min.js"></script>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/flow/js/actions/InSumActions.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/actions/InSumActions.js b/spot-oa/ui/flow/js/actions/InSumActions.js
deleted file mode 100755
index 7b8f9df..0000000
--- a/spot-oa/ui/flow/js/actions/InSumActions.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var SpotDispatcher = require('../../../js/dispatchers/SpotDispatcher');
-var NetflowConstants = require('../constants/NetflowConstants');
-
-var InSumActions = {
- reloadSummary: function () {
- SpotDispatcher.dispatch({
- actionType: NetflowConstants.RELOAD_INGEST_SUMMARY
- });
- }
-};
-
-module.exports = InSumActions;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/flow/js/components/IngestSummaryPanel.react.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/components/IngestSummaryPanel.react.js b/spot-oa/ui/flow/js/components/IngestSummaryPanel.react.js
deleted file mode 100755
index 77af5dd..0000000
--- a/spot-oa/ui/flow/js/components/IngestSummaryPanel.react.js
+++ /dev/null
@@ -1,235 +0,0 @@
-const $ = require('jquery');
-const d3 = require('d3');
-const React = require('react');
-const ReactDOM = require('react-dom');
-
-var DateUtils = require('../../../js/utils/DateUtils');
-var InSumActions = require('../actions/InSumActions');
-var IngestSummaryStore = require('../stores/IngestSummaryStore');
-
-function initialDraw() {
- var rootNode, format, x, y, xAxis, yAxis, area, svg, rect, total, minDate, maxDate, maxFlows, numberFormat;
-
- rootNode = d3.select(ReactDOM.findDOMNode(this));
-
- // graph dimensions
- var m = [100, 50, 50, 80], // Margin
- w = $(rootNode.node()).width() - m[1] - m[3], // Width
- h = $(rootNode.node()).height() - m[0] - m[2]; // Height
-
- format = d3.time.format("%Y-%m-%d %H:%M");
-
- // Scales.
- x = d3.time.scale().range([0, w]); // get X function
- y = d3.scale.linear().range([h, 0]); // get Y function
- xAxis = d3.svg.axis().scale(x).orient("bottom"); // Get the X axis (Time)
- yAxis = d3.svg.axis().scale(y).orient("left"); // Get Y Axis (Netflows)
-
- // An area generator.
- area = d3.svg.area()
- .x(function (d) {
- return x(d.date);
- })
- .y0(h)
- .y1(function (d) {
- if (!isNaN(d.flows))
- return y(d.flows);
- else
- return y(0);
- });
-
- rootNode.select('svg').remove();
-
- // define the Main SVG
- svg = rootNode.select('#' + this.props.id + '-summary').append("svg")
- .attr("width", w + m[1] + m[3])
- .attr("height", h + m[0] + m[2])
- .append("g")
- .attr("transform", "translate(" + m[3] + "," + m[0] + ")")
-
- // Append the clipPath to avoid the Area overlapping
- svg.append("clipPath")
- .attr("id", "clip")
- .append("rect")
- .attr("x", x(0))
- .attr("y", y(1))
- .attr("width", x(1) - x(0))
- .attr("height", y(0) - y(1));
-
- // Append the Y Axis group
- svg.append("g")
- .attr("class", "y axis");
-
- // Append the X axis group
- svg.append("g")
- .attr("class", "x axis")
- .attr("transform", "translate(0," + h + ")");
-
- // Append a pane rect, which will help us to add the zoom functionality
- rect = svg.append("rect")
- .attr("class", "pane")
- .attr("width", w)
- .attr("height", h);
-
- this.state.data.forEach(function (dataSet)
- {
- var a;
-
- a = [{date: minDate}];
- a.push.apply(a, dataSet);
- minDate = d3.min(a, function (d) { return d.date; });
- a[0] = {date: maxDate, flows: maxFlows};
- maxDate = d3.max(a, function (d) { return d.date; });
- maxFlows = d3.max(a, function (d) { return d.flows; })
- });
-
- !minDate && (minDate = DateUtils.parseDate(IngestSummaryStore.getStartDate()));
- !maxDate && (maxDate = DateUtils.parseDate(IngestSummaryStore.getEndDate()));
-
- // bind the data to the X and Y generators
- x.domain([minDate, maxDate]);
- y.domain([0, maxFlows]);
-
- // Bind the data to our path element.
- svg.selectAll("path.area").data(this.state.data).enter().insert('path', 'g')
- .attr('class', 'area')
- .attr('clip-path', 'url(#clip)')
- .style('fill', '#0071c5')
- .attr('d', function (d) {
- return area(d);
- });
-
- //Add the pane rect the zoom behavior
- rect.call(d3.behavior.zoom().x(x)
- .scaleExtent([0.3, 2300]) // these are magic numbers to avoid the grap be zoomable in/out to the infinity
- .on("zoom", zoom.bind(this)));
-
- function draw () {
- var total, minDate, maxDate, numberFormat;
-
- svg.select("g.x.axis").call(xAxis);
- svg.select("g.y.axis").call(yAxis);
- svg.selectAll("path.area").attr("d", function (d) { return area(d); });
- numberFormat = d3.format(",d"); // number formatter (comma separated number i.e. 100,000,000)
-
- rootNode.select('#' + this.props.id + '-range').html("Seeing total flows <strong>from:</strong> " + x.domain().map(format).join(" <strong>to:</strong> "));
-
- //Calculate the total flows between the displayed date range
-
- total = 0;
- minDate = x.domain()[0];
- maxDate = x.domain()[1];
-
- // Go to the first millisecond on dates
- minDate.setSeconds(0);minDate.setMilliseconds(0);
- maxDate.setSeconds(59);maxDate.setMilliseconds(0);
-
- svg.selectAll("path.area").data().forEach(function (pathData)
- {
- pathData.forEach(function (record)
- {
- // Discard records outside displayed date range
- if (record.date >= minDate && record.date <= maxDate) {
- total += +record.flows;
- }
- });
- });
-
- rootNode.select('#' + this.props.id + '-total').html("<strong>Total netflows in range:</strong> " + numberFormat(total));
- }
-
- /*
- Zoom event handler
- */
- function zoom() {
- if (d3.event.sourceEvent.type == "wheel") {
- if (d3.event.sourceEvent.wheelDelta < 0)
- rect.style("cursor", "zoom-out");
- else
- rect.style("cursor", "zoom-in");
- }
- else if (d3.event.sourceEvent.type == "mousemove") {
- rect.style("cursor", "e-resize");
- }
-
- draw.call(this);
- }
-
- draw.call(this);
-}
-
-var IngestSummaryPanel = React.createClass({
- propTypes: {
- id: React.PropTypes.string
- },
- getDefaultProperties: function () {
- return {
- id: 'spot-is'
- };
- },
- getInitialState: function ()
- {
- return {loading: true};
- },
- render:function()
- {
- var content;
-
- if (this.state.error)
- {
- content = (
- <div className="text-center text-danger">
- {this.state.error}
- </div>
- );
- }
- else if (this.state.loading)
- {
- content = (
- <div className="spot-loader">
- Loading <span className="spinner"></span>
- </div>
- );
- }
- else
- {
- content = (
- <div id={this.props.id} className="text-center">
- <div id={this.props.id + '-header'}>
- <p id={this.props.id + '-range'}></p>
- <p id={this.props.id + '-total'}></p>
- <p id={this.props.id + '-istructions'} className="small">** Zoom in/out using mouse wheel or two fingers in track pad <br /> ** Move across the x-axis by clicking anywhere in the graph and dragging to left or right</p>
- </div>
- <div id={this.props.id + '-summary'}></div>
- </div>
- );
- }
-
- return (
- <div>{content}</div>
- )
- },
- componentDidMount: function()
- {
- IngestSummaryStore.addChangeDataListener(this._onChange);
- window.addEventListener('resize', this.buildGraph);
- },
- componentWillUnmount: function ()
- {
- IngestSummaryStore.removeChangeDataListener(this._onChange);
- window.removeEventListener('resize', this.buildGraph);
- },
- componentDidUpdate: function ()
- {
- if (!this.state.loading && !this.state.error && this.state.data)
- {
- this.buildGraph();
- }
- },
- buildGraph: initialDraw,
- _onChange: function () {
- this.replaceState(IngestSummaryStore.getData());
- }
-});
-
-module.exports = IngestSummaryPanel;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/flow/js/constants/NetflowConstants.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/constants/NetflowConstants.js b/spot-oa/ui/flow/js/constants/NetflowConstants.js
index cb7ffb2..3ee8099 100755
--- a/spot-oa/ui/flow/js/constants/NetflowConstants.js
+++ b/spot-oa/ui/flow/js/constants/NetflowConstants.js
@@ -1,19 +1,14 @@
var NetflowConstants = {
- // Netflow Actions
- RELOAD_INGEST_SUMMARY: 'RELOAD_INGEST_SUMMARY',
- // INGEST SUMMARY
- START_DATE: 'start-date',
- END_DATE: 'end-date',
// Data source URLS
API_SUSPICIOUS: '../../data/flow/${date}/flow_scores.csv',
API_DETAILS: '../../data/flow/${date}/edge-${src_ip}-${dst_ip}-${time}.tsv',
API_VISUAL_DETAILS: '../../data/flow/${date}/chord-${ip}.tsv',
API_COMMENTS: '../../data/flow/${date}/threats.csv',
API_INCIDENT_PROGRESSION: '../../data/flow/${date}/threat-dendro-${ip}.json',
- API_INGEST_SUMMARY: '../../data/flow/ingest_summary/is_${year}${month}.csv',
+ API_INGEST_SUMMARY: '../data/flow/ingest_summary/is_${year}${month}.csv',
API_IMPACT_ANALYSIS: '../../data/flow/${date}/stats-${ip}.json',
API_GLOBE_VIEW: '../../data/flow/${date}/globe-${ip}.json',
- API_TIMELINE: '../../data/flow/${date}/sbdet-${ip}.tsv',
+ API_TIMELINE: '../../data/flow/${date}/sbdet-${ip}.tsv'
};
module.exports = NetflowConstants;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/flow/js/ingest-summary.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/ingest-summary.js b/spot-oa/ui/flow/js/ingest-summary.js
deleted file mode 100755
index 1bf71b7..0000000
--- a/spot-oa/ui/flow/js/ingest-summary.js
+++ /dev/null
@@ -1,94 +0,0 @@
-const React = require('react');
-const ReactDOM = require('react-dom');
-
-const SpotActions = require('../../js/actions/SpotActions');
-const InSumActions = require('./actions/InSumActions');
-const NetflowConstants = require('./constants/NetflowConstants');
-const SpotUtils = require('../../js/utils/SpotUtils');
-const DateUtils = require('../../js/utils/DateUtils');
-
-// Build and Render Toolbar
-const DateInput = require('../../js/components/DateInput.react');
-
-// Find out period
-var startDate, endDate, today;
-
-today = new Date();
-startDate = SpotUtils.getUrlParam(NetflowConstants.START_DATE);
-endDate = SpotUtils.getUrlParam(NetflowConstants.END_DATE);
-
-if (!startDate && endDate)
-{
- startDate = DateUtils.formatDate(DateUtils.calcDate(DateUtils.parseDate(endDate), -7));
-}
-else if (startDate && !endDate)
-{
- endDate = DateUtils.formatDate(DateUtils.calcDate(DateUtils.parseDate(startDate), 7));
-}
-else if (!startDate && !endDate)
-{
- // Default endDate to today and startDate to 7 days before
- startDate = DateUtils.formatDate(DateUtils.calcDate(today, -7));
- endDate = DateUtils.formatDate(today);
-}
-
-// We got values for both dates, make use endDate is after startDate
-if (endDate < startDate)
-{
- // Use today var to switch dates
- today = startDate;
- startDate = endDate;
- endDate = today;
-}
-
-ReactDOM.render(
- (
- <form className="form-inline">
- <div className="form-group">
- <label htmlFor="startDatePicker">Period:</label>
- <div className="input-group input-group-xs">
- <div className="input-group-addon">
- <span className="glyphicon glyphicon-calendar" aria-hidden="true"></span>
- </div>
- <DateInput id="startDatePicker" name={NetflowConstants.START_DATE} value={startDate}/>
- </div>
- </div>
- <div className="form-group">
- <label htmlFor="endDatePicker"> - </label>
- <div className="input-group input-group-xs">
- <DateInput id="endDatePicker" name={NetflowConstants.END_DATE} value={endDate} />
- <div className="input-group-btn">
- <button className="btn btn-default" type="button" title="Reload" onClick={InSumActions.reloadSummary}>
- <span className="glyphicon glyphicon-repeat" aria-hidden="true"></span>
- </button>
- </div>
- </div>
- </div>
- </form>
- ),
- document.getElementById('nav_form')
-);
-
-// Build and Render Edge Investigation's panels
-const PanelRow = require('../../js/components/PanelRow.react');
-const Panel = require('../../js/components/Panel.react');
-//
-const IngestSummaryPanel = require('./components/IngestSummaryPanel.react');
-
-ReactDOM.render(
- <div id="spot-content">
- <PanelRow maximized>
- <Panel title="Ingest Summary" container header={false} className="col-md-12">
- <IngestSummaryPanel id="spot-is" />
- </Panel>
- </PanelRow>
- </div>,
- document.getElementById('spot-content-wrapper')
-);
-
-// Set period
-SpotActions.setDate(startDate, NetflowConstants.START_DATE);
-SpotActions.setDate(endDate, NetflowConstants.END_DATE);
-
-// Load data
-InSumActions.reloadSummary();
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/stores/IngestSummaryStore.js b/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
index 9e4ccb5..55f2106 100755
--- a/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
+++ b/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
@@ -1,20 +1,20 @@
-var assign = require('object-assign');
-var d3 = require('d3');
+const assign = require('object-assign');
+const d3 = require('d3');
-var SpotDispatcher = require('../../../js/dispatchers/SpotDispatcher');
-var SpotConstants = require('../../../js/constants/SpotConstants');
-var NetflowConstants = require('../constants/NetflowConstants');
-var DateUtils = require('../../../js/utils/DateUtils');
-var RestStore = require('../../../js/stores/RestStore');
+const SpotDispatcher = require('../../../js/dispatchers/SpotDispatcher');
+const SpotConstants = require('../../../js/constants/SpotConstants');
+const NetflowConstants = require('../constants/NetflowConstants');
+const DateUtils = require('../../../js/utils/DateUtils');
+const RestStore = require('../../../js/stores/RestStore');
-var START_DATE_FILTER = NetflowConstants.START_DATE;
-var END_DATE_FILTER = NetflowConstants.END_DATE;
-var CURRENT_DATE_FILTER = 'current_date';
+const START_DATE_FILTER = SpotConstants.START_DATE;
+const END_DATE_FILTER = SpotConstants.END_DATE;
+const CURRENT_DATE_FILTER = 'current_date';
-var requestQueue = [];
-var requestErrors = [];
+const requestQueue = [];
+const requestErrors = [];
-var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMARY), {
+const IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMARY), {
errorMessages: {
404: 'No details available'
},
@@ -128,7 +128,7 @@ var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMAR
this._data.loading = requestQueue.length > 0;
if (!this._data.loading) {
- if (this._data.data.length==0) {
+ if (this._data.data && this._data.data.length==0) {
// Broadcast first found error
this._data = requestErrors[0];
}
@@ -144,15 +144,15 @@ SpotDispatcher.register(function (action) {
switch (action.actionType) {
case SpotConstants.UPDATE_DATE:
switch (action.name) {
- case NetflowConstants.START_DATE:
+ case SpotConstants.START_DATE:
IngestSummaryStore.setStartDate(action.date);
break;
- case NetflowConstants.END_DATE:
+ case SpotConstants.END_DATE:
IngestSummaryStore.setEndDate(action.date);
break;
}
break;
- case NetflowConstants.RELOAD_INGEST_SUMMARY:
+ case SpotConstants.RELOAD_INGEST_SUMMARY:
IngestSummaryStore.requestSummary();
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/flow/package.json
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/package.json b/spot-oa/ui/flow/package.json
index dcf4171..62f47ae 100755
--- a/spot-oa/ui/flow/package.json
+++ b/spot-oa/ui/flow/package.json
@@ -6,12 +6,10 @@
"watch-suspicious": "watchify js/suspicious.js -o js/suspicious.bundle.min.js -v -d",
"watch-threat-investigation": "watchify js/threat-investigation.js -o js/threat-investigation.bundle.min.js -v -d",
"watch-storyboard": "watchify js/storyboard.js -o js/storyboard.bundle.min.js -v -d",
- "watch-ingest-summary": "watchify js/ingest-summary.js -o js/ingest-summary.bundle.min.js -v -d",
- "build-all": "npm run build-suspicious && npm run build-threat-investigation && npm run build-ingest-summary && npm run build-storyboard",
+ "build-all": "npm run build-suspicious && npm run build-threat-investigation && npm run build-storyboard",
"build-suspicious": "browserify js/suspicious.js | uglifyjs -cm > js/suspicious.bundle.min.js",
"build-threat-investigation": "browserify js/threat-investigation.js | uglifyjs -cm > js/threat-investigation.bundle.min.js",
- "build-storyboard": "browserify js/storyboard.js | uglifyjs -cm > js/storyboard.bundle.min.js",
- "build-ingest-summary": "browserify js/ingest-summary.js | uglifyjs -cm > js/ingest-summary.bundle.min.js"
+ "build-storyboard": "browserify js/storyboard.js | uglifyjs -cm > js/storyboard.bundle.min.js"
},
"browserify": {
"transform": [
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/ingest-summary.html
----------------------------------------------------------------------
diff --git a/spot-oa/ui/ingest-summary.html b/spot-oa/ui/ingest-summary.html
new file mode 100755
index 0000000..e694609
--- /dev/null
+++ b/spot-oa/ui/ingest-summary.html
@@ -0,0 +1,155 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Netflow :: Ingest Summary</title>
+
+ <meta charset="UTF-8">
+
+ <!--Bootstrap styles-->
+ <link rel="stylesheet" type="text/css" href="css/bootstrap-spot.min.css" />
+ <!--Bootstrap Date picker styles-->
+ <link rel="stylesheet" type="text/css" href="node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css" />
+ <!-- Spot styles -->
+ <link rel="stylesheet" type="text/css" href="css/main.css" />
+ <!-- Favicon -->
+ <link rel="apple-touch-icon" sizes="57x57" href="images/favicon/apple-icon-57x57.png">
+ <link rel="apple-touch-icon" sizes="60x60" href="images/favicon/apple-icon-60x60.png"
+ <link rel="apple-touch-icon" sizes="72x72" href="images/favicon/apple-icon-72x72.png">
+ <link rel="apple-touch-icon" sizes="76x76" href="images/favicon/apple-icon-76x76.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="images/favicon/apple-icon-114x114.png">
+ <link rel="apple-touch-icon" sizes="120x120" href="images/favicon/apple-icon-120x120.png">
+ <link rel="apple-touch-icon" sizes="144x144" href="images/favicon/apple-icon-144x144.png">
+ <link rel="apple-touch-icon" sizes="152x152" href="images/favicon/apple-icon-152x152.png">
+ <link rel="apple-touch-icon" sizes="180x180" href="images/favicon/apple-icon-180x180.png">
+ <link rel="icon" type="image/png" sizes="192x192" href="images/favicon/android-icon-192x192.png">
+ <link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
+ <link rel="icon" type="image/png" sizes="96x96" href="images/favicon/favicon-96x96.png">
+ <link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
+ <link rel="manifest" href="images/favicon/manifest.json">
+ <meta name="msapplication-TileColor" content="#ffffff">
+ <meta name="msapplication-TileImage" content="images/favicon/ms-icon-144x144.png">
+ <meta name="theme-color" content="#ffffff">
+ <style type="text/css">
+ .spot-row {
+ height: 100%;
+ }
+
+ #spot-is-header {
+ width: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 2;
+ height: auto;
+ }
+
+ #spot-is, #spot-is-summary {
+ height: 100%;
+ }
+
+ .axis {
+ shape-rendering: crispEdges;
+ }
+
+ .axis path, .axis line {
+ fill: none;
+ }
+
+ rect.pane {
+ cursor: e-resize;
+ fill: none;
+ pointer-events: all;
+ }
+ </style>
+</head>
+<body>
+ <nav id="spot-nav" class="navbar navbar-default">
+ <div class="container-fluid">
+ <!-- App name and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <span class="navbar-brand">Apache Spot :: Netflow :: Ingest Summary</span>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="main-menu">
+ <ul class="nav navbar-nav navbar-right">
+ <li class="dropdown">
+ <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
+ Flows
+ <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu" aria-labelledby="flowsMenu">
+ <li>
+ <a data-href="flow/suspicious.html#date=${end-date}">Suspicious</a>
+ </li>
+ <li>
+ <a data-href="flow/threat-investigation.html#date=${end-date}">Threat Investigation</a>
+ </li>
+ <li>
+ <a data-href="flow/storyboard.html#date=${end-date}">Storyboard</a>
+ </li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
+ DNS
+ <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu" aria-labelledby="dnsMenu">
+ <li>
+ <a data-href="dns/suspicious.html#date=${end-date}">Suspicious</a>
+ </li>
+ <li>
+ <a data-href="dns/threat-investigation.html#date=${end-date}">Threat Investigation</a>
+ </li>
+ <li>
+ <a data-href="dns/storyboard.html#date=${end-date}">Storyboard</a>
+ </li>
+ </ul>
+ </li>
+ <li class="dropdown">
+ <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
+ Proxy
+ <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu" aria-labelledby="proxyMenu">
+ <li>
+ <a data-href="proxy/suspicious.html#date=${end-date}">Suspicious</a>
+ </li>
+ <li>
+ <a data-href="proxy/threat-investigation.html#date=${end-date}">Threat Investigation</a>
+ </li>
+ <li>
+ <a data-href="proxy/storyboard.html#date=${end-date}">Storyboard</a>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+ <div id="search-box" class="row text-right">
+ <!--Tools Buttons-->
+ <div id="nav_form" class="col-md-12">
+ <!-- Search form placeholder -->
+ </div>
+ </div> <!-- /Tools Buttons-->
+ </div>
+ </nav>
+ <div id="spot-content-wrapper" class="container-fluid">
+ <!-- Main Content Placeholder -->
+ </div>
+
+ <!-- SCRIPTS -->
+ <script type="application/javascript" src="node_modules/jquery/dist/jquery.min.js"></script>
+ <script type="application/javascript" src="node_modules/d3/d3.min.js"></script>
+ <script type="application/javascript" src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
+ <script type="application/javascript" src="node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
+ <script type="application/javascript" src="node_modules/react/dist/react.min.js"></script>
+ <script type="application/javascript" src="node_modules/react-dom/dist/react-dom.min.js"></script>
+ <script type="application/javascript" src="js/ingest-summary.bundle.min.js"></script>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/js/actions/InSumActions.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/actions/InSumActions.js b/spot-oa/ui/js/actions/InSumActions.js
new file mode 100755
index 0000000..ea15715
--- /dev/null
+++ b/spot-oa/ui/js/actions/InSumActions.js
@@ -0,0 +1,12 @@
+const SpotDispatcher = require('../dispatchers/SpotDispatcher');
+const SpotConstants = require('../constants/SpotConstants');
+
+const InSumActions = {
+ reloadSummary: function () {
+ SpotDispatcher.dispatch({
+ actionType: SpotConstants.RELOAD_INGEST_SUMMARY
+ });
+ }
+};
+
+module.exports = InSumActions;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/js/components/IngestSummaryPanel.react.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/components/IngestSummaryPanel.react.js b/spot-oa/ui/js/components/IngestSummaryPanel.react.js
new file mode 100755
index 0000000..cc951ad
--- /dev/null
+++ b/spot-oa/ui/js/components/IngestSummaryPanel.react.js
@@ -0,0 +1,236 @@
+const $ = require('jquery');
+const d3 = require('d3');
+const React = require('react');
+const ReactDOM = require('react-dom');
+
+const DateUtils = require('../utils/DateUtils');
+const InSumActions = require('../actions/InSumActions');
+
+const NetflowIngestSummaryStore = require('../../flow/js/stores/IngestSummaryStore');
+
+function initialDraw() {
+ var rootNode, format, x, y, xAxis, yAxis, area, svg, rect, total, minDate, maxDate, maxFlows, numberFormat;
+
+ rootNode = d3.select(ReactDOM.findDOMNode(this));
+
+ // graph dimensions
+ var m = [100, 50, 50, 80], // Margin
+ w = $(rootNode.node()).width() - m[1] - m[3], // Width
+ h = $(rootNode.node()).height() - m[0] - m[2]; // Height
+
+ format = d3.time.format("%Y-%m-%d %H:%M");
+
+ // Scales.
+ x = d3.time.scale().range([0, w]); // get X function
+ y = d3.scale.linear().range([h, 0]); // get Y function
+ xAxis = d3.svg.axis().scale(x).orient("bottom"); // Get the X axis (Time)
+ yAxis = d3.svg.axis().scale(y).orient("left"); // Get Y Axis (Netflows)
+
+ // An area generator.
+ area = d3.svg.area()
+ .x(function (d) {
+ return x(d.date);
+ })
+ .y0(h)
+ .y1(function (d) {
+ if (!isNaN(d.total))
+ return y(d.total);
+ else
+ return y(0);
+ });
+
+ rootNode.select('svg').remove();
+
+ // define the Main SVG
+ svg = rootNode.select('#' + this.props.id + '-summary').append("svg")
+ .attr("width", w + m[1] + m[3])
+ .attr("height", h + m[0] + m[2])
+ .append("g")
+ .attr("transform", "translate(" + m[3] + "," + m[0] + ")")
+
+ // Append the clipPath to avoid the Area overlapping
+ svg.append("clipPath")
+ .attr("id", "clip")
+ .append("rect")
+ .attr("x", x(0))
+ .attr("y", y(1))
+ .attr("width", x(1) - x(0))
+ .attr("height", y(0) - y(1));
+
+ // Append the Y Axis group
+ svg.append("g")
+ .attr("class", "y axis");
+
+ // Append the X axis group
+ svg.append("g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + h + ")");
+
+ // Append a pane rect, which will help us to add the zoom functionality
+ rect = svg.append("rect")
+ .attr("class", "pane")
+ .attr("width", w)
+ .attr("height", h);
+
+ this.state.data.forEach(function (dataSet)
+ {
+ var a;
+
+ a = [{date: minDate}];
+ a.push.apply(a, dataSet);
+ minDate = d3.min(a, function (d) { return d.date; });
+ a[0] = {date: maxDate, flows: maxFlows};
+ maxDate = d3.max(a, function (d) { return d.date; });
+ maxFlows = d3.max(a, function (d) { return d.total; })
+ });
+
+ !minDate && (minDate = DateUtils.parseDate(NetflowIngestSummaryStore.getStartDate()));
+ !maxDate && (maxDate = DateUtils.parseDate(NetflowIngestSummaryStore.getEndDate()));
+
+ // bind the data to the X and Y generators
+ x.domain([minDate, maxDate]);
+ y.domain([0, maxFlows]);
+
+ // Bind the data to our path element.
+ svg.selectAll("path.area").data(this.state.data).enter().insert('path', 'g')
+ .attr('class', 'area')
+ .attr('clip-path', 'url(#clip)')
+ .style('fill', '#0071c5')
+ .attr('d', function (d) {
+ return area(d);
+ });
+
+ //Add the pane rect the zoom behavior
+ rect.call(d3.behavior.zoom().x(x)
+ .scaleExtent([0.3, 2300]) // these are magic numbers to avoid the grap be zoomable in/out to the infinity
+ .on("zoom", zoom.bind(this)));
+
+ function draw () {
+ var total, minDate, maxDate, numberFormat;
+
+ svg.select("g.x.axis").call(xAxis);
+ svg.select("g.y.axis").call(yAxis);
+ svg.selectAll("path.area").attr("d", function (d) { return area(d); });
+ numberFormat = d3.format(",d"); // number formatter (comma separated number i.e. 100,000,000)
+
+ rootNode.select('#' + this.props.id + '-range').html("Seeing total flows <strong>from:</strong> " + x.domain().map(format).join(" <strong>to:</strong> "));
+
+ //Calculate the total flows between the displayed date range
+
+ total = 0;
+ minDate = x.domain()[0];
+ maxDate = x.domain()[1];
+
+ // Go to the first millisecond on dates
+ minDate.setSeconds(0);minDate.setMilliseconds(0);
+ maxDate.setSeconds(59);maxDate.setMilliseconds(0);
+
+ svg.selectAll("path.area").data().forEach(function (pathData)
+ {
+ pathData.forEach(function (record)
+ {
+ // Discard records outside displayed date range
+ if (record.date >= minDate && record.date <= maxDate) {
+ total += +record.total;
+ }
+ });
+ });
+
+ rootNode.select('#' + this.props.id + '-total').html("<strong>Total netflows in range:</strong> " + numberFormat(total));
+ }
+
+ /*
+ Zoom event handler
+ */
+ function zoom() {
+ if (d3.event.sourceEvent.type == "wheel") {
+ if (d3.event.sourceEvent.wheelDelta < 0)
+ rect.style("cursor", "zoom-out");
+ else
+ rect.style("cursor", "zoom-in");
+ }
+ else if (d3.event.sourceEvent.type == "mousemove") {
+ rect.style("cursor", "e-resize");
+ }
+
+ draw.call(this);
+ }
+
+ draw.call(this);
+}
+
+var IngestSummaryPanel = React.createClass({
+ propTypes: {
+ id: React.PropTypes.string
+ },
+ getDefaultProperties: function () {
+ return {
+ id: 'spot-is'
+ };
+ },
+ getInitialState: function ()
+ {
+ return {loading: true};
+ },
+ render:function()
+ {
+ var content;
+
+ if (this.state.error)
+ {
+ content = (
+ <div className="text-center text-danger">
+ {this.state.error}
+ </div>
+ );
+ }
+ else if (this.state.loading)
+ {
+ content = (
+ <div className="spot-loader">
+ Loading <span className="spinner"></span>
+ </div>
+ );
+ }
+ else
+ {
+ content = (
+ <div id={this.props.id} className="text-center">
+ <div id={this.props.id + '-header'}>
+ <p id={this.props.id + '-range'}></p>
+ <p id={this.props.id + '-total'}></p>
+ <p id={this.props.id + '-istructions'} className="small">** Zoom in/out using mouse wheel or two fingers in track pad <br /> ** Move across the x-axis by clicking anywhere in the graph and dragging to left or right</p>
+ </div>
+ <div id={this.props.id + '-summary'}></div>
+ </div>
+ );
+ }
+
+ return (
+ <div>{content}</div>
+ )
+ },
+ componentDidMount: function()
+ {
+ NetflowIngestSummaryStore.addChangeDataListener(this._onChange);
+ window.addEventListener('resize', this.buildGraph);
+ },
+ componentWillUnmount: function ()
+ {
+ NetflowIngestSummaryStore.removeChangeDataListener(this._onChange);
+ window.removeEventListener('resize', this.buildGraph);
+ },
+ componentDidUpdate: function ()
+ {
+ if (!this.state.loading && !this.state.error && this.state.data)
+ {
+ this.buildGraph();
+ }
+ },
+ buildGraph: initialDraw,
+ _onChange: function () {
+ this.replaceState(NetflowIngestSummaryStore.getData());
+ }
+});
+
+module.exports = IngestSummaryPanel;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/js/constants/SpotConstants.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/constants/SpotConstants.js b/spot-oa/ui/js/constants/SpotConstants.js
index 03471c4..35e23c4 100755
--- a/spot-oa/ui/js/constants/SpotConstants.js
+++ b/spot-oa/ui/js/constants/SpotConstants.js
@@ -30,6 +30,11 @@ var SpotConstants = {
// Storyboard
RELOAD_COMMENTS: 'RELOAD_COMMENTS',
SELECT_COMMENT: 'SELECT_COMMENT',
+ // INGEST SUMMARY
+ START_DATE: 'start-date',
+ END_DATE: 'end-date',
+ // Ingest summary Actions
+ RELOAD_INGEST_SUMMARY: 'RELOAD_INGEST_SUMMARY',
// Server Paths
NOTEBOOKS_PATH: '/notebooks/ipynb'
};
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/js/ingest-summary.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/ingest-summary.js b/spot-oa/ui/js/ingest-summary.js
new file mode 100755
index 0000000..c42ed41
--- /dev/null
+++ b/spot-oa/ui/js/ingest-summary.js
@@ -0,0 +1,94 @@
+const React = require('react');
+const ReactDOM = require('react-dom');
+
+const SpotActions = require('./actions/SpotActions');
+const InSumActions = require('./actions/InSumActions');
+const SpotConstants = require('./constants/SpotConstants');
+const SpotUtils = require('./utils/SpotUtils');
+const DateUtils = require('./utils/DateUtils');
+
+// Build and Render Toolbar
+const DateInput = require('./components/DateInput.react');
+
+// Find out period
+var startDate, endDate, today;
+
+today = new Date();
+startDate = SpotUtils.getUrlParam(SpotConstants.START_DATE);
+endDate = SpotUtils.getUrlParam(SpotConstants.END_DATE);
+
+if (!startDate && endDate)
+{
+ startDate = DateUtils.formatDate(DateUtils.calcDate(DateUtils.parseDate(endDate), -7));
+}
+else if (startDate && !endDate)
+{
+ endDate = DateUtils.formatDate(DateUtils.calcDate(DateUtils.parseDate(startDate), 7));
+}
+else if (!startDate && !endDate)
+{
+ // Default endDate to today and startDate to 7 days before
+ startDate = DateUtils.formatDate(DateUtils.calcDate(today, -7));
+ endDate = DateUtils.formatDate(today);
+}
+
+// We got values for both dates, make use endDate is after startDate
+if (endDate < startDate)
+{
+ // Use today var to switch dates
+ today = startDate;
+ startDate = endDate;
+ endDate = today;
+}
+
+ReactDOM.render(
+ (
+ <form className="form-inline">
+ <div className="form-group">
+ <label htmlFor="startDatePicker">Period:</label>
+ <div className="input-group input-group-xs">
+ <div className="input-group-addon">
+ <span className="glyphicon glyphicon-calendar" aria-hidden="true"></span>
+ </div>
+ <DateInput id="startDatePicker" name={SpotConstants.START_DATE} value={startDate}/>
+ </div>
+ </div>
+ <div className="form-group">
+ <label htmlFor="endDatePicker"> - </label>
+ <div className="input-group input-group-xs">
+ <DateInput id="endDatePicker" name={SpotConstants.END_DATE} value={endDate} />
+ <div className="input-group-btn">
+ <button className="btn btn-default" type="button" title="Reload" onClick={InSumActions.reloadSummary}>
+ <span className="glyphicon glyphicon-repeat" aria-hidden="true"></span>
+ </button>
+ </div>
+ </div>
+ </div>
+ </form>
+ ),
+ document.getElementById('nav_form')
+);
+
+// Build and Render Edge Investigation's panels
+const PanelRow = require('./components/PanelRow.react');
+const Panel = require('./components/Panel.react');
+//
+const IngestSummaryPanel = require('./components/IngestSummaryPanel.react');
+
+ReactDOM.render(
+ <div id="spot-content">
+ <PanelRow maximized>
+ <Panel title="Ingest Summary" container header={false} className="col-md-12">
+ <IngestSummaryPanel id="spot-is" />
+ </Panel>
+ </PanelRow>
+ </div>,
+ document.getElementById('spot-content-wrapper')
+);
+
+// Set period
+SpotActions.setDate(startDate, SpotConstants.START_DATE);
+SpotActions.setDate(endDate, SpotConstants.END_DATE);
+
+// Load data
+InSumActions.reloadSummary();
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/js/stores/IngestSummaryStore.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/js/stores/IngestSummaryStore.js b/spot-oa/ui/js/stores/IngestSummaryStore.js
new file mode 100755
index 0000000..9e4ccb5
--- /dev/null
+++ b/spot-oa/ui/js/stores/IngestSummaryStore.js
@@ -0,0 +1,161 @@
+var assign = require('object-assign');
+var d3 = require('d3');
+
+var SpotDispatcher = require('../../../js/dispatchers/SpotDispatcher');
+var SpotConstants = require('../../../js/constants/SpotConstants');
+var NetflowConstants = require('../constants/NetflowConstants');
+var DateUtils = require('../../../js/utils/DateUtils');
+var RestStore = require('../../../js/stores/RestStore');
+
+var START_DATE_FILTER = NetflowConstants.START_DATE;
+var END_DATE_FILTER = NetflowConstants.END_DATE;
+var CURRENT_DATE_FILTER = 'current_date';
+
+var requestQueue = [];
+var requestErrors = [];
+
+var IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMARY), {
+ errorMessages: {
+ 404: 'No details available'
+ },
+ setStartDate: function (date) {
+ this.setRestFilter(START_DATE_FILTER, date);
+ },
+ getStartDate: function () {
+ return this.getRestFilter(START_DATE_FILTER);
+ },
+ setEndDate: function (date) {
+ this.setRestFilter(END_DATE_FILTER, date);
+ },
+ getEndDate: function () {
+ return this.getRestFilter(END_DATE_FILTER);
+ },
+ /**
+ * Start asking the server for CSV data to create the chart
+ **/
+ requestSummary: function () {
+ var startDate, endDate, date, delta, startRequests, i, month;
+
+ startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
+ endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
+
+ // Find out how many request need to be made
+ delta = (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
+
+ startRequests = requestQueue.length == 0;
+
+ // Go to first day in month
+ date = new Date(startDate);
+ date.setDate(1);
+
+ // Queue date requests
+ requestQueue.push(date);
+ for (i = 1; i <= delta; i++) {
+ requestQueue.push(DateUtils.calcDate(date, i, 'month'));
+ }
+
+ // dequeue is no request is running
+ startRequests && this.dequeue();
+ },
+ dequeue: function () {
+ var date, year, month;
+
+ if (requestQueue.length == 0) return;
+
+ date = requestQueue.shift();
+ this.setRestFilter(CURRENT_DATE_FILTER, date);
+ year = date.getFullYear();
+ month = date.getMonth() + 1 + "";
+ month = month.length == 1 ? "0" + month : month;
+
+ this.setEndpoint(NetflowConstants.API_INGEST_SUMMARY.replace('${year}', year).replace('${month}', month));
+
+ this.reload();
+ },
+ setData: function (data) {
+ var startDate, endDate, date, dayFilter, parse;
+
+ // Does the loading indicator needs to be displayed?
+ if (data.loading) {
+ if (!this._data.loading) {
+ this._data = data;
+ this.emitChangeData();
+ }
+
+ // Do nothing when loading is in progress
+ return;
+ }
+
+ // Store errors for later usage
+ if (data.error) {
+ requestErrors.push(data);
+ }
+ else if (data.data) {
+ parse = d3.time.format("%Y-%m-%d %H:%M").parse; // Date formatting parser
+ startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
+ endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
+ date = DateUtils.parseDate(this.getRestFilter(CURRENT_DATE_FILTER));
+
+ if (date.getFullYear() == startDate.getFullYear() && date.getMonth() == startDate.getMonth()) {
+ dayFilter = startDate.getDate();
+ data.data = data.data.filter(function (row) {
+ return DateUtils.parseDate(row.date, true).getDate() >= dayFilter
+ });
+ }
+
+ if (date.getFullYear() == endDate.getFullYear() && date.getMonth() == endDate.getMonth()) {
+ dayFilter = endDate.getDate();
+ data.data = data.data.filter(function (row) {
+ return DateUtils.parseDate(row.date, true).getDate() <= dayFilter
+ });
+ }
+
+ // Parse dates and numbers.
+ data.data.forEach(function (d) {
+ d.date = parse(d.date);
+ d.flows = +d.flows;
+ });
+
+ // Sort the data by date ASC
+ data.data.sort(function (a, b) {
+ return a.date - b.date;
+ });
+
+ if (!this._data.data) this._data.data = [];
+ this._data.data.push(data.data);
+ }
+
+ this._data.loading = requestQueue.length > 0;
+
+ if (!this._data.loading) {
+ if (this._data.data.length==0) {
+ // Broadcast first found error
+ this._data = requestErrors[0];
+ }
+ this.emitChangeData();
+ }
+ else {
+ setTimeout(this.dequeue.bind(this), 1);
+ }
+ }
+});
+
+SpotDispatcher.register(function (action) {
+ switch (action.actionType) {
+ case SpotConstants.UPDATE_DATE:
+ switch (action.name) {
+ case NetflowConstants.START_DATE:
+ IngestSummaryStore.setStartDate(action.date);
+ break;
+ case NetflowConstants.END_DATE:
+ IngestSummaryStore.setEndDate(action.date);
+ break;
+ }
+ break;
+ case NetflowConstants.RELOAD_INGEST_SUMMARY:
+ IngestSummaryStore.requestSummary();
+ break;
+ }
+});
+
+module.exports = IngestSummaryStore;
http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/86d15527/spot-oa/ui/package.json
----------------------------------------------------------------------
diff --git a/spot-oa/ui/package.json b/spot-oa/ui/package.json
index a07a106..9e76f09 100644
--- a/spot-oa/ui/package.json
+++ b/spot-oa/ui/package.json
@@ -37,10 +37,12 @@
"scripts": {
"test": "jest",
"postinstall": "npm run build-all",
- "build-all": "npm run build-flow && npm run build-dns && npm run build-proxy",
+ "watch-ingest-summary": "watchify js/ingest-summary.js -o js/ingest-summary.bundle.min.js -v -d",
+ "build-all": "npm run build-flow && npm run build-dns && npm run build-proxy && npm run build-ingest-summary",
"build-flow": "cd flow/ && npm run build-all && cd ../",
"build-dns": "cd dns/ && npm run build-all && cd ../",
- "build-proxy": "cd proxy/ && npm run build-all && cd ../"
+ "build-proxy": "cd proxy/ && npm run build-all && cd ../",
+ "build-ingest-summary": "browserify js/ingest-summary.js | uglifyjs -cm > js/ingest-summary.bundle.min.js"
},
"browserify": {
"transform": [