Visualize > Metric aggregation on terms


(Damien) #1

Hi everyone,

I'm trying to use Kibana 5.X to render data from an ES 5.X that is populate using an open source project, Apache Unomi.
I'm pretty new to ES and even more to Kibana so I could be miss understanding how to reach my goal, I have spent some time reading the documentation and the forum but could not find what I needed.

I have a query which may not be perfect (if anyone know a better way to do that, you are welcome) but does work and now I would like to display the result of this query using Visualize > Metric (one big number...), but I tried to reproduce my query using Kibana UI and could not do it, again they might have a better way to display this information and therefore to do it.

Here is my query:
GET context-*/_search/
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "_type: event AND eventType: view",
"analyze_wildcard": true
}
}
]
}
},
"size": 0,
"aggs": {
"pages_view_per_session": {
"terms": {
"field": "sessionId.keyword",
"order": {
"_count": "desc"
},
"size": 20000
}
},
"avg_pages_view_per_session": {
"avg_bucket": {
"buckets_path": "pages_view_per_session._count"
}
}
}
}

So I'm getting all docs of type event with a property eventType = view and then I'm aggregating those docs using their property sessionId.keyword, which basically give the number of pages view by session and then I'm using this aggregate to calculate the average pages view per session which is the number that I would like to display using Visualize > Metric

Also I have a bonus question, I didn't spend a lot of time on this one to be honest, and found some information on google but most of them are pretty old.
Is it possible to create a visualization or a dashboard that display its visualization based on a parameter in its URL?
My final goal is to build a generic dashboard that will display information based on a page path for example, so I will just display the dashboard in an iframe and add the page path to the url of the dashboard.

Thanks in advance for the help :slight_smile:


(Tim Sullivan) #2

Hi Damien,

This is a really cool idea, but unfortunately the metric visualization doesn't provide a way to do anything other than a metric aggregation. There's no way in the Metric Visualize builder to start with a bucket aggregation and then pipe the data into an avg_bucket pipeline aggregation.

If you feel up for it, would you mind creating an enhancement request in our issues page? https://github.com/elastic/kibana/issues

-Tim


(Damien) #3

Hi @tsullivan ,

Thanks for your answer, I will create an enhancement request.

Any idea about my second question?

Thanks again for your help :slight_smile:

Damien


(Tim Sullivan) #4

This isn't documented, but the Dashboard URLs are made up of variables and conditions that are encoded in RISON. If you can de-code and re-construct those variables, then you can replace the values how you want. If you want to show a different dashboard based on a "page path," then look closely at how the URL changes when you add or remove a filter for that page path.

Another way to possibly do what you want would be to programmatically create saved dashboards that you need by constructing saved objects to store in the .kibana index. If you want to be able to show different dashboards in an iframe, you could just switch the _id of the dashboard in the iframe url. You can specify your own _id at index time, which would help a lot there.

If you don't have very many dashboards that you have to manage, you could also create a Markdown visualization that has links to the different dashboards. The Markdown viz would act as a control widget to navigate to different dashboards. Just add that visualization to each dashboard.


(Tim Sullivan) #5

Hi again Damien,

This actually will be possible in 5.4.0. There are new pipeline aggregation options available for most of the visualization types. For Metric aggregation, you'll be able to select "Average Bucket" as the aggregation type, and then choose a terms aggregation and a metric aggregation. I've played with this a little bit in a preview build and it looks like it can do exactly what you want.

I'm getting all docs of type event with a property eventType = view

For this part, you would want to make a saved search for these docs, and then base the visualization off of that saved search.

A high-level intro to the pipeline features is given by @ppisljar in the video: https://www.elastic.co/elasticon/conf/2017/sf/kibana-visualizations-deep-dive , so you can check that out too.

I hope you will be able to try out 5.4.0 when it comes out (soon)!

-Tim


(Damien) #6

Hi Tim,

Sorry for the late answer and thanks for all those information.
I will check out everything, but so far it looks promising :slight_smile:

Damien


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.