Fix cache. Fix appstate. Fix filters

This commit is contained in:
Pedro S 2016-12-04 08:34:04 -08:00
parent b8c1f97fe0
commit ad74b6294b
5 changed files with 37 additions and 36 deletions

View File

@ -2,6 +2,7 @@
var app = require('ui/modules').get('app/wazuh', []);
app.controller('testController', function ($scope, $http, testConnection, appState, $mdToast) {
app.controller('testController', function ($scope, $http, testConnection, appState, $mdToast, $rootScope) {
});

View File

@ -38,12 +38,7 @@ require('ui/modules').get('app/wazuh', []).controller('kibanaSearchBar', functio
$scope.timefilter.time.from = "now-24h";
let $state = $scope.$state = (function initState() {
if(getAppState())
$state = getAppState();
else
$state = new AppState();
$state = new AppState();
return $state;
} ());
@ -56,6 +51,7 @@ require('ui/modules').get('app/wazuh', []).controller('kibanaSearchBar', functio
// Watch visCounter, wait for finish and fetch.
var visCounterWatch = $rootScope.$watch('visCounter', function (data) {
if($rootScope.visCounter == 0){
$timeout(
function() {

View File

@ -38,6 +38,7 @@ var app = require('ui/modules').get('app/wazuh', [])
}
}]);
require('ui/modules').get('app/wazuh', []).controller('VisController', function ($scope, $route, timefilter, AppState, appState, $location, kbnUrl, $timeout, courier, Private, Promise, savedVisualizations, SavedVis, getAppState, $rootScope) {
@ -73,13 +74,9 @@ require('ui/modules').get('app/wazuh', []).controller('VisController', function
if($route.current.params._g == "()")
$scope.timefilter.time.from = "now-24h";
// Get or create App State
let $state = $scope.$state = (function initState() {
$state = new AppState();
// Get App State
let $state = getAppState();
return $state;
} ());
// Initialize queryFilter and searchSource
@ -87,15 +84,13 @@ require('ui/modules').get('app/wazuh', []).controller('VisController', function
$scope.searchSource = $scope.newVis.searchSource;
const brushEvent = Private(UtilsBrushEventProvider);
// Initialize visualization initial state
// Initialize time
$scope.timefilter = timefilter;
$timeout(
function() {
@ -118,16 +113,14 @@ require('ui/modules').get('app/wazuh', []).controller('VisController', function
$scope.vis.setState(visState);
$rootScope.visCounter--;
$scope.loadBeforeShow = true;
}, 0);
// Fetch visualization
$scope.fetch = function ()
{
$state.save();
if($scope.visIndexPattern == "ossec-*"){
$scope.searchSource.set('filter', $scope.queryFilter.getFilters());
@ -176,4 +169,4 @@ require('ui/modules').get('app/wazuh', []).controller('VisController', function
};
});
});

View File

@ -5,12 +5,13 @@
<md-content flex layout="row">
<md-card layout="column">
<md-card-content style="text-align: center;">
<kbn-vis-value vis-height="37px" vis-type="table" vis-index-pattern="ossec-*" vis-a="(filters:!(),linked:!f,query:(query_string:(analyze_wildcard:!t,query:'*')),uiState:(vis:(params:(sort:(columnIndex:!n,direction:!n)))),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count),(enabled:!t,id:'2',params:(field:AgentName,order:desc,orderBy:'1',size:1),schema:bucket,type:terms),(enabled:!t,id:'3',params:(customInterval:'2h',extended_bounds:(),field:'@timestamp',interval:auto,min_doc_count:1),schema:bucket,type:date_histogram)),listeners:(),params:(perPage:1,showMeticsAtAllLevels:!f,showPartialRows:!f,showTotal:!f,sort:(columnIndex:!n,direction:!n),totalFunc:sum),title:'New%20Visualization',type:table))"
vis-filter="*">
</kbn-vis-value>
<div class="ng-binding">Most changed file</div>
<md-card flex="100">
<md-card-content>
<span class="md-headline">Agents</span>
<kbn-vis vis-height="160px" vis-type="area" vis-index-pattern="ossec-*" vis-a="(filters:!(),linked:!f,query:(query_string:(analyze_wildcard:!t,query:'*')),uiState:(),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count),(enabled:!t,id:'2',params:(customInterval:'2h',extended_bounds:(),field:'@timestamp',interval:auto,min_doc_count:1),schema:segment,type:date_histogram),(enabled:!t,id:'3',params:(field:AgentName,order:desc,orderBy:'1',size:10),schema:group,type:terms)),listeners:(),params:(addLegend:!t,addTimeMarker:!f,addTooltip:!t,defaultYExtents:!f,interpolate:linear,legendPosition:right,mode:overlap,scale:linear,setYExtents:!f,shareYAxis:!t,smoothLines:!t,times:!(),yAxis:()),title:'VIS1',type:area))"
vis-filter="*"
>
</kbn-vis>
</md-card-content>
</md-card>
@ -21,17 +22,27 @@
<md-content flex layout="row">
<md-card layout="column">
<md-card-content style="text-align: center;">
<kbn-vis-value vis-height="37px" vis-type="table" vis-index-pattern="ossec-*" vis-a="(filters:!(),linked:!f,query:(query_string:(analyze_wildcard:!t,query:'*')),uiState:(vis:(params:(sort:(columnIndex:!n,direction:!n)))),vis:(aggs:!((enabled:!t,id:'1',params:(field:'@timestamp'),schema:metric,type:max),(enabled:!t,id:'2',params:(field:SyscheckFile.path,order:desc,orderBy:'1',size:1),schema:bucket,type:terms)),listeners:(),params:(perPage:1,showMeticsAtAllLevels:!f,showPartialRows:!f,showTotal:!f,sort:(columnIndex:!n,direction:!n),totalFunc:sum),title:'New%20Visualization',type:table))"
vis-filter="SyscheckFile.event: added AND location: syscheck">
</kbn-vis-value>
<div class="ng-binding">Most changed file</div>
<md-card flex="100">
<md-card-content>
<span class="md-headline">Agents</span>
<kbn-vis vis-height="160px" vis-type="area" vis-index-pattern="ossec-*" vis-a="(filters:!(),linked:!f,query:(query_string:(analyze_wildcard:!t,query:'*')),uiState:(),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count),(enabled:!t,id:'2',params:(customInterval:'2h',extended_bounds:(),field:'@timestamp',interval:auto,min_doc_count:1),schema:segment,type:date_histogram),(enabled:!t,id:'3',params:(field:rule.description,order:desc,orderBy:'1',size:10),schema:group,type:terms)),listeners:(),params:(addLegend:!t,addTimeMarker:!f,addTooltip:!t,defaultYExtents:!f,interpolate:linear,legendPosition:right,mode:overlap,scale:linear,setYExtents:!f,shareYAxis:!t,smoothLines:!t,times:!(),yAxis:()),title:'VIS2',type:area))"
vis-filter="*"
>
</kbn-vis>
</md-card-content>
</md-card>
</md-content>
<md-content flex layout="row">
<md-card layout="column" flex="45">
<md-card-content>
<span class="md-headline">Agents status</span>
<kbn-vis vis-height="160px" vis-type="line" vis-index-pattern="wazuh-monitoring-*" vis-a="(filters:!(),linked:!f,query:(query_string:(analyze_wildcard:!t,query:'*')),uiState:(),vis:(aggs:!((enabled:!t,id:'2',params:(customInterval:'2h',extended_bounds:(),field:'@timestamp',interval:'auto',min_doc_count:1),schema:segment,type:date_histogram),(enabled:!t,id:'3',params:(field:id),schema:metric,type:cardinality),(enabled:!t,id:'4',params:(field:status,order:asc,orderBy:'3',size:5),schema:group,type:terms)),listeners:(),params:(addLegend:!t,addTimeMarker:!f,addTooltip:!t,defaultYExtents:!f,drawLinesBetweenPoints:!t,interpolate:linear,radiusRatio:9,scale:linear,setYExtents:!f,shareYAxis:!t,showCircles:!t,smoothLines:!f,times:!(),yAxis:()),title:'VIS3',type:line))"
vis-filter="*">
</kbn-vis>
</md-card-content>
</md-card>
</md-content>
</div>

View File

@ -188,7 +188,7 @@ module.exports = function (server, options) {
server.log([blueWazuh, 'server', 'info'], '[Wazuh agents monitoring] Skipping "wazuh-monitoring-*" index pattern configuration: Already configured.');
}
});
cron.schedule('* */10 * * * *', function () {
cron.schedule('0 */10 * * * *', function () {
agentsArray.length = 0;
getConfig(loadCredentials);
}, true);