mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added statistical modes to histogram panel
This commit is contained in:
parent
45c9bb8f38
commit
906f3a3ca8
@ -9,6 +9,7 @@ angular.module('kibana.controllers', [])
|
|||||||
title: "",
|
title: "",
|
||||||
editable: true,
|
editable: true,
|
||||||
rows: [],
|
rows: [],
|
||||||
|
last: null
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
@ -24,7 +25,8 @@ angular.module('kibana.controllers', [])
|
|||||||
|
|
||||||
// Load dashboard by event
|
// Load dashboard by event
|
||||||
eventBus.register($scope,'dashboard', function(event,dashboard){
|
eventBus.register($scope,'dashboard', function(event,dashboard){
|
||||||
$scope.dashboards = dashboard;
|
$scope.dashboards = dashboard.dashboard;
|
||||||
|
$scope.dashboards.last = dashboard.last;
|
||||||
_.defaults($scope.dashboards,_d)
|
_.defaults($scope.dashboards,_d)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -271,8 +271,10 @@ angular.module('kibana.dashcontrol', [])
|
|||||||
$scope.dash_load = function(dashboard) {
|
$scope.dash_load = function(dashboard) {
|
||||||
if(!_.isObject(dashboard))
|
if(!_.isObject(dashboard))
|
||||||
dashboard = JSON.parse(dashboard)
|
dashboard = JSON.parse(dashboard)
|
||||||
|
eventBus.broadcast($scope.$id,'ALL','dashboard',{
|
||||||
eventBus.broadcast($scope.$id,'ALL','dashboard',dashboard)
|
dashboard : dashboard,
|
||||||
|
last : $scope.dashboards
|
||||||
|
})
|
||||||
timer.cancel_all();
|
timer.cancel_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +289,6 @@ angular.module('kibana.dashcontrol', [])
|
|||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.directive('dashUpload', function(timer, eventBus){
|
.directive('dashUpload', function(timer, eventBus){
|
||||||
return {
|
return {
|
||||||
|
@ -40,6 +40,7 @@ angular.module('kibana.fields', [])
|
|||||||
eventBus.register($scope,'table_documents', function(event, docs) {
|
eventBus.register($scope,'table_documents', function(event, docs) {
|
||||||
$scope.panel.query = docs.query;
|
$scope.panel.query = docs.query;
|
||||||
$scope.docs = docs.docs;
|
$scope.docs = docs.docs;
|
||||||
|
$scope.index = docs.index;
|
||||||
});
|
});
|
||||||
eventBus.register($scope,"get_fields", function(event,id) {
|
eventBus.register($scope,"get_fields", function(event,id) {
|
||||||
eventBus.broadcast($scope.$id,$scope.panel.group,"selected_fields",$scope.active);
|
eventBus.broadcast($scope.$id,$scope.panel.group,"selected_fields",$scope.active);
|
||||||
|
@ -1,14 +1,29 @@
|
|||||||
<div>
|
<div>
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span3">
|
||||||
|
<label class="small">Mode</label>
|
||||||
|
<select ng-change="set_refresh(true)" class="input-small" ng-model="panel.mode" ng-options="f for f in ['count','min','mean','max','total']"></select>
|
||||||
|
</div>
|
||||||
|
<div class="span3">
|
||||||
|
<label class="small">Field</label>
|
||||||
|
<form>
|
||||||
|
<input ng-change="set_refresh(true)" placeholder="Start typing" bs-typeahead="fields.list" type="text" class="input-small" ng-model="panel.value_field">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="span5" ng-show="panel.mode != 'count'">
|
||||||
|
<label class="small">Note</label><small> In <strong>{{panel.mode}}</strong> mode the configured field <strong>must</strong> be a numeric type</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span3">
|
<div class="span3">
|
||||||
<form style="margin-bottom: 0px">
|
<form style="margin-bottom: 0px">
|
||||||
<h6>Label</h6>
|
<label class="small">Label</label>
|
||||||
<input type="text" placeholder="New Label" style="width:70%" ng-model="newlabel">
|
<input type="text" placeholder="New Label" style="width:70%" ng-model="newlabel">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="span8">
|
<div class="span8">
|
||||||
|
<label class="small">Query</label>
|
||||||
<form class="input-append" style="margin-bottom: 0px">
|
<form class="input-append" style="margin-bottom: 0px">
|
||||||
<h6>Query</h6>
|
|
||||||
<input type="text" placeholder="New Query" style="width:80%" ng-model="newquery">
|
<input type="text" placeholder="New Query" style="width:80%" ng-model="newquery">
|
||||||
<button class="btn" ng-click="add_query(newlabel,newquery);newlabel='';newquery=''"><i class="icon-plus"></i></button>
|
<button class="btn" ng-click="add_query(newlabel,newquery);newlabel='';newquery=''"><i class="icon-plus"></i></button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<div style="display:inline-block;background:{{series.color}};height:10px;width:10px;border-radius:5px;"></div>
|
<div style="display:inline-block;background:{{series.color}};height:10px;width:10px;border-radius:5px;"></div>
|
||||||
<div class='small' style='display:inline-block'>{{series.label}} ({{series.hits}})</div>
|
<div class='small' style='display:inline-block'>{{series.label}} ({{series.hits}})</div>
|
||||||
</span>
|
</span>
|
||||||
<span ng-show="panel.legend" class="small"> per <strong>{{panel.interval}}</strong> | (<strong>{{hits}}</strong> total)</span>
|
<span ng-show="panel.legend" class="small"><span ng-show="panel.value_field && panel.mode != 'count'">{{panel.value_field}}</span> {{panel.mode}} per <strong>{{panel.interval}}</strong> | (<strong>{{hits}}</strong> hits)</span>
|
||||||
</div>
|
</div>
|
||||||
<center><img ng-show='panel.loading && _.isUndefined(data)' src="common/img/load_big.gif"></center>
|
<center><img ng-show='panel.loading && _.isUndefined(data)' src="common/img/load_big.gif"></center>
|
||||||
<div histogram-chart params="{{panel}}" style="height:{{panel.height || row.height}};position:relative"></div>
|
<div histogram-chart params="{{panel}}" style="height:{{panel.height || row.height}};position:relative"></div>
|
||||||
|
@ -45,6 +45,8 @@ angular.module('kibana.histogram', [])
|
|||||||
var _d = {
|
var _d = {
|
||||||
group : "default",
|
group : "default",
|
||||||
query : [ {query: "*", label:"Query"} ],
|
query : [ {query: "*", label:"Query"} ],
|
||||||
|
mode : 'count',
|
||||||
|
value_field: null,
|
||||||
auto_int : true,
|
auto_int : true,
|
||||||
interval : '5m',
|
interval : '5m',
|
||||||
fill : 3,
|
fill : 3,
|
||||||
@ -124,12 +126,20 @@ angular.module('kibana.histogram', [])
|
|||||||
|
|
||||||
// Build the facet part, injecting the query in as a facet filter
|
// Build the facet part, injecting the query in as a facet filter
|
||||||
_.each(queries, function(v) {
|
_.each(queries, function(v) {
|
||||||
request = request
|
|
||||||
.facet($scope.ejs.DateHistogramFacet("chart"+_.indexOf(queries,v))
|
var facet = $scope.ejs.DateHistogramFacet("chart"+_.indexOf(queries,v))
|
||||||
.field($scope.time.field)
|
|
||||||
.interval($scope.panel.interval)
|
if($scope.panel.mode === 'count') {
|
||||||
.facetFilter($scope.ejs.QueryFilter(v))
|
facet = facet.field($scope.time.field)
|
||||||
).size(0)
|
} else {
|
||||||
|
if(_.isNull($scope.panel.value_field)) {
|
||||||
|
$scope.panel.error = "In " + $scope.panel.mode + " mode a field must be specified";
|
||||||
|
return
|
||||||
|
}
|
||||||
|
facet = facet.keyField($scope.time.field).valueField($scope.panel.value_field)
|
||||||
|
}
|
||||||
|
facet = facet.interval($scope.panel.interval).facetFilter($scope.ejs.QueryFilter(v))
|
||||||
|
request = request.facet(facet).size(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Populate the inspector panel
|
// Populate the inspector panel
|
||||||
@ -171,14 +181,12 @@ angular.module('kibana.histogram', [])
|
|||||||
// Assemble segments
|
// Assemble segments
|
||||||
var segment_data = [];
|
var segment_data = [];
|
||||||
_.each(v.entries, function(v, k) {
|
_.each(v.entries, function(v, k) {
|
||||||
segment_data.push([v['time'],v['count']])
|
segment_data.push([v['time'],v[$scope.panel.mode]])
|
||||||
hits += v['count']; // The series level hits counter
|
hits += v['count']; // The series level hits counter
|
||||||
$scope.hits += v['count']; // Entire dataset level hits counter
|
$scope.hits += v['count']; // Entire dataset level hits counter
|
||||||
});
|
});
|
||||||
|
|
||||||
data.splice.apply(data,[1,0].concat(segment_data)) // Join histogram data
|
data.splice.apply(data,[1,0].concat(segment_data)) // Join histogram data
|
||||||
|
|
||||||
|
|
||||||
// Create the flot series object
|
// Create the flot series object
|
||||||
var series = {
|
var series = {
|
||||||
data: {
|
data: {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span2">
|
<div class="span2">
|
||||||
<label class="small">Mulit-query</label><input type="checkbox" ng-change="set_multi(panel.multi) "ng-model="panel.multi" ng-checked="panel.multi">
|
<label class="small">Multi-query</label><input type="checkbox" ng-change="set_multi(panel.multi) "ng-model="panel.multi" ng-checked="panel.multi">
|
||||||
</div>
|
</div>
|
||||||
<div class="span3" ng-show="panel.multi">
|
<div class="span3" ng-show="panel.multi">
|
||||||
<label class="small">Arrangement</label>
|
<label class="small">Arrangement</label>
|
||||||
|
@ -70,10 +70,10 @@ angular.module('kibana.table', [])
|
|||||||
eventBus.register($scope,'selected_fields', function(event, fields) {
|
eventBus.register($scope,'selected_fields', function(event, fields) {
|
||||||
$scope.panel.fields = _.clone(fields)
|
$scope.panel.fields = _.clone(fields)
|
||||||
});
|
});
|
||||||
eventBus.register($scope,'table_documents', function(event, docs) {
|
eventBus.register($scope,'table_documents', function(event, docs) {
|
||||||
$scope.panel.query = docs.query;
|
$scope.panel.query = docs.query;
|
||||||
$scope.data = docs.docs;
|
$scope.data = docs.docs;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.set_sort = function(field) {
|
$scope.set_sort = function(field) {
|
||||||
@ -220,7 +220,11 @@ angular.module('kibana.table', [])
|
|||||||
active: $scope.panel.fields
|
active: $scope.panel.fields
|
||||||
});
|
});
|
||||||
eventBus.broadcast($scope.$id,$scope.panel.group,"table_documents",
|
eventBus.broadcast($scope.$id,$scope.panel.group,"table_documents",
|
||||||
{query:$scope.panel.query,docs:$scope.data});
|
{
|
||||||
|
query: $scope.panel.query,
|
||||||
|
docs : $scope.data,
|
||||||
|
index: $scope.index
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_time(time) {
|
function set_time(time) {
|
||||||
|
Loading…
Reference in New Issue
Block a user