-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Timelion percentiles aggregation support (#8953) #15154
Add Timelion percentiles aggregation support (#8953) #15154
Conversation
Elasticsearch already supports percentiles aggregation. In order to support it in Timelion we add `percentiles` aggregation function and optionally a list of comma separated `percents` to the request. The response contains a list of buckets, each of them is a single series.
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. This is really nice.
There are just a few additional files that need to be updated
- arg_value_suggestions Need to add
percentiles
as an argument suggestion. - We should add another test case to es.js to verify that multi-value metric aggregataion results are flattened as expected.
@@ -34,6 +34,11 @@ export default function createDateAgg(config, tlConfig, scriptedFields) { | |||
const metricName = metric[0] + '(' + metric[1] + ')'; | |||
dateAgg.time_buckets.aggs[metricName] = {}; | |||
dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(metric[1], scriptedFields); | |||
if (metric[0] === 'percentiles' && metric[2]) { | |||
let percentList = metric[2].split(','); | |||
percentList = percentList.map(x => parseFloat(x)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
percents
is an optional parameter of the percentiles
aggregation. I think it should be optional in timelion as well. So percentiles:load_time
and percentiles:load_time:95,99.99
are both valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is optional. In case there are no percents
, metric[2]
is false
and percentList
is not added to the request. ES returns the default list[ 1, 5, 25, 50, 75, 95, 99 ]
then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. disregard
if (metric[0] === 'percentiles' && metric[2]) { | ||
let percentList = metric[2].split(','); | ||
percentList = percentList.map(x => parseFloat(x)); | ||
dateAgg.time_buckets.aggs[metricName][metric[0]].percents = percentList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to use the buildAggBody method so scripted fields can be supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scripted fields are already supported.
36: dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(metric[1], scriptedFields);
buildAggBody
sets dateAgg.time_buckets.aggs[metricName][metric[0]]
to either field
or script
, percents
is added to the corresponding object afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. disregard
Done. Should we also mention |
@wkruse yes, that text should also be updated. Maybe something like @thomasneirynck what are your thoughts on the updated metric description? |
@nreese Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me (lgtm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice addition @wkruse, thanks a lot!
I think there's a small bug when dealing with time-ranges with empty data. Could you double check?
thx,
series[key] = series[key] || []; | ||
series[key].push(val.value); | ||
if (val.values) { | ||
_.forOwn(val.values, function (bucketValue, bucketKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should filter here on NaN
values. These arise when there is no data in the time-range of the bucket. They get propagated to the client, and the code breaks on the front-end (https://github.com/thomasneirynck/kibana/blob/e274f118f720386c551d3941668387f686e3d52c/src/core_plugins/timelion/public/panels/timechart/schema.js#L168-L168).
TypeError: y.toFixed is not a function
at setLegendNumbers
Nice catch, thanks for looking into it @thomasneirynck! First I tried to remove |
Input data are in JSON. |
thanks for the quick update @wkruse, I'll try and take a look later today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged! thanks @wkruse |
…15154) * Add Timelion percentiles aggregation support (elastic#8953) Elasticsearch already supports percentiles aggregation. In order to support it in Timelion we add `percentiles` aggregation function and optionally a list of comma separated `percents` to the request. The response contains a list of buckets, each of them is a single series. * Add percentiles as an argument suggestion * Add test case for percentiles multi-value metric aggregation flattening * Add percentiles to the function reference help page * Fix broken frontend on NaN values
* Add Timelion percentiles aggregation support (#8953) Elasticsearch already supports percentiles aggregation. In order to support it in Timelion we add `percentiles` aggregation function and optionally a list of comma separated `percents` to the request. The response contains a list of buckets, each of them is a single series. * Add percentiles as an argument suggestion * Add test case for percentiles multi-value metric aggregation flattening * Add percentiles to the function reference help page * Fix broken frontend on NaN values
fixes #8953
Elasticsearch already supports percentiles aggregation. In order to support it in Timelion we add
percentiles
aggregation function and optionally a list of comma separatedpercents
to the request.The response contains a list of buckets, each of them is a single series.
Usage in Timelion:
Thanks to @nisxiya!
Elasticsearch: Percentiles Aggregation