mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added query input binding
This commit is contained in:
parent
bf75a42b88
commit
e54982d42d
@ -30,7 +30,7 @@ var config = new Settings(
|
||||
timefield: '@timestamp',
|
||||
//indexpattern: '"logstash-"yyyy.mm.dd',
|
||||
indexpattern: '"shakespeare"',
|
||||
modules: ['histogram','map','pie','table'],
|
||||
modules: ['histogram','map','pie','table','stringquery'],
|
||||
|
||||
defaultfields: ['line_text'],
|
||||
perpage: 50,
|
||||
|
@ -2,6 +2,16 @@ var dashboards =
|
||||
{
|
||||
title: "Infinite Monkey Dashboard",
|
||||
rows: [
|
||||
{
|
||||
height: "30px",
|
||||
panels: [
|
||||
{
|
||||
type : "stringquery",
|
||||
span : 12,
|
||||
group : "mainsearch"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
height: "300px",
|
||||
panels: [
|
||||
@ -11,12 +21,8 @@ var dashboards =
|
||||
span : 6,
|
||||
show : ['lines','stack'],
|
||||
fill : 1,
|
||||
query : [
|
||||
{ label : "US", query : "country:US", color: '#86B32D' },
|
||||
{ label : "CN", query : "country:CN", color: '#BF3030' },
|
||||
{ label : "IN", query : "country:IN", color: '#1D7373' }
|
||||
],
|
||||
color : "#7BA4AF"
|
||||
query : [{ label : "lines", query : "*", color: '#86B32D' } ],
|
||||
group : "mainsearch"
|
||||
},
|
||||
{
|
||||
title : "World Monkeys",
|
||||
@ -25,7 +31,9 @@ var dashboards =
|
||||
field : "country",
|
||||
span : 6,
|
||||
size : 500,
|
||||
query : "*"
|
||||
query : "*",
|
||||
group : "mainsearch"
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -33,7 +41,7 @@ var dashboards =
|
||||
height: "300px",
|
||||
panels: [
|
||||
{
|
||||
title : "Hamlet vs Macbeth",
|
||||
title : "Plays",
|
||||
type : "pie",
|
||||
span : 4,
|
||||
size : 8,
|
||||
@ -41,17 +49,16 @@ var dashboards =
|
||||
colors : ['#BF3030','#1D7373','#86B32D','#A60000','#006363','#679B00'],
|
||||
field : 'country',
|
||||
//query : { query: "*", field: "country"}
|
||||
query : [
|
||||
{ label : "Hamlet", query : "play_name:Hamlet", color: '#86B32D' },
|
||||
{ label : "Macbeth", query : "play_name:macbeth", color: '#BF3030' },
|
||||
]
|
||||
query : { field : "play_name", query : "*" },
|
||||
group : "mainsearch"
|
||||
},
|
||||
{
|
||||
title : "Newest Lines",
|
||||
type : "table",
|
||||
span : 8,
|
||||
query : "*",
|
||||
fields : ['@timestamp','speaker','text_entry']
|
||||
fields : ['@timestamp','speaker','text_entry'],
|
||||
group : "mainsearch"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -14,6 +14,13 @@ angular.module('kibana.histogram', [])
|
||||
? _d[k] : $scope.panel[k];
|
||||
});
|
||||
|
||||
if (!(_.isUndefined($scope.panel.group))) {
|
||||
$scope.$on($scope.panel.group+"-query", function(event, query) {
|
||||
$scope.panel.query[0].query = query;
|
||||
$scope.get_data();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.get_data = function() {
|
||||
var request = $scope.ejs.Request().indices($scope.index);
|
||||
|
||||
|
@ -14,6 +14,14 @@ angular.module('kibana.map', [])
|
||||
? _d[k] : $scope.panel[k];
|
||||
});
|
||||
|
||||
|
||||
if (!(_.isUndefined($scope.panel.group))) {
|
||||
$scope.$on($scope.panel.group+"-query", function(event, query) {
|
||||
$scope.panel.query = query;
|
||||
$scope.get_data();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.get_data = function() {
|
||||
var request = $scope.ejs.Request().indices($scope.index);
|
||||
|
||||
|
@ -18,6 +18,13 @@ angular.module('kibana.pie', [])
|
||||
? _d[k] : $scope.panel[k];
|
||||
});
|
||||
|
||||
if (!(_.isUndefined($scope.panel.group)) && !(_.isArray($scope.panel.query))) {
|
||||
$scope.$on($scope.panel.group+"-query", function(event, query) {
|
||||
$scope.panel.query.query = query;
|
||||
$scope.get_data();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.get_data = function() {
|
||||
var request = $scope.ejs.Request().indices($scope.index);
|
||||
|
||||
|
7
panels/stringquery/module.html
Normal file
7
panels/stringquery/module.html
Normal file
@ -0,0 +1,7 @@
|
||||
<div ng-controller='stringquery'>
|
||||
<h4 ng-hide="_.isUndefined(panel.title)">{{panel.title}}</h4>
|
||||
<form class="form-search">
|
||||
<input type="text" class="input-medium search-query" ng-model="query" style="width:90%">
|
||||
<button type="submit" class="btn" ng-click="send_query(query)">Search</button>
|
||||
</form>
|
||||
</div>
|
20
panels/stringquery/module.js
Normal file
20
panels/stringquery/module.js
Normal file
@ -0,0 +1,20 @@
|
||||
angular.module('kibana.stringquery', [])
|
||||
.controller('stringquery', function($scope, $rootScope) {
|
||||
|
||||
// Set and populate defaults
|
||||
var _d = {
|
||||
query : "*",
|
||||
size : 100,
|
||||
sort : [config.timefield,'desc'],
|
||||
}
|
||||
_.each(_d, function(v, k) {
|
||||
$scope.panel[k] = _.isUndefined($scope.panel[k])
|
||||
? _d[k] : $scope.panel[k];
|
||||
});
|
||||
|
||||
if (!(_.isUndefined($scope.panel.group))) {
|
||||
$scope.send_query = function(query) {
|
||||
$rootScope.$broadcast($scope.panel.group+"-query", query)
|
||||
}
|
||||
}
|
||||
})
|
@ -12,6 +12,13 @@ angular.module('kibana.table', [])
|
||||
? _d[k] : $scope.panel[k];
|
||||
});
|
||||
|
||||
if (!(_.isUndefined($scope.panel.group))) {
|
||||
$scope.$on($scope.panel.group+"-query", function(event, query) {
|
||||
$scope.panel.query = query;
|
||||
$scope.get_data();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.get_data = function() {
|
||||
var request = $scope.ejs.Request().indices($scope.index);
|
||||
|
||||
@ -30,7 +37,6 @@ angular.module('kibana.table', [])
|
||||
|
||||
// Populate scope when we have results
|
||||
results.then(function(results) {
|
||||
console.log(results)
|
||||
$scope.hits = results.hits.total;
|
||||
$scope.data = results.hits.hits;
|
||||
/*
|
||||
@ -55,4 +61,4 @@ angular.module('kibana.table', [])
|
||||
$scope.get_data();
|
||||
});
|
||||
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user