Skip to content

Commit

Permalink
Merge pull request #470 from spenceralger/limit_pie_to_count_metric
Browse files Browse the repository at this point in the history
[pie] only allow count agg
  • Loading branch information
spenceralger committed Oct 3, 2014
2 parents aa25e0c + 93e201e commit 020561d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Kibana is an open source (Apache Licensed), browser based analytics and search d

You're up and running! Fantastic! Kibana is now running on port 5601, so point your browser at http://YOURDOMAIN.com:5601.

The first screen you arrive at will ask you to configure an **index pattern**. An index pattern describes to kibana how to access your data. We make the guess that you're working with log data, and we hope (because it's awesome) that you're working with Logstash. By default, we fill in `logstash-*` as your index pattern, thus the only thing you need to do is select which field contains the timestamp you'd like to use. Kibana reads your Elasticsearch mapping to find your time fields - select one from the list and hit *Create*.
The first screen you arrive at will ask you to configure an **index pattern**. An index pattern describes to Kibana how to access your data. We make the guess that you're working with log data, and we hope (because it's awesome) that you're working with Logstash. By default, we fill in `logstash-*` as your index pattern, thus the only thing you need to do is select which field contains the timestamp you'd like to use. Kibana reads your Elasticsearch mapping to find your time fields - select one from the list and hit *Create*.

**Tip:** there's an optimization in the way of the *Use event times to create index names* option. Since Logstash creates an index every day, Kibana uses that fact to only search indices that could possibly contain data in your selected time range.

Expand Down Expand Up @@ -128,7 +128,7 @@ Or HTML
status:[400 TO 499] AND (extension:php OR extension:html)
```

While lucene query syntax is simple and very powerful, Kibana also supports the full elasticsearch, JSON based, query DSL. See the [Elasticsearch documentation](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax) for usage and examples.
While Lucene query syntax is simple and very powerful, Kibana also supports the full Elasticsearch, JSON based, Query DSL. See the [Elasticsearch documentation](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax) for usage and examples.
<!-- /include -->
<!-- include {"path":"docs/visualize.md"} -->
## Visualize
Expand Down Expand Up @@ -163,7 +163,7 @@ To the right of the search box there are a row of icons for creating new visuali

#### Aggregation Builder

The aggregation builder on the left of the screen is used for configuring the [metric](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-aggregations.html#_metrics_aggregations) and [bucket](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-aggregations.html#_bucket_aggregations) aggregations used to create a visualization. (If you are coming from the SQL world, buckets are similar to group-bys. Check out the [elasticsearch docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-aggregations.html) for more info) For a bar chart or line chart the *metric* is used for the y-axis and the *buckets* are used for the x-axis, segment bar colors, and row/column splits. For pie charts the "metric" is used for the size of the slice and the *bucket* is used for the number of slices. Other visualizations may use these in new and different ways.
The aggregation builder on the left of the screen is used for configuring the [metric](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-aggregations.html#_metrics_aggregations) and [bucket](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-aggregations.html#_bucket_aggregations) aggregations used to create a visualization. (If you are coming from the SQL world, buckets are similar to group-bys. Check out the [Elasticsearch docs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-aggregations.html) for more info) For a bar chart or line chart the *metric* is used for the y-axis and the *buckets* are used for the x-axis, segment bar colors, and row/column splits. For pie charts the "metric" is used for the size of the slice and the *bucket* is used for the number of slices. Other visualizations may use these in new and different ways.

For the remainder of this documentation we are going to use the bar chart as our example when discussing the features of the aggregation panel. The same concepts apply to the other visualizations but the bar chart is the workhorse of the visualization world.

Expand Down
2 changes: 1 addition & 1 deletion src/kibana/apps/visualize/editor/agg.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
class="form-control"
ng-model="agg.type"
required
ng-options="agg as agg.title for agg in aggTypeOptions">
ng-options="agg as agg.title for agg in aggTypeOptions | aggFilter:agg.schema.aggFilter">
</select>
</div>
</div>
Expand Down
36 changes: 36 additions & 0 deletions src/kibana/apps/visualize/editor/agg_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Gets all fields of a given type.
// You may also pass "*" to get all types
// Or an array of types to get all fields of that type
define(function (require) {
var _ = require('lodash');

require('modules')
.get('kibana')
.filter('aggFilter', function () {
return function (aggs, names) {
if (!names) return aggs;
if (!_.isArray(names)) names = [names];
if (_.contains(names, '*')) return aggs;

var filters = names.map(function (name) {
var filter = {
match: true,
name: name
};

if (name.charAt(0) === '!') {
filter.match = false;
filter.name = name.substr(1);
}
return filter;
});

return aggs.filter(function (agg) {
for (var i = 0; i < filters.length; i++) {
var filter = filters[i];
if ((agg.name === filter.name) === filter.match) return true;
}
});
};
});
});
1 change: 1 addition & 0 deletions src/kibana/apps/visualize/editor/editor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define(function (require) {
require('apps/visualize/saved_visualizations/saved_visualizations');
require('apps/visualize/editor/sidebar');
require('apps/visualize/editor/agg_filter');

require('directives/saved_object_finder');
require('components/visualize/visualize');
Expand Down
1 change: 1 addition & 0 deletions src/kibana/components/vis_types/_schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ define(function (require) {
max: Infinity,
group: 'buckets',
title: schema.name,
aggFilter: '*',
editor: false,
params: []
});
Expand Down
1 change: 1 addition & 0 deletions src/kibana/components/vis_types/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define(function (require) {
title: 'Slice Size',
min: 1,
max: 1,
aggFilter: 'count',
defaults: [
{ schema: 'metric', type: 'count' }
]
Expand Down

0 comments on commit 020561d

Please sign in to comment.