Add a custom metric to Kibana (4.1)

(Damien Picard) #1


Using scripted metrics aggregation in ElasticSearch, I created a metric that returns the "duration" between the oldest and the newest document in a bucket, given a date field (useful to know, for example, a session duration from logs).

These scripts work well, and I get a result very similar to the "standard" aggregation like sum, min, max etc. :
"aggregations": {"sessionid_terms": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 4,
"buckets": [
"key": "41249bb5fe7d32078145f06a675d0fe5",
"doc_count": 64,
"duration": {"value": 6395711}
"key": "34ac96dcf0a8a59325788bda593c23f9",
"doc_count": 59,
"duration": {"value": 4298000}

Now, I would like to offer the possibility to my end-users to use this metric the same way the others metrics (sum, min, max, etc.) in Kibana.
So I take a look at the Kibana 4.1 source code from github, but I'm not sure the way I have to do that ; especially I don't find a "plugin" way to add this metric.

What is your advice to achieve it ?

Thank you.

(Tanya Bragin) #2

Kibana does not support creating fields using scripted metric aggregations:

You might be able to use JSON input in aggregations to do something fancy like that -- see one example here: Display concurrency in data on Kibana

(system) #3