You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2016/02/15 14:28:20 UTC
[37/51] [partial] karaf-decanter git commit: KARAF-3624 - Add Kibana
4.x static feature and support
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/map/module.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/map/module.html b/kibana-3.x/src/main/resources/app/panels/map/module.html
new file mode 100644
index 0000000..4b177a9
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/map/module.html
@@ -0,0 +1,63 @@
+<div ng-controller='map' ng-init="init()">
+ <style>
+ .jvectormap-label {
+ position: absolute;
+ display: none;
+ visibility: hidden;
+ border: solid 1px #CDCDCD;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ background: #292929;
+ color: white;
+ font-family: sans-serif, Verdana;
+ font-size: smaller;
+ padding: 3px;
+ }
+
+ .jvectormap-zoomin, .jvectormap-zoomout {
+ position: absolute;
+ left: 10px;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ background: #292929;
+ padding: 3px;
+ color: white;
+ width: 10px;
+ height: 10px;
+ cursor: pointer;
+ line-height: 10px;
+ text-align: center;
+ }
+
+ .jvectormap {
+ position: relative;
+ }
+
+ .jvectormap-zoomin {
+ display: none;
+ top: 10px;
+ }
+
+ .jvectormap-zoomout {
+ display: none;
+ top: 30px;
+ }
+
+ .map-legend {
+ color : #c8c8c8;
+ padding : 10px;
+ font-size: 11pt;
+ font-weight: 200;
+ background-color: #1f1f1f;
+ border-radius: 5px;
+ position: absolute;
+ left: 0px;
+ top: 15px;
+ display: none;
+ z-index: 99;
+ }
+ </style>
+ <div class="jvectormap" map params="{{panel}}" ng-style="{height:panel.height||row.height}"></div>
+</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/map/module.js
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/map/module.js b/kibana-3.x/src/main/resources/app/panels/map/module.js
new file mode 100644
index 0000000..c512479
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/map/module.js
@@ -0,0 +1,263 @@
+/** @scratch /panels/5
+ *
+ * include::panels/map.asciidoc[]
+ */
+
+/** @scratch /panels/map/0
+ *
+ * == Map
+ * Status: *Stable*
+ *
+ * The map panel translates 2 letter country or state codes into shaded regions on a map. Currently
+ * available maps are world, usa and europe.
+ *
+ */
+define([
+ 'angular',
+ 'app',
+ 'lodash',
+ 'jquery',
+ 'config',
+ './lib/jquery.jvectormap.min'
+],
+function (angular, app, _, $) {
+ 'use strict';
+
+ var module = angular.module('kibana.panels.map', []);
+ app.useModule(module);
+
+ module.controller('map', function($scope, $rootScope, querySrv, dashboard, filterSrv) {
+ $scope.panelMeta = {
+ editorTabs : [
+ {title:'Queries', src:'app/partials/querySelect.html'}
+ ],
+ modals : [
+ {
+ description: "Inspect",
+ icon: "icon-info-sign",
+ partial: "app/partials/inspector.html",
+ show: $scope.panel.spyable
+ }
+ ],
+ status : "Stable",
+ description : "Displays a map of shaded regions using a field containing a 2 letter country "+
+ ", or US state, code. Regions with more hit are shaded darker. Node that this does use the"+
+ " Elasticsearch terms facet, so it is important that you set it to the correct field."
+ };
+
+ // Set and populate defaults
+ var _d = {
+ /** @scratch /panels/map/3
+ *
+ * === Parameters
+ *
+ * map:: Map to display. world, usa, europe
+ */
+ map : "world",
+ /** @scratch /panels/map/3
+ * colors:: An array of colors to use to shade the map. If 2 colors are specified, shades
+ * between them will be used. For example [`#A0E2E2', `#265656']
+ */
+ colors : ['#A0E2E2', '#265656'],
+ /** @scratch /panels/map/3
+ * size:: Max number of regions to shade
+ */
+ size : 100,
+ /** @scratch /panels/map/3
+ * exclude:: exclude this array of regions. For example [`US',`BR',`IN']
+ */
+ exclude : [],
+ /** @scratch /panels/map/3
+ * spyable:: Setting spyable to false disables the inspect icon.
+ */
+ spyable : true,
+ /** @scratch /panels/map/5
+ *
+ * ==== Queries
+ * queries object:: This object describes the queries to use on this panel.
+ * queries.mode::: Of the queries available, which to use. Options: +all, pinned, unpinned, selected+
+ * queries.ids::: In +selected+ mode, which query ids are selected.
+ */
+ queries : {
+ mode : 'all',
+ ids : []
+ },
+ /** @scratch /panels/map/3
+ * tmode:: Facet mode: terms or terms_stats
+ */
+ tmode : 'terms',
+ /** @scratch /panels/map/3
+ * tstat:: Terms_stats facet stats field
+ */
+ tstat : 'total',
+ /** @scratch /panels/map/3
+ * valuefield:: Terms_stats facet value field
+ */
+ valuefield : ''
+ };
+ _.defaults($scope.panel,_d);
+
+ $scope.init = function() {
+ $scope.$on('refresh',function() {
+ $scope.get_data();
+ });
+ $scope.get_data();
+ };
+
+ $scope.get_data = function() {
+
+ // Make sure we have everything for the request to complete
+ if(dashboard.indices.length === 0) {
+ return;
+ }
+ $scope.panelMeta.loading = true;
+
+
+ var request,
+ boolQuery,
+ queries;
+
+ $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
+ request = $scope.ejs.Request();
+ queries = querySrv.getQueryObjs($scope.panel.queries.ids);
+
+ boolQuery = $scope.ejs.BoolQuery();
+ _.each(queries,function(q) {
+ boolQuery = boolQuery.should(querySrv.toEjsObj(q));
+ });
+
+ // Then the insert into facet and make the request
+ // Terms mode
+ if($scope.panel.tmode === 'terms') {
+ request = request
+ .facet($scope.ejs.TermsFacet('map')
+ .field($scope.panel.field)
+ .size($scope.panel.size)
+ .exclude($scope.panel.exclude)
+ .facetFilter($scope.ejs.QueryFilter(
+ $scope.ejs.FilteredQuery(
+ boolQuery,
+ filterSrv.getBoolFilter(filterSrv.ids())
+ )))).size(0);
+ }
+ if($scope.panel.tmode === 'terms_stats') {
+ request = request
+ .facet($scope.ejs.TermStatsFacet('map')
+ .valueField($scope.panel.valuefield)
+ .keyField($scope.panel.field)
+ .size($scope.panel.size)
+ .facetFilter($scope.ejs.QueryFilter(
+ $scope.ejs.FilteredQuery(
+ boolQuery,
+ filterSrv.getBoolFilter(filterSrv.ids())
+ )))).size(0);
+ }
+
+
+ $scope.populate_modal(request);
+
+ var results = $scope.ejs.doSearch(dashboard.indices, request);
+
+ // Populate scope when we have results
+ results.then(function(results) {
+ $scope.panelMeta.loading = false;
+ $scope.hits = results.hits.total;
+ $scope.data = {};
+ _.each(results.facets.map.terms, function(v) {
+ if($scope.panel.tmode === 'terms') {
+ //slice = { label : v.term, data : [[k,v.count]], actions: true};
+ $scope.data[v.term.toUpperCase()] = v.count;
+ }
+ if($scope.panel.tmode === 'terms_stats') {
+ $scope.data[v.term.toUpperCase()] = v[$scope.panel.tstat];
+
+ //slice = { label : v.term, data : [[k,v[scope.panel.tstat]]], actions: true};
+ }
+ //$scope.data[v.term.toUpperCase()] = v.total;
+ });
+ $scope.$emit('render');
+ });
+ };
+
+ // I really don't like this function, too much dom manip. Break out into directive?
+ $scope.populate_modal = function(request) {
+ $scope.inspector = request.toJSON();
+ };
+
+ $scope.build_search = function(field, value) {
+ filterSrv.set({type:'field', field:field, query:value, mandate:"must"});
+ };
+
+ $scope.set_refresh = function (state) {
+ $scope.refresh = state;
+ };
+
+ $scope.close_edit = function() {
+ if($scope.refresh) {
+ $scope.get_data();
+ }
+ $scope.refresh = false;
+ $scope.$emit('render');
+ };
+ });
+
+
+ module.directive('map', function() {
+ return {
+ restrict: 'A',
+ link: function(scope, elem) {
+
+ elem.html('<center><img src="img/load_big.gif"></center>');
+
+ // Receive render events
+ scope.$on('render',function(){
+ slow();
+ });
+
+ elem.closest('.panel').resize(function () {
+ elem.empty();
+ });
+
+ function render_panel() {
+ elem.empty();
+ elem.css({height:scope.panel.height||scope.row.height});
+ $('.jvectormap-zoomin,.jvectormap-zoomout,.jvectormap-label').remove();
+ require(['./panels/map/lib/map.'+scope.panel.map], function () {
+ elem.vectorMap({
+ map: scope.panel.map,
+ regionStyle: {initial: {fill: '#8c8c8c'}},
+ zoomOnScroll: false,
+ backgroundColor: null,
+ series: {
+ regions: [{
+ values: scope.data,
+ scale: scope.panel.colors,
+ normalizeFunction: 'polynomial'
+ }]
+ },
+ onRegionLabelShow: function(event, label, code){
+ elem.children('.map-legend').show();
+ var count = _.isUndefined(scope.data[code]) ? 0 : scope.data[code];
+ elem.children('.map-legend').text(label.text() + ": " + count);
+ },
+ onRegionOut: function() {
+ elem.children('.map-legend').hide();
+ },
+ onRegionClick: function(event, code) {
+ var count = _.isUndefined(scope.data[code]) ? 0 : scope.data[code];
+ if (count !== 0) {
+ scope.build_search(scope.panel.field,code);
+ }
+ }
+ });
+ elem.prepend('<span class="map-legend"></span>');
+
+ elem.children('.map-legend').hide();
+ });
+ }
+
+ var slow = _.debounce(render_panel, 200);
+ }
+ };
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/editor.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/editor.html b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/editor.html
new file mode 100644
index 0000000..098423d
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/editor.html
@@ -0,0 +1,104 @@
+<style>
+ .querySelect .query {
+ margin-right: 5px;
+ }
+ .querySelect .selected {
+ border: 3px solid;
+ }
+ .querySelect .unselected {
+ border: 0px solid;
+ }
+</style>
+<div class="editor-row row-fluid">
+ <div class="section span12">
+ <h5>Values</h5>
+ <table class="table table-condensed table-striped">
+ <thead>
+ <tr>
+ <th></th>
+ <th>Chart value</th>
+ <th>Transform Series</th>
+ <th>Queries</th>
+ <th ng-show="panel.values.length > 1">Delete</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat="value in panel.values">
+ <td>
+ <label class="small"> </label>
+ <i class="icon-circle pointer" data-unique="1" bs-popover="'app/panels/multifieldhistogram/meta.html'" data-placement="right" ng-style="{color: value.color}"></i></td>
+ <td>
+ <div class="editor-option">
+ <label class="small">Mode</label>
+ <select ng-change="set_refresh(true)" class="input-small" ng-model="value.mode" ng-options="f for f in ['count','min','mean','max','total']"></select>
+ </div>
+ <div class="editor-option" ng-show="value.mode != 'count'">
+ <label class="small">Value Field <tip>This field must contain a numeric value</tip></label>
+ <input ng-change="set_refresh(true)" placeholder="Start typing" bs-typeahead="fields.list" type="text" class="input-medium" ng-model="value.value_field">
+ </div>
+ </td>
+ <td>
+ <div class="editor-option" ng-show="value.mode != 'count'">
+ <label class="small">Scale</label>
+ <input type="text" class="input-mini" ng-model="value.scale">
+ </div>
+ <div class="editor-option">
+ <label class="small">Seconds <tip>Normalize intervals to per-second</tip></label>
+ <input type="checkbox" ng-model="value.scaleSeconds" ng-checked="value.scaleSeconds">
+ </div>
+ <div class="editor-option">
+ <label class="small">Derivative <tip>Plot the change per interval in the series</tip></label>
+ <input type="checkbox" ng-model="value.derivative" ng-checked="value.derivative" ng-change="set_refresh(true)">
+ </div>
+ <div class="editor-option">
+ <label class="small">Zero fill <tip>Fills zeros in gaps.</tip></label>
+ <input type="checkbox" ng-model="value.zerofill" ng-checked="value.zerofill" ng-change="set_refresh(true)">
+ </div>
+ <div class="editor-option">
+ <label class="small">Yaxis Position<tip>default "left"</tip></label>
+ <select ng-model="value.yaxisposition" class='input-small' ng-options="f for f in ['left','right']" ng-change="set_refresh(true)"></select>
+ </div>
+ </td>
+ <td>
+ <div class="editor-option querySelect">
+ <label class="small">Selected Queries</label>
+ <span ng-style="{'border-color': querySrv.list()[id].color}" ng-class="{selected:_.contains(value.queries,id),unselected:!_.contains(value.queries,id)}" ng-repeat="id in querySrv.ids()" ng-click="value.queries = _.toggleInOut(value.queries,id);set_refresh(true);" class="query pointer badge">
+ <i class="icon-circle" ng-style="{color: querySrv.list()[id].color}"></i>
+ <span> {{querySrv.list()[id].alias || querySrv.list()[id].query}}</span>
+ </span>
+ </div>
+ </td>
+ <td ng-show="panel.values.length > 1">
+ <label class="small"> </label>
+ <i ng-click="panel.values = _.without(panel.values, value);set_refresh(true)" class="pointer icon-remove"></i>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <button type="button" class="btn btn-success" ng-click="add_new_value(panel);set_refresh(true)"><i class="icon-plus-sign"></i> Add value</button>
+ </div>
+</div>
+<div class="editor-row">
+ <div class="section">
+ <h5>Time Options</h5>
+ <div class="editor-option">
+ <label class="small">Time Field</label>
+ <input ng-change="set_refresh(true)" placeholder="Start typing" bs-typeahead="fields.list" type="text" class="input-small" ng-model="panel.time_field">
+ </div>
+ <div class="editor-option">
+ <label class="small">Time correction</label>
+ <select ng-model="panel.timezone" class='input-small' ng-options="f for f in ['browser','utc']"></select>
+ </div>
+ <div class="editor-option">
+ <label class="small">Auto-interval</label><input type="checkbox" ng-model="panel.auto_int" ng-checked="panel.auto_int" />
+ </div>
+ <div class="editor-option" ng-show='panel.auto_int'>
+ <label class="small">Resolution <tip>Shoot for this many data points, rounding to sane intervals</tip></label>
+ <input type="number" class='input-mini' ng-model="panel.resolution" ng-change='set_refresh(true)'/>
+ </div>
+ <div class="editor-option" ng-hide='panel.auto_int'>
+ <label class="small">Interval <tip>Use Elasticsearch date math format (eg 1m, 5m, 1d, 2w, 1y)</tip></label>
+ <input type="text" class='input-mini' ng-model="panel.interval" ng-change='set_refresh(true)'/>
+ </div>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/interval.js
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/interval.js b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/interval.js
new file mode 100644
index 0000000..ed5ae01
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/interval.js
@@ -0,0 +1,57 @@
+define([
+ 'kbn'
+],
+function (kbn) {
+ 'use strict';
+
+ /**
+ * manages the interval logic
+ * @param {[type]} interval_string An interval string in the format '1m', '1y', etc
+ */
+ function Interval(interval_string) {
+ this.string = interval_string;
+
+ var info = kbn.describe_interval(interval_string);
+ this.type = info.type;
+ this.ms = Math.ceil(info.sec * 1000 * info.count);
+
+ // does the length of the interval change based on the current time?
+ if (this.type === 'y' || this.type === 'M') {
+ // we will just modify this time object rather that create a new one constantly
+ this.get = this.get_complex;
+ this.date = new Date(0);
+ } else {
+ this.get = this.get_simple;
+ }
+ }
+
+ Interval.prototype = {
+ toString: function () {
+ return this.string;
+ },
+ after: function(current_ms) {
+ return this.get(current_ms, 1);
+ },
+ before: function (current_ms) {
+ return this.get(current_ms, -1);
+ },
+ get_complex: function (current, delta) {
+ this.date.setTime(current);
+ switch(this.type) {
+ case 'M':
+ this.date.setUTCMonth(this.date.getUTCMonth() + delta);
+ break;
+ case 'y':
+ this.date.setUTCFullYear(this.date.getUTCFullYear() + delta);
+ break;
+ }
+ return this.date.getTime();
+ },
+ get_simple: function (current, delta) {
+ return current + (delta * this.ms);
+ }
+ };
+
+ return Interval;
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/markersEditor.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/markersEditor.html b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/markersEditor.html
new file mode 100644
index 0000000..18ff027
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/markersEditor.html
@@ -0,0 +1,39 @@
+<div class="editor-row">
+ <h4>Markers</h4>
+ <div class="small">
+ Here you can specify a query to be plotted on your chart as a marker. Hovering over a marker will display the field you specify below. If more documents are found than the limit you set, they will be scored by Elasticsearch and events that best match your query will be displayed.
+ </div>
+ <style>
+ .querySelect .query {
+ margin-right: 5px;
+ }
+ .querySelect .selected {
+ border: 3px solid;
+ }
+ .querySelect .unselected {
+ border: 0px solid;
+ }
+ </style>
+ <p>
+ <div class="editor-option">
+ <label class="small">Enable</label>
+ <input type="checkbox" ng-change="set_refresh(true)" ng-model="panel.annotate.enable" ng-checked="panel.annotate.enable">
+ </div>
+ <div class="editor-option" ng-show="panel.annotate.enable">
+ <label class="small">Marker Query</label>
+ <input type="text" ng-change="set_refresh(true)" class="input-large" ng-model="panel.annotate.query"/>
+ </div>
+ <div class="editor-option" ng-show="panel.annotate.enable">
+ <label class="small">Tooltip field</label>
+ <input type="text" class="input-small" ng-model="panel.annotate.field" bs-typeahead="fields.list"/>
+ </div>
+ <div class="editor-option" ng-show="panel.annotate.enable">
+ <label class="small">Limit <tip>Max markers on the chart</tip></label>
+ <input type="number" class="input-mini" ng-model="panel.annotate.size" ng-change="set_refresh(true)"/>
+ </div>
+ <div class="editor-option" ng-show="panel.annotate.enable">
+ <label class="small">Sort <tip>Determine the most relevant markers using this field</tip></label>
+ <input type="text" class="input-small" bs-typeahead="fields.list" ng-model="panel.annotate.sort[0]" ng-change="set_refresh(true)" />
+ <i ng-click="panel.annotate.sort[1] = _.toggle(panel.annotate.sort[1],'desc','asc');set_refresh(true)" ng-class="{'icon-chevron-up': panel.annotate.sort[1] == 'asc','icon-chevron-down': panel.annotate.sort[1] == 'desc'}"></i>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/meta.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/meta.html b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/meta.html
new file mode 100644
index 0000000..72583d0
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/meta.html
@@ -0,0 +1,22 @@
+<div class="panel-query-meta row-fluid" style="width:260px">
+ <style>
+ .panel-query-meta fieldset label {
+ margin-top: 3px;
+ }
+ </style>
+
+ <fieldset>
+ <label class="small">Legend value</label>
+ <input class="input-medium input-value-alias" type="text" ng-model="value.alias" placeholder='Alias...' ng-change="set_refresh(true);" />
+ </fieldset>
+
+ <hr class="small" />
+ <div>
+ <i ng-repeat="color in querySrv.colors" class="pointer" ng-class="{'icon-circle-blank':value.color == color,'icon-circle':value.color != color}" ng-style="{color:color}" ng-click="value.color = color;set_refresh(true);"> </i>
+ </div>
+
+ <div class="pull-right">
+ <a class="btn btn-mini btn-value-remove-color" ng-click="value.color = null;set_refresh(true);" ng-show="value.color" class="pointer">Remove color</a>
+ <input class="btn btn-mini" ng-click="set_refresh(true);dismiss();" type="submit"/ value="Close">
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.html b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.html
new file mode 100644
index 0000000..ab48267
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.html
@@ -0,0 +1,108 @@
+<div ng-controller='multifieldhistogram' ng-init="init()" style="min-height:{{panel.height || row.height}}">
+ <style>
+ .histogram-legend {
+ display:inline-block;
+ padding-right:5px
+ }
+ .histogram-legend-dot {
+ display:inline-block;
+ height:10px;
+ width:10px;
+ border-radius:5px;
+ }
+ .histogram-legend-item {
+ display:inline-block;
+ }
+ .histogram-chart {
+ position:relative;
+ }
+ .histogram-options {
+ padding: 5px;
+ margin-right: 15px;
+ margin-bottom: 0px;
+ }
+ .histogram-options label {
+ margin: 0px 0px 0px 10px !important;
+ }
+ .histogram-options span {
+ white-space: nowrap;
+ }
+
+ /* this is actually should be in bootstrap */
+ .form-inline .checkbox {
+ display: inline-block;
+ }
+
+ .histogram-marker {
+ display: block;
+ width: 20px;
+ height: 21px;
+ background-image: url('img/annotation-icon.png');
+ background-repeat: no-repeat;
+ }
+
+ </style>
+ <div>
+ <span ng-show='panel.options'>
+ <a class="link small" ng-show='panel.options' ng-click="options=!options">
+ View <i ng-show="!options" class="icon-caret-right"></i><i ng-show="options" class="icon-caret-down"></i>
+ </a> | 
+ </span>
+ <span ng-show='panel.zoomlinks'>
+ <!--<a class='small' ng-click='zoom(0.5)'><i class='icon-zoom-in'></i> Zoom In</a>-->
+ <a class='small' ng-click='zoom(2)'><i class='icon-zoom-out'></i> Zoom Out</a> | 
+ </span>
+ <span ng-show="panel.legend" ng-repeat='series in _.values(legend)' class="histogram-legend">
+ <i class='icon-circle' ng-style="{color: series.query.color}"></i>
+ <span class='small histogram-legend-item'>
+ <span ng-if="panel.show_query">{{series.query.alias || series.query.query}}</span>
+ <span ng-if="!panel.show_query">{{series.query.alias}}</span>
+ <span ng-show="panel.legend_counts"> ({{series.hits}})</span>
+ </span>
+ </span>
+ <span ng-show="panel.legend" class="small"><span ng-show="panel.derivative"> change in </span><span class="strong" ng-show="panel.value_field && panel.mode != 'count'">{{panel.value_field}}</span> {{panel.mode}} per <strong ng-hide="panel.scaleSeconds">{{panel.interval}}</strong><strong ng-show="panel.scaleSeconds">1s</strong> | (<strong>{{hits}}</strong> hits)</span>
+ </div>
+ <form class="form-inline bordered histogram-options" ng-show="options">
+ <span>
+ <div class="checkbox">
+ <label class="small">
+ <input type="checkbox" ng-model="panel.lines" ng-checked="panel.lines" ng-change="render()">
+ Lines
+ </label>
+ </div>
+ <div class="checkbox">
+ <label class="small">
+ <input type="checkbox" ng-model="panel.points" ng-checked="panel.points" ng-change="render()">
+ Points
+ </label>
+ </div>
+ <div class="checkbox">
+ <label class="small">
+ <input type="checkbox" ng-model="panel.stack" ng-checked="panel.stack" ng-change="render()">
+ Stack
+ </label>
+ </div>
+ </span>
+ <span ng-show="panel.stack">
+ <div class="checkbox">
+ <label style="white-space:nowrap" class="small">
+ <input type="checkbox" ng-model="panel.percentage" ng-checked="panel.percentage" ng-change="render()">
+ Percent
+ </label>
+ </div>
+ </span>
+ <span>
+ <div class="checkbox">
+ <label class="small">
+ <input type="checkbox" ng-model="panel.legend" ng-checked="panel.legend" ng-change="render()">
+ Legend
+ </label>
+ </div>
+ </span>
+ <span>
+ <label class="small">Interval</label> <select ng-change="set_interval(panel.interval);get_data();" class="input-small" ng-model="panel.interval" ng-options="interval_label(time) for time in _.union([panel.interval],panel.intervals)"></select>
+ </span>
+ </form>
+ <center><img ng-show='panel.loading' src="img/load_big.gif"></center>
+ <div multifieldhistogram-chart class="pointer histogram-chart" params="{{panel}}"></div>
+</div>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.js
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.js b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.js
new file mode 100644
index 0000000..8bb67c4
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/module.js
@@ -0,0 +1,844 @@
+/** @scratch /panels/5
+ *
+ * include::panels/multifieldhistogram.asciidoc[]
+ */
+
+/** @scratch /panels/multifieldhistogram/0
+ *
+ * == multifieldhistogram
+ * Status: *Stable*
+ *
+ * The multifieldhistogram panel allow for the display of time charts. It includes several modes and tranformations
+ * to display event counts, mean, min, max and total of numeric fields, and derivatives of counter
+ * fields, just like the histogram panel. It provides a bit more flexibility than the histogram by allowing
+ * to use different fields.
+ *
+ */
+define([
+ 'angular',
+ 'app',
+ 'jquery',
+ 'lodash',
+ 'kbn',
+ 'moment',
+ './timeSeries',
+ 'numeral',
+ 'jquery.flot',
+ 'jquery.flot.events',
+ 'jquery.flot.selection',
+ 'jquery.flot.time',
+ 'jquery.flot.byte',
+ 'jquery.flot.stack',
+ 'jquery.flot.stackpercent'
+],
+function (angular, app, $, _, kbn, moment, timeSeries, numeral) {
+
+ 'use strict';
+
+ var module = angular.module('kibana.panels.multifieldhistogram', []);
+ app.useModule(module);
+
+ module.controller('multifieldhistogram', function($scope, querySrv, dashboard, filterSrv) {
+ $scope.panelMeta = {
+ modals : [
+ {
+ description: "Inspect",
+ icon: "icon-info-sign",
+ partial: "app/partials/inspector.html",
+ show: $scope.panel.spyable
+ }
+ ],
+ editorTabs : [
+ {
+ title:'Style',
+ src:'app/panels/multifieldhistogram/styleEditor.html'
+ },
+ {
+ title:'Markers',
+ src:'app/panels/multifieldhistogram/markersEditor.html'
+ },
+ ],
+ status : "Stable",
+ description : "A bucketed time series chart of the current query or queries. Uses the "+
+ "Elasticsearch date_histogram facet. If using time stamped indices this panel will query"+
+ " them sequentially to attempt to apply the lighest possible load to your Elasticsearch cluster"
+ };
+
+ // Set and populate defaults
+ $scope.defaultValue = {
+ /** m ode:: Value to use for the y-axis. For all modes other than count, +value_field+ must be
+ * defined. Possible values: count, mean, max, min, total.
+ */
+ mode : 'count',
+ /** @scratch /panels/multifieldhistogram/3
+ * value_field:: y-axis field if +mode+ is set to mean, max, min or total. Must be numeric.
+ */
+ value_field : null,
+ /** @scratch /panels/multifieldhistogram/3
+ * scale:: Scale the y-axis by this factor
+ */
+ scale : 1,
+ /** @scratch /panels/multifieldhistogram/3
+ * zerofill:: Improves the accuracy of line charts at a small performance cost.
+ */
+ zerofill : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * derivative:: Show each point on the x-axis as the change from the previous point
+ */
+ yaxisposition : 'left',
+ /** @scratch /panels/multifieldhistogram/3
+ * yaxispostion:: Show y-axis at which position.
+ */
+ derivative : false,
+ /** @scratch /panels/multifieldhistogram/5
+ * queries array:: which query ids are selected.
+ */
+ queries : [],
+ color : null,
+ alias : null
+ };
+
+ var _d = {
+ /** @scra tch /panels/multifieldhistogram/3
+ *
+ * === Parameters
+ * ==== Axis options
+ *
+ */
+ /** @scratch /panels/multifieldhistogram/3
+ * values:: array of values.
+ */
+ values : [angular.copy($scope.defaultValue)],
+ /** @scratch /panels/multifieldhistogram/3
+ * time_field:: x-axis field. This must be defined as a date type in Elasticsearch.
+ */
+ time_field : '@timestamp',
+ /** @scratch /panels/multifieldhistogram/3
+ * x-axis:: Show the x-axis
+ */
+ 'x-axis' : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * y-axis:: Show the y-axis
+ */
+ 'y-axis' : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * y_format:: 'none','bytes','short '
+ */
+ y_format : 'none',
+ /** @scratch /panels/multifieldhistogram/5
+ * grid object:: Min and max y-axis values
+ * grid.min::: Minimum y-axis value
+ * grid.max::: Maximum y-axis value
+ */
+ grid : {
+ max: null,
+ min: 0
+ },
+ /** @scratch /panels/multifieldhistogram/3
+ *
+ * ==== Annotations
+ * annotate object:: A query can be specified, the results of which will be displayed as markers on
+ * the chart. For example, for noting code deploys.
+ * annotate.enable::: Should annotations, aka markers, be shown?
+ * annotate.query::: Lucene query_string syntax query to use for markers.
+ * annotate.size::: Max number of markers to show
+ * annotate.field::: Field from documents to show
+ * annotate.sort::: Sort array in format [field,order], For example [`@timestamp',`desc']
+ */
+ annotate : {
+ enable : false,
+ query : "*",
+ size : 20,
+ field : '_type',
+ sort : ['_score','desc']
+ },
+ /** @scratch /panels/multifieldhistogram/3
+ * ==== Interval options
+ * auto_int:: Automatically scale intervals?
+ */
+ auto_int : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * resolution:: If auto_int is true, shoot for this many points.
+ */
+ resolution : 100,
+ /** @scratch /panels/multifieldhistogram/3
+ * interval:: If auto_int is set to false, use this as the interval.
+ */
+ interval : '5m',
+ /** @scratch /panels/multifieldhistogram/3
+ * interval:: Array of possible intervals in the *View* selector. Example [`auto',`1s',`5m',`3h']
+ */
+ intervals : ['auto','1s','1m','5m','10m','30m','1h','3h','12h','1d','1w','1y'],
+ /** @scratch /panels/multifieldhistogram/3
+ * ==== Drawing options
+ * lines:: Show line chart
+ */
+ lines : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * fill:: Area fill factor for line charts, 1-10
+ */
+ fill : 0,
+ /** @scratch /panels/multifieldhistogram/3
+ * linewidth:: Weight of lines in pixels
+ */
+ linewidth : 3,
+ /** @scratch /panels/multifieldhistogram/3
+ * points:: Show points on chart
+ */
+ points : false,
+ /** @scratch /panels/multifieldhistogram/3
+ * pointradius:: Size of points in pixels
+ */
+ pointradius : 5,
+ /** @scratch /panels/multifieldhistogram/3
+ * stack:: Stack multiple series
+ */
+ stack : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * spyable:: Show inspect icon
+ */
+ spyable : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * zoomlinks:: Show `Zoom Out' link
+ */
+ zoomlinks : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * options:: Show quick view options section
+ */
+ options : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * legend:: Display the legond
+ */
+ legend : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * show_query:: If no alias is set, should the query be displayed?
+ */
+ show_query : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * interactive:: Enable click-and-drag to zoom functionality
+ */
+ interactive : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * legend_counts:: Show counts in legend
+ */
+ legend_counts : true,
+ /** @scratch /panels/multifieldhistogram/3
+ * ==== Transformations
+ * timezone:: Correct for browser timezone?. Valid values: browser, utc
+ */
+ timezone : 'browser', // browser or utc
+ /** @scratch /panels/multifieldhistogram/3
+ * percentage:: Show the y-axis as a percentage of the axis total. Only makes sense for multiple
+ * queries
+ */
+ percentage : false,
+ /** @scratch /panels/multifieldhistogram/3
+ * tooltip object::
+ * tooltip.value_type::: Individual or cumulative controls how tooltips are display on stacked charts
+ * tooltip.query_as_alias::: If no alias is set, should the query be displayed?
+ */
+ tooltip : {
+ value_type: 'cumulative',
+ query_as_alias: true
+ }
+ };
+
+ _.defaults($scope.panel,_d);
+ _.defaults($scope.panel.tooltip,_d.tooltip);
+ _.defaults($scope.panel.annotate,_d.annotate);
+ _.defaults($scope.panel.grid,_d.grid);
+
+
+
+ $scope.init = function() {
+ // Hide view options by default
+ $scope.options = false;
+
+ // Always show the query if an alias isn't set. Users can set an alias if the query is too
+ // long
+ $scope.panel.tooltip.query_as_alias = true;
+
+ $scope.get_data();
+
+ };
+
+ $scope.set_interval = function(interval) {
+ if(interval !== 'auto') {
+ $scope.panel.auto_int = false;
+ $scope.panel.interval = interval;
+ } else {
+ $scope.panel.auto_int = true;
+ }
+ };
+
+ $scope.interval_label = function(interval) {
+ return $scope.panel.auto_int && interval === $scope.panel.interval ? interval+" (auto)" : interval;
+ };
+
+ /**
+ * The time range effecting the panel
+ * @return {[type]} [description]
+ */
+ $scope.get_time_range = function () {
+ var range = $scope.range = filterSrv.timeRange('last');
+ return range;
+ };
+
+ $scope.get_alias = function (value, query) {
+ var alias = '';
+ var isCount = value.mode === 'count';
+ if (value.alias) {
+ alias += value.alias;
+ } else {
+ if (query.alias) {
+ alias += query.alias;
+ } else {
+ if (isCount) {
+ alias += $scope.panel.show_query ? query.query||'*' : '';
+ } else {
+ alias += $scope.panel.show_query ? '('+(query.query||'*')+')' : '';
+ }
+ }
+ alias += !isCount && value.value_field ? (alias && '.')+value.value_field : '';
+ alias = alias ? value.mode + '(' + alias + ')' : value.mode;
+ }
+ return alias;
+ };
+
+ $scope.get_interval = function () {
+ var interval = $scope.panel.interval,
+ range;
+ if ($scope.panel.auto_int) {
+ range = $scope.get_time_range();
+ if (range) {
+ interval = kbn.secondsToHms(
+ kbn.calculate_interval(range.from, range.to, $scope.panel.resolution, 0) / 1000
+ );
+ }
+ }
+ $scope.panel.interval = interval || '10m';
+ return $scope.panel.interval;
+ };
+
+ /**
+ * Fetch the data for a chunk of a queries results. Multiple segments occur when several indicies
+ * need to be consulted (like timestamped logstash indicies)
+ *
+ * The results of this function are stored on the scope's data property. This property will be an
+ * array of objects with the properties info, time_series, and hits. These objects are used in the
+ * render_panel function to create the historgram.
+ *
+ * @param {number} segment The segment count, (0 based)
+ * @param {number} query_id The id of the query, generated on the first run and passed back when
+ * this call is made recursively for more segments
+ */
+ $scope.get_data = function(data, segment, query_id) {
+ var
+ _range,
+ _interval,
+ request,
+ queries,
+ results;
+
+ if (_.isUndefined(segment)) {
+ segment = 0;
+ }
+ delete $scope.panel.error;
+
+ // Make sure we have everything for the request to complete
+ if(dashboard.indices.length === 0) {
+ return;
+ }
+ _range = $scope.get_time_range();
+ _interval = $scope.get_interval(_range);
+
+ if ($scope.panel.auto_int) {
+ $scope.panel.interval = kbn.secondsToHms(
+ kbn.calculate_interval(_range.from,_range.to,$scope.panel.resolution,0)/1000);
+ }
+
+ $scope.panelMeta.loading = true;
+ request = $scope.ejs.Request();
+
+ // Build the queries
+ _.each($scope.panel.values, function(panel_value, panel_value_index) {
+ queries = querySrv.getQueryObjs(panel_value.queries);
+ _.each(queries, function(q) {
+ var serie_id = panel_value_index.toString()+"_"+q.id.toString();
+ var query = $scope.ejs.FilteredQuery(
+ querySrv.toEjsObj(q),
+ filterSrv.getBoolFilter(filterSrv.ids())
+ );
+
+ var facet = $scope.ejs.DateHistogramFacet(serie_id);
+
+ if(panel_value.mode === 'count') {
+ facet = facet.field($scope.panel.time_field).global(true);
+ } else {
+ if(_.isNull(panel_value.value_field)) {
+ $scope.panel.error = "In " + panel_value.mode + " mode a field must be specified";
+ return;
+ }
+ facet = facet.keyField($scope.panel.time_field).valueField(panel_value.value_field).global(true);
+ }
+ facet = facet.interval(_interval).facetFilter($scope.ejs.QueryFilter(query));
+ request = request.facet(facet)
+ .size($scope.panel.annotate.enable ? $scope.panel.annotate.size : 0);
+ });
+ });
+
+ // Annotate query
+ if($scope.panel.annotate.enable) {
+ var query = $scope.ejs.FilteredQuery(
+ $scope.ejs.QueryStringQuery($scope.panel.annotate.query || '*'),
+ filterSrv.getBoolFilter(filterSrv.idsByType('time'))
+ );
+ request = request.query(query);
+
+ // This is a hack proposed by @boaz to work around the fact that we can't get
+ // to field data values directly, and we need timestamps as normalized longs
+ request = request.sort([
+ $scope.ejs.Sort($scope.panel.annotate.sort[0]).order($scope.panel.annotate.sort[1]).ignoreUnmapped(true),
+ $scope.ejs.Sort($scope.panel.time_field).desc().ignoreUnmapped(true)
+ ]);
+ }
+
+ // Populate the inspector panel
+ $scope.populate_modal(request);
+
+ // Then run it
+ results = $scope.ejs.doSearch(dashboard.indices[segment], request);
+
+ // Populate scope when we have results
+ return results.then(function(results) {
+ $scope.panelMeta.loading = false;
+ if(segment === 0) {
+ $scope.legend = {};
+ $scope.hits = 0;
+ data = {};
+ $scope.annotations = [];
+ query_id = $scope.query_id = new Date().getTime();
+ }
+
+ // Check for error and abort if found
+ if(!(_.isUndefined(results.error))) {
+ $scope.panel.error = $scope.parse_error(results.error);
+ }
+ // Make sure we're still on the same query/queries
+ else if($scope.query_id === query_id) {
+
+ var time_series,
+ hits,
+ counters; // Stores the bucketed hit counts.
+
+ _.each($scope.panel.values, function(panel_value, panel_value_index) {
+ queries = querySrv.getQueryObjs(panel_value.queries);
+ _.each(queries, function(q) {
+ var serie_id = panel_value_index.toString()+"_"+q.id.toString();
+ var query_results = results.facets[serie_id];
+ // we need to initialize the data variable on the first run,
+ // and when we are working on the first segment of the data.
+ if(_.isUndefined(data[serie_id]) || segment === 0) {
+ var tsOpts = {
+ interval: _interval,
+ start_date: _range && _range.from,
+ end_date: _range && _range.to,
+ fill_style: panel_value.derivative ? 'null' : panel_value.zerofill ? 'minimal' : 'no'
+ };
+ time_series = new timeSeries.ZeroFilled(tsOpts);
+ hits = 0;
+ counters = {};
+ } else {
+ time_series = data[serie_id].time_series;
+ hits = data[serie_id].hits;
+ counters = data[serie_id].counters;
+ }
+
+ // push each entry into the time series, while incrementing counters
+ _.each(query_results.entries, function(entry) {
+ var value;
+
+ hits += entry.count; // The series level hits counter
+ $scope.hits += entry.count; // Entire dataset level hits counter
+ counters[entry.time] = (counters[entry.time] || 0) + entry.count;
+
+ if(panel_value.mode === 'count') {
+ value = (time_series._data[entry.time] || 0) + entry.count;
+ } else if (panel_value.mode === 'mean') {
+ // Compute the ongoing mean by
+ // multiplying the existing mean by the existing hits
+ // plus the new mean multiplied by the new hits
+ // divided by the total hits
+ value = (((time_series._data[entry.time] || 0)*(counters[entry.time]-entry.count)) +
+ entry.mean*entry.count)/(counters[entry.time]);
+ } else if (panel_value.mode === 'min'){
+ if(_.isUndefined(time_series._data[entry.time])) {
+ value = entry.min;
+ } else {
+ value = time_series._data[entry.time] < entry.min ? time_series._data[entry.time] : entry.min;
+ }
+ } else if (panel_value.mode === 'max'){
+ if(_.isUndefined(time_series._data[entry.time])) {
+ value = entry.max;
+ } else {
+ value = time_series._data[entry.time] > entry.max ? time_series._data[entry.time] : entry.max;
+ }
+ } else if (panel_value.mode === 'total'){
+ value = (time_series._data[entry.time] || 0) + entry.total;
+ }
+ time_series.addValue(entry.time, value);
+ });
+
+ var info = {
+ color: panel_value.color || q.color,
+ alias: $scope.get_alias(panel_value, q),
+ };
+
+ $scope.legend[serie_id] = {query:info,hits:hits};
+
+ data[serie_id] = {
+ info: info,
+ yaxis: panel_value.yaxisposition === 'left' ? 1 : 2,
+ time_series: time_series,
+ hits: hits,
+ counters: counters
+ };
+ });
+ });
+
+ if($scope.panel.annotate.enable) {
+ $scope.annotations = $scope.annotations.concat(_.map(results.hits.hits, function(hit) {
+ var _p = _.omit(hit,'_source','sort','_score');
+ var _h = _.extend(kbn.flatten_json(hit._source),_p);
+ return {
+ min: hit.sort[1],
+ max: hit.sort[1],
+ eventType: "annotation",
+ title: null,
+ description: "<small><i class='icon-tag icon-flip-vertical'></i> "+
+ _h[$scope.panel.annotate.field]+"</small><br>"+
+ moment(hit.sort[1]).format('YYYY-MM-DD HH:mm:ss'),
+ score: hit.sort[0]
+ };
+ }));
+ // Sort the data
+ $scope.annotations = _.sortBy($scope.annotations, function(v){
+ // Sort in reverse
+ return v.score*($scope.panel.annotate.sort[1] === 'desc' ? -1 : 1);
+ });
+ // And slice to the right size
+ $scope.annotations = $scope.annotations.slice(0,$scope.panel.annotate.size);
+ }
+ }
+
+ // Tell the multifieldhistogram directive to render.
+ $scope.$emit('render', data);
+
+ // If we still have segments left, get them
+ if(segment < dashboard.indices.length-1) {
+ $scope.get_data(data,segment+1,query_id);
+ }
+
+ });
+
+ };
+
+ // function $scope.zoom
+ // factor :: Zoom factor, so 0.5 = cuts timespan in half, 2 doubles timespan
+ $scope.zoom = function(factor) {
+ var _range = filterSrv.timeRange('last');
+ var _timespan = (_range.to.valueOf() - _range.from.valueOf());
+ var _center = _range.to.valueOf() - _timespan/2;
+
+ var _to = (_center + (_timespan*factor)/2);
+ var _from = (_center - (_timespan*factor)/2);
+
+ // If we're not already looking into the future, don't.
+ if(_to > Date.now() && _range.to < Date.now()) {
+ var _offset = _to - Date.now();
+ _from = _from - _offset;
+ _to = Date.now();
+ }
+
+ if(factor > 1) {
+ filterSrv.removeByType('time');
+ }
+ filterSrv.set({
+ type:'time',
+ from:moment.utc(_from).toDate(),
+ to:moment.utc(_to).toDate(),
+ field:$scope.panel.time_field
+ });
+ };
+
+ // I really don't like this function, too much dom manip. Break out into directive?
+ $scope.populate_modal = function(request) {
+ $scope.inspector = request.toJSON();
+ };
+
+ $scope.set_refresh = function (state) {
+ $scope.refresh = state;
+ };
+
+ $scope.close_edit = function() {
+ if($scope.refresh) {
+ $scope.get_data();
+ }
+ $scope.refresh = false;
+ $scope.$emit('render');
+ };
+
+ $scope.render = function() {
+ $scope.$emit('render');
+ };
+
+ $scope.add_new_value = function(panel) {
+ panel.values.push(angular.copy($scope.defaultValue));
+ };
+
+ });
+
+ module.directive('multifieldhistogramChart', function(dashboard, filterSrv) {
+ return {
+ restrict: 'A',
+ template: '<div></div>',
+ link: function(scope, elem) {
+ var data, plot;
+
+ scope.$on('refresh',function(){
+ scope.get_data();
+ });
+
+ // Receive render events
+ scope.$on('render',function(event,d){
+ data = d || data;
+ render_panel(_.values(data));
+ });
+
+ var scale = function(series,factor) {
+ return _.map(series,function(p) {
+ return [p[0],p[1]*factor];
+ });
+ };
+
+ var scaleSeconds = function(series,interval) {
+ return _.map(series,function(p) {
+ return [p[0],p[1]/kbn.interval_to_seconds(interval)];
+ });
+ };
+
+ var derivative = function(series) {
+ return _.map(series, function(p,i) {
+ var _v;
+ if(i === 0 || p[1] === null) {
+ _v = [p[0],null];
+ } else {
+ _v = series[i-1][1] === null ? [p[0],null] : [p[0],p[1]-(series[i-1][1])];
+ }
+ return _v;
+ });
+ };
+
+ // Function for rendering panel
+ function render_panel(data) {
+ // IE doesn't work without this
+ try {
+ elem.css({height:scope.panel.height||scope.row.height});
+ } catch(e) {return;}
+
+ // Populate from the query service
+ try {
+ _.each(data, function(series) {
+ series.label = series.info.alias;
+ series.color = series.info.color;
+ });
+ } catch(e) {return;}
+
+
+ var stack = scope.panel.stack ? true : null;
+
+ // Populate element
+ try {
+ var options = {
+ legend: { show: false },
+ series: {
+ stackpercent: scope.panel.stack ? scope.panel.percentage : false,
+ stack: scope.panel.percentage ? null : stack,
+ lines: {
+ show: scope.panel.lines,
+ // Silly, but fixes bug in stacked percentages
+ fill: scope.panel.fill === 0 ? 0.001 : scope.panel.fill/10,
+ lineWidth: scope.panel.linewidth,
+ steps: false
+ },
+ points: {
+ show: scope.panel.points,
+ fill: 1,
+ fillColor: false,
+ radius: scope.panel.pointradius
+ },
+ shadowSize: 1
+ },
+ yaxes: [{
+ show: scope.panel['y-axis'],
+ min: scope.panel.grid.min,
+ max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.max
+ },{
+ show: scope.panel['y-axis'],
+ position: 'right',
+ min: scope.panel.grid.min,
+ max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.max
+ }],
+ xaxis: {
+ timezone: scope.panel.timezone,
+ show: scope.panel['x-axis'],
+ mode: "time",
+ min: _.isUndefined(scope.range.from) ? null : scope.range.from.getTime(),
+ max: _.isUndefined(scope.range.to) ? null : scope.range.to.getTime(),
+ timeformat: time_format(scope.panel.interval),
+ label: "Datetime",
+ ticks: elem.width()/100
+ },
+ grid: {
+ backgroundColor: null,
+ borderWidth: 0,
+ hoverable: true,
+ color: '#c8c8c8'
+ }
+ };
+
+ if (scope.panel.y_format === 'bytes') {
+ options.yaxes[0].mode = "byte";
+ options.yaxes[0].tickFormatter = function (val, axis) {
+ return kbn.byteFormat(val, 0, axis.tickSize);
+ };
+ }
+
+ if (scope.panel.y_format === 'short') {
+ options.yaxis[0].tickFormatter = function (val, axis) {
+ return kbn.shortFormat(val, 0, axis.tickSize);
+ };
+ }
+
+ if(scope.panel.annotate.enable) {
+ options.events = {
+ clustering: true,
+ levels: 1,
+ data: scope.annotations,
+ types: {
+ 'annotation': {
+ level: 1,
+ icon: {
+ width: 20,
+ height: 21,
+ icon: "histogram-marker"
+ }
+ }
+ }
+ //xaxis: int // the x axis to attach events to
+ };
+ }
+
+ if(scope.panel.interactive) {
+ options.selection = { mode: "x", color: '#666' };
+ }
+
+ // when rendering stacked, we need to ensure each point that has data is zero-filled
+ // so that the stacking happens in the proper order
+ var required_times = [];
+ if (data.length > 1) {
+ required_times = Array.prototype.concat.apply([], _.map(data, function (query) {
+ return query.time_series.getOrderedTimes();
+ }));
+ required_times = _.uniq(required_times.sort(function (a, b) {
+ // decending numeric sort
+ return a-b;
+ }), true);
+ }
+
+
+ for (var i = 0; i < data.length; i++) {
+ var _d = data[i].time_series.getFlotPairs(required_times);
+ if(scope.panel.values[i].derivative) {
+ _d = derivative(_d);
+ }
+ if(scope.panel.values[i].scale !== 1) {
+ _d = scale(_d,scope.panel.values[i].scale);
+ }
+ if(scope.panel.scaleSeconds) {
+ _d = scaleSeconds(_d,scope.panel.interval);
+ }
+ data[i].data = _d;
+ }
+
+ plot = $.plot(elem, data, options);
+
+ } catch(e) {
+ // Nothing to do here
+ }
+ }
+
+ function time_format(interval) {
+ var _int = kbn.interval_to_seconds(interval);
+ if(_int >= 2628000) {
+ return "%Y-%m";
+ }
+ if(_int >= 86400) {
+ return "%Y-%m-%d";
+ }
+ if(_int >= 60) {
+ return "%H:%M<br>%m-%d";
+ }
+
+ return "%H:%M:%S";
+ }
+
+ var $tooltip = $('<div>');
+ elem.bind("plothover", function (event, pos, item) {
+ var group, value, timestamp, interval;
+ interval = " per " + (scope.panel.scaleSeconds ? '1s' : scope.panel.interval);
+ if (item) {
+ if (item.series.info.alias || scope.panel.tooltip.query_as_alias) {
+ group = '<small style="font-size:0.9em;">' +
+ '<i class="icon-circle" style="color:'+item.series.color+';"></i>' +
+ ' ' + item.series.info.alias + '</small><br>';
+ } else {
+ group = kbn.query_color_dot(item.series.color, 15) + ' ';
+ }
+ value = (scope.panel.stack && scope.panel.tooltip.value_type === 'individual') ?
+ item.datapoint[1] - item.datapoint[2] :
+ item.datapoint[1];
+ if(scope.panel.y_format === 'bytes') {
+ value = kbn.byteFormat(value,2);
+ }
+ if(scope.panel.y_format === 'short') {
+ value = kbn.shortFormat(value,2);
+ } else {
+ value = numeral(value).format('0,0[.]000');
+ }
+ timestamp = scope.panel.timezone === 'browser' ?
+ moment(item.datapoint[0]).format('YYYY-MM-DD HH:mm:ss') :
+ moment.utc(item.datapoint[0]).format('YYYY-MM-DD HH:mm:ss');
+ $tooltip
+ .html(
+ group + value + interval + " @ " + timestamp
+ )
+ .place_tt(pos.pageX, pos.pageY);
+ } else {
+ $tooltip.detach();
+ }
+ });
+
+ elem.bind("plotselected", function (event, ranges) {
+ filterSrv.set({
+ type : 'time',
+ from : moment.utc(ranges.xaxis.from).toDate(),
+ to : moment.utc(ranges.xaxis.to).toDate(),
+ field : scope.panel.time_field
+ });
+ });
+ }
+ };
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/styleEditor.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/styleEditor.html b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/styleEditor.html
new file mode 100644
index 0000000..fb01184
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/styleEditor.html
@@ -0,0 +1,85 @@
+<div class="editor-row">
+ <div class="section">
+ <h5>Chart Options</h5>
+ <div class="editor-option">
+ <label class="small">Lines</label><input type="checkbox" ng-model="panel.lines" ng-checked="panel.lines">
+ </div>
+ <div class="editor-option">
+ <label class="small">Points</label><input type="checkbox" ng-model="panel.points" ng-checked="panel.points">
+ </div>
+ <div class="editor-option">
+ <label class="small">Selectable</label><input type="checkbox" ng-model="panel.interactive" ng-checked="panel.interactive">
+ </div>
+ <div class="editor-option">
+ <label class="small">xAxis</label><input type="checkbox" ng-model="panel['x-axis']" ng-checked="panel['x-axis']"></div>
+ <div class="editor-option">
+ <label class="small">yAxis</label><input type="checkbox" ng-model="panel['y-axis']" ng-checked="panel['y-axis']"></div>
+ <div class="editor-option" ng-show="panel.lines">
+ <label class="small">Line Fill</label>
+ <select class="input-mini" ng-model="panel.fill" ng-options="f for f in [0,1,2,3,4,5,6,7,8,9,10]"></select>
+ </div>
+ <div class="editor-option" ng-show="panel.lines">
+ <label class="small">Line Width</label>
+ <select class="input-mini" ng-model="panel.linewidth" ng-options="f for f in [0,1,2,3,4,5,6,7,8,9,10]"></select>
+ </div>
+ <div class="editor-option" ng-show="panel.points">
+ <label class="small">Point Radius</label>
+ <select class="input-mini" ng-model="panel.pointradius" ng-options="f for f in [1,2,3,4,5,6,7,8,9,10]"></select>
+ </div>
+ <div class="editor-option">
+ <label class="small">Y Format <tip>Y-axis formatting</tip></label>
+ <select class="input-small" ng-model="panel.y_format" ng-options="f for f in ['none','short','bytes']"></select>
+ </div>
+ </div>
+ <div class="section">
+ <h5>Multiple Series</h5>
+ <div class="editor-option">
+ <label class="small">Stack</label><input type="checkbox" ng-model="panel.stack" ng-checked="panel.stack">
+ </div>
+ <div class="editor-option" ng-show="panel.stack">
+ <label style="white-space:nowrap" class="small">Percent <tip>Stack as a percentage of total</tip></label>
+ <input type="checkbox" ng-model="panel.percentage" ng-checked="panel.percentage">
+ </div>
+ <div class="editor-option" ng-show="panel.stack">
+ <label class="small">Stacked Values <tip>How should the values in stacked charts to be calculated?</tip></label>
+ <select class="input-small" ng-model="panel.tooltip.value_type" ng-options="f for f in ['cumulative','individual']"></select>
+ </div>
+ </div>
+</div>
+
+<div class="editor-row">
+ <div class="section">
+ <h5>Header<h5>
+ <div class="editor-option">
+ <label class="small">Zoom</label><input type="checkbox" ng-model="panel.zoomlinks" ng-checked="panel.zoomlinks" />
+ </div>
+ <div class="editor-option">
+ <label class="small">View</label><input type="checkbox" ng-model="panel.options" ng-checked="panel.options" />
+ </div>
+ </div>
+ <div class="section">
+ <h5>Legend<h5>
+ <div class="editor-option">
+ <label class="small">Legend</label><input type="checkbox" ng-model="panel.legend" ng-checked="panel.legend">
+ </div>
+ <div ng-show="panel.legend" class="editor-option">
+ <label class="small">Query <tip>If no alias is set, show the query in the legend</tip></label><input type="checkbox" ng-model="panel.show_query" ng-checked="panel.show_query" ng-change='set_refresh(true)'>
+ </div>
+ <div ng-show="panel.legend" class="editor-option">
+ <label class="small">Counts</label><input type="checkbox" ng-model="panel.legend_counts" ng-checked="panel.legend_counts">
+ </div>
+ </div>
+
+ <div class="section">
+ <h5>Grid<h5>
+ <div class="editor-option">
+ <label class="small">Min / <a href='' ng-click="panel.grid.min = _.toggle(panel.grid.min,null,0)">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.min)"></i></a></label>
+ <input type="number" class="input-small" ng-model="panel.grid.min"/>
+ </div>
+ <div class="editor-option">
+ <label class="small">Max / <a ref='' ng-click="panel.grid.max = _.toggle(panel.grid.max,null,0)">Auto <i class="icon-star" ng-show="_.isNull(panel.grid.max)"></i></a></label>
+ <input type="number" class="input-small" ng-model="panel.grid.max"/>
+ </div>
+ </div>
+
+</div>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/timeSeries.js
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/timeSeries.js b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/timeSeries.js
new file mode 100644
index 0000000..4f94735
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/multifieldhistogram/timeSeries.js
@@ -0,0 +1,235 @@
+define([
+ './interval',
+ 'lodash'
+],
+function (Interval, _) {
+ 'use strict';
+
+ var ts = {};
+
+ // map compatable parseInt
+ function base10Int(val) {
+ return parseInt(val, 10);
+ }
+
+ // trim the ms off of a time, but return it with empty ms.
+ function getDatesTime(date) {
+ return Math.floor(date.getTime() / 1000)*1000;
+ }
+
+ /**
+ * Certain graphs require 0 entries to be specified for them to render
+ * properly (like the line graph). So with this we will caluclate all of
+ * the expected time measurements, and fill the missing ones in with 0
+ * @param {object} opts An object specifying some/all of the options
+ *
+ * OPTIONS:
+ * @opt {string} interval The interval notion describing the expected spacing between
+ * each data point.
+ * @opt {date} start_date (optional) The start point for the time series, setting this and the
+ * end_date will ensure that the series streches to resemble the entire
+ * expected result
+ * @opt {date} end_date (optional) The end point for the time series, see start_date
+ * @opt {string} fill_style Either "minimal", or "all" describing the strategy used to zero-fill
+ * the series.
+ */
+ ts.ZeroFilled = function (opts) {
+ opts = _.defaults(opts, {
+ interval: '10m',
+ start_date: null,
+ end_date: null,
+ fill_style: 'minimal'
+ });
+
+ // the expected differenece between readings.
+ this.interval = new Interval(opts.interval);
+
+ // will keep all values here, keyed by their time
+ this._data = {};
+ // For each bucket in _data, store a corresponding counter of how many times it was written to.
+ this._counters = {};
+ this.start_time = opts.start_date && getDatesTime(opts.start_date);
+ this.end_time = opts.end_date && getDatesTime(opts.end_date);
+ this.opts = opts;
+ };
+
+ /**
+ * Add a row
+ * @param {int} time The time for the value, in
+ * @param {any} value The value at this time
+ */
+ ts.ZeroFilled.prototype.addValue = function (time, value) {
+ this._counters[time] = (this._counters[time] || 0) + 1;
+ if (time instanceof Date) {
+ time = getDatesTime(time);
+ } else {
+ time = base10Int(time);
+ }
+ if (!isNaN(time)) {
+ this._data[time] = (_.isUndefined(value) ? 0 : value);
+ }
+ this._cached_times = null;
+ };
+
+ /**
+ * Get an array of the times that have been explicitly set in the series
+ * @param {array} include (optional) list of timestamps to include in the response
+ * @return {array} An array of integer times.
+ */
+ ts.ZeroFilled.prototype.getOrderedTimes = function (include) {
+ var times = _.map(_.keys(this._data), base10Int);
+ if (_.isArray(include)) {
+ times = times.concat(include);
+ }
+ return _.uniq(times.sort(function (a, b) {
+ // decending numeric sort
+ return a - b;
+ }), true);
+ };
+
+ /**
+ * return the rows in the format:
+ * [ [time, value], [time, value], ... ]
+ *
+ * Heavy lifting is done by _get(Min|Default|All)FlotPairs()
+ * @param {array} required_times An array of timestamps that must be in the resulting pairs
+ * @return {array}
+ */
+ ts.ZeroFilled.prototype.getFlotPairs = function (required_times) {
+ var times = this.getOrderedTimes(required_times),
+ strategy,
+ pairs;
+
+ if(this.opts.fill_style === 'all') {
+ strategy = this._getAllFlotPairs;
+ } else if(this.opts.fill_style === 'null') {
+ strategy = this._getNullFlotPairs;
+ } else if(this.opts.fill_style === 'no') {
+ strategy = this._getNoZeroFlotPairs;
+ } else {
+ strategy = this._getMinFlotPairs;
+ }
+
+ pairs = _.reduce(
+ times, // what
+ strategy, // how
+ [], // where
+ this // context
+ );
+
+ // if the first or last pair is inside either the start or end time,
+ // add those times to the series with null values so the graph will stretch to contain them.
+ // Removing, flot 0.8.1's max/min params satisfy this
+ /*
+ if (this.start_time && (pairs.length === 0 || pairs[0][0] > this.start_time)) {
+ pairs.unshift([this.start_time, null]);
+ }
+ if (this.end_time && (pairs.length === 0 || pairs[pairs.length - 1][0] < this.end_time)) {
+ pairs.push([this.end_time, null]);
+ }
+ */
+
+ return pairs;
+ };
+
+ /**
+ * ** called as a reduce stragegy in getFlotPairs() **
+ * Fill zero's on either side of the current time, unless there is already a measurement there or
+ * we are looking at an edge.
+ * @return {array} An array of points to plot with flot
+ */
+ ts.ZeroFilled.prototype._getMinFlotPairs = function (result, time, i, times) {
+ var next, expected_next, prev, expected_prev;
+
+ // check for previous measurement
+ if (i > 0) {
+ prev = times[i - 1];
+ expected_prev = this.interval.before(time);
+ if (prev < expected_prev) {
+ result.push([expected_prev, 0]);
+ }
+ }
+
+ // add the current time
+ result.push([ time, this._data[time] || 0]);
+
+ // check for next measurement
+ if (times.length > i) {
+ next = times[i + 1];
+ expected_next = this.interval.after(time);
+ if (next > expected_next) {
+ result.push([expected_next, 0]);
+ }
+ }
+
+ return result;
+ };
+
+ /**
+ * ** called as a reduce stragegy in getFlotPairs() **
+ * Fill zero's to the right of each time, until the next measurement is reached or we are at the
+ * last measurement
+ * @return {array} An array of points to plot with flot
+ */
+ ts.ZeroFilled.prototype._getAllFlotPairs = function (result, time, i, times) {
+ var next, expected_next;
+
+ result.push([ times[i], this._data[times[i]] || 0 ]);
+ next = times[i + 1];
+ expected_next = this.interval.after(time);
+ for(; times.length > i && next > expected_next; expected_next = this.interval.after(expected_next)) {
+ result.push([expected_next, 0]);
+ }
+
+ return result;
+ };
+
+ /**
+ * ** called as a reduce stragegy in getFlotPairs() **
+ * Same as min, but fills with nulls
+ * @return {array} An array of points to plot with flot
+ */
+ ts.ZeroFilled.prototype._getNullFlotPairs = function (result, time, i, times) {
+ var next, expected_next, prev, expected_prev;
+
+ // check for previous measurement
+ if (i > 0) {
+ prev = times[i - 1];
+ expected_prev = this.interval.before(time);
+ if (prev < expected_prev) {
+ result.push([expected_prev, null]);
+ }
+ }
+
+ // add the current time
+ result.push([ time, this._data[time] || null]);
+
+ // check for next measurement
+ if (times.length > i) {
+ next = times[i + 1];
+ expected_next = this.interval.after(time);
+ if (next > expected_next) {
+ result.push([expected_next, null]);
+ }
+ }
+
+ return result;
+ };
+
+ /**
+ * ** called as a reduce stragegy in getFlotPairs() **
+ * Not fill zero's on either side of the current time, only the current time
+ * @return {array} An array of points to plot with flot
+ */
+ ts.ZeroFilled.prototype._getNoZeroFlotPairs = function (result, time) {
+
+ // add the current time
+ if(this._data[time]){
+ result.push([ time, this._data[time]]);
+ }
+
+ return result;
+ };
+
+ return ts;
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/percentiles/editor.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/percentiles/editor.html b/kibana-3.x/src/main/resources/app/panels/percentiles/editor.html
new file mode 100644
index 0000000..2a7fc69
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/percentiles/editor.html
@@ -0,0 +1,42 @@
+<div class="row-fluid">
+ <h5>Details</h5>
+ <div class="editor-option">
+ <label class="small">Featured Percentile</label>
+ <select ng-change="set_refresh(true)" class="input-small" ng-model="panel.mode" ng-options="f for f in modes"></select>
+ </div>
+ <div class="editor-option">
+ <label class="small">Field <tip>This field must contain a numeric value</tip></label>
+ <input ng-change="set_refresh(true)" placeholder="Start typing" bs-typeahead="fields.list" type="text" class="input-large" ng-model="panel.field">
+ </div>
+ <div class="editor-option">
+ <label class="small">Unit</label>
+ <input type="text" class="input-large" ng-model="panel.unit">
+ </div>
+ <div class="editor-option">
+ <label class="small">Compression <tip>Compression controls memory usage and approximation error</tip></label>
+ <input type="text" class="input-small" ng-model="panel.compression">
+ </div>
+
+ <h5>Columns</h5>
+ <div class="editor-option" ng-repeat="stat in modes">
+ <label class="small">{{stat}}</label><input type="checkbox" ng-model="panel.show[stat]" ng-checked="panel.show[stat]">
+ </div>
+
+ <h5>Formating</h5>
+ <div class="editor-option">
+ <label class="small">Format</label>
+ <select ng-change="set_refresh(true)" class="input-small" ng-model="panel.format" ng-options="f for f in ['number','float','money','bytes']"></select>
+ </div>
+ <div class="editor-option">
+ <label class="small">Font Size</label>
+ <select class="input-mini" ng-model="panel.style['font-size']" ng-options="f for f in ['7pt','8pt','9pt','10pt','12pt','14pt','16pt','18pt','20pt','24pt','28pt','32pt','36pt','42pt','48pt','52pt','60pt','72pt']"></select></span>
+ </div>
+ <div class="editor-option">
+ <label class="small">Display Breakdowns</label>
+ <select class="input-mini" ng-model="panel.display_breakdown" ng-options="f for f in ['yes', 'no']"></select></span>
+ </div>
+ <div class="editor-option">
+ <label class="small">Query column name</label>
+ <input type="text" class="input-large" ng-model="panel.label_name">
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/percentiles/module.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/percentiles/module.html b/kibana-3.x/src/main/resources/app/panels/percentiles/module.html
new file mode 100644
index 0000000..ef2b95b
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/percentiles/module.html
@@ -0,0 +1,37 @@
+<div ng-controller="percentiles" ng-init="init()">
+ <style>
+ table.stats-table th, table.stats-table td {
+ text-align: right;
+ }
+
+ table.stats-table th:first-child, table.stats-table td:first-child {
+ text-align: left !important;
+ }
+
+
+ </style>
+
+ <h1 ng-style="panel.style" style="text-align: center; line-height: .6em">{{data.value|formatstats:panel.format}} <small style="font-size: .5em; line-height: 0;">{{panel.unit}} ({{panel.mode}})</small></h1>
+ <table ng-show="panel.display_breakdown == 'yes'" cellspacing="0" class="table-hover table table-condensed stats-table" style="margin-top: 38px;">
+ <tbody>
+ <thead>
+ <tr>
+ <th><a href="" ng-click="set_sort('label')" ng-class="{'icon-chevron-down': panel.sort_field == 'label' && panel.sort_reverse == true, 'icon-chevron-up': panel.sort_field == 'label' && panel.sort_reverse == false}"> {{panel.label_name}} </a></th>
+ <th ng-repeat="stat in modes" ng-show="panel.show[stat]">
+ <a href=""
+ ng-click="set_sort(stat)"
+ ng-class="{'icon-chevron-down': panel.sort_field == stat && panel.sort_reverse == true, 'icon-chevron-up': panel.sort_field == stat && panel.sort_reverse == false}">
+ {{stat}}%
+ </a>
+ </th>
+ </tr>
+ </thead>
+ <tr ng-repeat="item in data.rows | orderBy:(panel.sort_field == 'label' ? 'label' : 'value.'+panel.sort_field):panel.sort_reverse">
+ <td><i class="icon-circle" ng-style="{color:item.color}"></i> {{item.label}}</td>
+ <td ng-repeat="stat in modes" ng-show="panel.show[stat]">{{item.value[stat]|formatstats:panel.format}} {{panel.unit}}</td>
+
+ <!--<td style="text-align: right;">{{item.value|formatstats:panel.format}} {{panel.unit}}</td>-->
+ </tr>
+ </tbody>
+ </table>
+</div>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/percentiles/module.js
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/percentiles/module.js b/kibana-3.x/src/main/resources/app/panels/percentiles/module.js
new file mode 100644
index 0000000..f4b6e64
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/percentiles/module.js
@@ -0,0 +1,258 @@
+/*
+
+ ## Percentiles Module
+
+ ### Parameters
+ * format :: The format of the value returned. (Default: number)
+ * style :: The font size of the main number to be displayed.
+ * mode :: The aggergate value to use for display
+ * spyable :: Dislay the 'eye' icon that show the last elasticsearch query
+
+*/
+define([
+ 'angular',
+ 'app',
+ 'lodash',
+ 'jquery',
+ 'kbn',
+ 'numeral',
+ 'config'
+], function (
+ angular,
+ app,
+ _,
+ $,
+ kbn,
+ numeral,
+ config
+) {
+
+ 'use strict';
+
+ var module = angular.module('kibana.panels.percentiles', []);
+ app.useModule(module);
+
+ module.controller('percentiles', function ($scope, querySrv, dashboard, filterSrv, $http, esVersion) {
+
+ $scope.panelMeta = {
+ modals : [
+ {
+ description: "Inspect",
+ icon: "icon-info-sign",
+ partial: "app/partials/inspector.html",
+ show: $scope.panel.spyable
+ }
+ ],
+ editorTabs : [
+ {title:'Queries', src:'app/partials/querySelect.html'}
+ ],
+ status: 'Beta',
+ description: 'A percentiles panel for displaying aggregations using the Elastic Search percentiles aggregation query.'
+ };
+
+ $scope.modes = ['25','50','75','90','95','99'];
+
+ var defaults = {
+ queries : {
+ mode : 'all',
+ ids : []
+ },
+ style : { "font-size": '24pt'},
+ format: 'number',
+ mode: 'count',
+ display_breakdown: 'yes',
+ sort_field: '',
+ sort_reverse: false,
+ label_name: 'Query',
+ value_name: 'Value',
+ spyable : true,
+ compression : 100,
+ show: {
+ '25': true,
+ '75': true,
+ '95': true,
+ '99': true,
+ }
+ };
+
+ _.defaults($scope.panel, defaults);
+
+ $scope.init = function () {
+ $scope.ready = false;
+ $scope.$on('refresh', function () {
+ $scope.get_data();
+ });
+ $scope.get_data();
+ };
+
+ $scope.set_sort = function(field) {
+ if($scope.panel.sort_field === field && $scope.panel.sort_reverse === false) {
+ $scope.panel.sort_reverse = true;
+ } else if($scope.panel.sort_field === field && $scope.panel.sort_reverse === true) {
+ $scope.panel.sort_field = '';
+ $scope.panel.sort_reverse = false;
+ } else {
+ $scope.panel.sort_field = field;
+ $scope.panel.sort_reverse = false;
+ }
+ };
+
+ $scope.get_data = function () {
+ if(dashboard.indices.length === 0) {
+ return;
+ }
+
+ $scope.panelMeta.loading = true;
+
+ var request,
+ results,
+ boolQuery,
+ queries;
+
+ request = $scope.ejs.Request();
+
+ $scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
+ queries = querySrv.getQueryObjs($scope.panel.queries.ids);
+
+ // This could probably be changed to a BoolFilter
+ boolQuery = $scope.ejs.BoolQuery();
+ _.each(queries,function(q) {
+ boolQuery = boolQuery.should(querySrv.toEjsObj(q));
+ });
+
+ var percents = _.keys($scope.panel.show);
+
+ request = request
+ .aggregation(
+ $scope.ejs.FilterAggregation('stats')
+ .filter($scope.ejs.QueryFilter(
+ $scope.ejs.FilteredQuery(
+ boolQuery,
+ filterSrv.getBoolFilter(filterSrv.ids())
+ )
+ ))
+ .aggregation($scope.ejs.PercentilesAggregation('stats')
+ .field($scope.panel.field)
+ .percents(percents)
+ .compression($scope.panel.compression)
+ )
+ ).size(0);
+
+ $.each(queries, function (i, q) {
+ var query = $scope.ejs.BoolQuery();
+ query.should(querySrv.toEjsObj(q));
+ var qname = 'stats_'+i;
+
+ request.aggregation(
+ $scope.ejs.FilterAggregation(qname)
+ .filter($scope.ejs.QueryFilter(
+ $scope.ejs.FilteredQuery(
+ query,
+ filterSrv.getBoolFilter(filterSrv.ids())
+ )
+ ))
+ .aggregation($scope.ejs.PercentilesAggregation(qname)
+ .field($scope.panel.field)
+ .percents(percents)
+ .compression($scope.panel.compression)
+ )
+ );
+ });
+ // Populate the inspector panel
+ $scope.inspector = request.toJSON();
+
+ results = $scope.ejs.doSearch(dashboard.indices, request);
+
+ results.then(function(results) {
+ $scope.panelMeta.loading = false;
+ esVersion.gte('1.3.0').then(function(is) {
+ if (is) {
+ var value = results.aggregations.stats['stats']['values'][$scope.panel.mode+'.0'];
+ var rows = queries.map(function (q, i) {
+ var alias = q.alias || q.query;
+ var obj = _.clone(q);
+ obj.label = alias;
+ obj.Label = alias.toLowerCase(); //sort field
+ obj.value = {};
+ obj.Value = {};
+ var data = results.aggregations['stats_'+i]['stats_'+i]['values'];
+ for ( var keys in data ) {
+ obj.value[parseInt(keys)] = data[keys];
+ obj.Value[parseInt(keys)] = data[keys]; //sort field
+ };
+ return obj;
+ });
+
+ $scope.data = {
+ value: value,
+ rows: rows
+ };
+
+ $scope.$emit('render');
+ } else {
+ esVersion.gte('1.1.0').then(function(is) {
+ if (is) {
+ var value = results.aggregations.stats['stats'][$scope.panel.mode+'.0'];
+ var rows = queries.map(function (q, i) {
+ var alias = q.alias || q.query;
+ var obj = _.clone(q);
+ obj.label = alias;
+ obj.Label = alias.toLowerCase(); //sort field
+ obj.value = {};
+ obj.Value = {};
+ var data = results.aggregations['stats_'+i]['stats_'+i];
+ for ( var keys in data ) {
+ obj.value[parseInt(keys)] = data[keys];
+ obj.Value[parseInt(keys)] = data[keys]; //sort field
+ };
+ return obj;
+ });
+
+ $scope.data = {
+ value: value,
+ rows: rows
+ };
+
+ $scope.$emit('render');
+ }
+ });
+ };
+ });
+
+ });
+ };
+
+ $scope.set_refresh = function (state) {
+ $scope.refresh = state;
+ };
+
+ $scope.close_edit = function() {
+ if($scope.refresh) {
+ $scope.get_data();
+ }
+ $scope.refresh = false;
+ $scope.$emit('render');
+ };
+
+ });
+
+ module.filter('formatstats', function(){
+ return function (value,format) {
+ switch (format) {
+ case 'money':
+ value = numeral(value).format('$0,0.00');
+ break;
+ case 'bytes':
+ value = numeral(value).format('0.00b');
+ break;
+ case 'float':
+ value = numeral(value).format('0.000');
+ break;
+ default:
+ value = numeral(value).format('0,0');
+ }
+ return value;
+ };
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/query/editor.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/query/editor.html b/kibana-3.x/src/main/resources/app/panels/query/editor.html
new file mode 100644
index 0000000..3100415
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/query/editor.html
@@ -0,0 +1,7 @@
+<div>
+ <div class="row-fluid">
+ <div class="span12">
+ No options here
+ </div>
+ </div>
+</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/query/editors/lucene.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/query/editors/lucene.html b/kibana-3.x/src/main/resources/app/panels/query/editors/lucene.html
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/query/editors/regex.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/query/editors/regex.html b/kibana-3.x/src/main/resources/app/panels/query/editors/regex.html
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/query/editors/topN.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/query/editors/topN.html b/kibana-3.x/src/main/resources/app/panels/query/editors/topN.html
new file mode 100644
index 0000000..5fe4566
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/query/editors/topN.html
@@ -0,0 +1,12 @@
+ <fieldset>
+ <label class="small">Field</label><br>
+ <input ng-model="dashboard.current.services.query.list[id].field" type="text" bs-typeahead="fields.list" placeholder="Field">
+ <p>
+ <label class="small">Count</label><br>
+ <input ng-model="dashboard.current.services.query.list[id].size" type="number">
+ <p>
+ <label class="small">Union</label><br>
+ <select class="input-small" ng-model="dashboard.current.services.query.list[id].union">
+ <option ng-repeat="mode in ['none','AND','OR']">{{mode}}</option>
+ </select>
+ </fieldset>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/0bcbfc59/kibana-3.x/src/main/resources/app/panels/query/help/lucene.html
----------------------------------------------------------------------
diff --git a/kibana-3.x/src/main/resources/app/panels/query/help/lucene.html b/kibana-3.x/src/main/resources/app/panels/query/help/lucene.html
new file mode 100644
index 0000000..9e860e9
--- /dev/null
+++ b/kibana-3.x/src/main/resources/app/panels/query/help/lucene.html
@@ -0,0 +1,30 @@
+The lucene query type uses <a target="_blank" href='http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax'>LUCENE query string syntax</a> to find matching documents or events within Elasticsearch.
+
+<h4>Examples</h4>
+<ul class="unstyled" type="disc">
+ <li class="listitem"><p class="simpara">
+ <code class="literal">status</code> field contains <code class="literal">active</code>
+ </p><pre class="literallayout">status:active</pre></li>
+ <li class="listitem"><p class="simpara">
+ <code class="literal">title</code> field contains <code class="literal">quick</code> or <code class="literal">brown</code>
+ </p><pre class="literallayout">title:(quick brown)</pre></li>
+ <li class="listitem"><p class="simpara">
+ <code class="literal">author</code> field contains the exact phrase <code class="literal">"john smith"</code>
+ </p><pre class="literallayout">author:"John Smith"</pre></li>
+</ul>
+
+<p>Wildcard searches can be run on individual terms, using <code class="literal">?</code> to replace
+a single character, and <code class="literal">*</code> to replace zero or more characters:</p>
+<pre class="literallayout">qu?ck bro*</pre>
+
+<ul class="unstyled" type="disc">
+ <li class="listitem"><p class="simpara">
+ Numbers 1..5
+ </p><pre class="literallayout">count:[1 TO 5]</pre></li>
+ <li class="listitem"><p class="simpara">
+ Tags between <code class="literal">alpha</code> and <code class="literal">omega</code>, excluding <code class="literal">alpha</code> and <code class="literal">omega</code>:
+ </p><pre class="literallayout">tag:{alpha TO omega}</pre></li>
+ <li class="listitem"><p class="simpara">
+ Numbers from 10 upwards
+ </p><pre class="literallayout">count:[10 TO *]</pre></li>
+</ul>