How to combine aggregations in ElasticSearch/Kibana? - elasticsearch

Let's imagine I am logging displays and clicks, say by cities.
I can aggregate those by countries and I can also compute grand totals.
Now I would like to compute click rates (clicks/displays) by cities, countries and I would also like to get a global click rate.
How can I do this?
It seems that I could use a scripted metric (I have not tried yet) but I would also like to expose these rates in Kibana.
It is possible?

I also want this feature. Kibana don't have this feature at this moment but maybe in the future version. please take a look at:
https://github.com/elasticsearch/kibana/issues/2646
update: I think you can use scripted fields please see for more info http://www.elasticsearch.org/blog/kibana-4-beta-3-now-more-filtery/

Related

Is there a way to hide the total sum from a single column in a data table on Kibana?

I created a data table containing several columns: most of them must show the total of their respective values. I’m just wondering if there’s a way to selectively hide this sum, since the latest column includes an average of ratings and it doesn’t make sense to have a sum of them.
Below, an example of what I’d like to achieve if it’s possibile:
Basically, I need to hide the number deleted in red. I know that there could be plugins to do so, but I don’t know if I can ask to install one or more.
Thanks in advance.

Fixed time range for a grafana panel

I'm using several time series panels on my dashboards, which are showing the values based on the selected time range.
Now, I want to add a gauge panel, which should show the number of payment transactions since midnight (although I know all the problems about server restarts, the feature of the rate function, etc. the gauge panel will an interesting part of my dashboard). So my query has to be independant from the selected time range of the dashboard.
I've found the variables ${__from} und ${__to} in the Grafana docs, but I'm not sure, how I can use them in a query or how to use them flexibel, e.g. getting the current daten/time as "to" and calculating "from" als midnight value.
Has anybody an idea, if this is generally possible?
Thanks in advance
Matthias

Is it possible to total a schema field?

Apologies if this has come up before, but I couldn't find anything.
I am using GraphCMS (highly recommend it) and I have several fields that are floats. I am using them for prices. Each entry in the schema can either be a buy or sell in an enumeration field. I would like to total all the price fields where the entry is a buy, and total all the price fields where the entry is a sell.
I thought there would be something clear in the docs because totalling those fields would be very useful for something like calculating an average score etc. but I can only see docs about counting entries. Have I missed it somewhere?
Surely this is possible?
After speaking with the helpful guys at GraphCMS I have figured out how to do it. This is not a question about GraphCMS as #puelo suggested, but can be achieved by running a graphql query and then programatically running calculations with the data. It's a simple solution but wasn't immediately apparent to me at first. Hopefully that info will be useful to other newbies.

Grafana elasticsearch time from now

I've configured Grafana to use Elasticsearch as a data source and prepared a few panels.
My document in ES index contains only a few fields. It describes some system actions, respectively there are such fields as userId, action date, and others.
Now I faced with the issue that I can't calculate the amount of time left when the action happened. I mean if the action happened 2 days ago, I need to have the number 2 in my table. Pretty simple I supposed.
I couldn't find any metric or transformation that can allow me to do it.
Any suggestion, help, please.
Resolved my issue with scripted field.
In table visualization, I just picked any numeric field, selected Min metric, and added script like next:
Instant Currentdate = Instant.ofEpochMilli(new Date().getTime());
Instant Startdate = Instant.ofEpochMilli(doc['activity'].value.getMillis());
ChronoUnit.DAYS.between(Startdate, Currentdate);
As a result, it shows me the number I needed.
I don't find this solution the best, so in case anybody know some better way to resolve this issue, please add a comment.

Grafana graph total count shown as list?

I have a Grafana dashboard, where I am currently getting my query shown as a "Gauge"-graph showing the total hits.
As you can see on the screenshot, it shows total number of hits - but I would like to have them on a list, with the details of each hit (NOT the Kibana way).
I've looked at some of the other graph models that Grafana provide and the "Table"-model is the one I find best, but it only shows the columns "time" and "count", which isn't that useful.
Is there some way to manipulate the columns shown on the table, so it isnt "time" and "count" but more custom values?
Or do others have better ways to do it?
I have already looked at the tutorial/guidelines provided by Grafana here but I find them quite low on details.
I've also tried to pull out the "Raw document" to find the JSON-columns, that I want shown, but then it crashes and I get the same error message as the one reported in Grafans github here saying
"Grafana has likely been updated. Please try reloading the page."
hmm... Quite frustrating to be honest.
// In short: I want to add some metrics from the query that is shown in the JSON, which I can place in the table, as I want.
UPDATE 22nd Oct. 2019
Regarding the error message from Grafana
"Grafana has likely been updated. Please try reloading the page."
Updating it to the newest version 6.4.3 fixed this problem, even though it should have been fixed in 6.4.2.
This enables me to see raw JSON formatted data, so that is done. Now I need to find out how to fetch and work with some of these data inside the JSON, so that I can see them on the table.
Found out that I just had to use the metric "Unique Count" or "Count" from where I choose a indexed metric which will then give me a count value.
Please double check that you are not getting an average value, but a total. If it fx shows 0.4 and you only have integers, then you are probably getting an average value.
Also if you want to play around with the different metrics, so they show in the panel, a solution would be to choose the metric "Raw Document". Then inside visualization you can choose to add the metrics you want shown under "Column". Press the '+' mark and add the different metrics.
If you want to give it a better name, you can configure it under "Column Styles".
And finally - always stay up to date with the newest grafana version, so you don't end up getting frustated over a error which is only there because you haven't updated.

Resources