-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Timelion] Fixes bug with escape colons in field names in the metric/split parameter #96770
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
@@ -30,7 +31,7 @@ export default function createDateAgg(config, tlConfig, scriptedFields) { | |||
|
|||
dateAgg.time_buckets.aggs = {}; | |||
_.each(config.metric, function (metric) { | |||
metric = metric.split(':'); | |||
metric = metric.split(/:(.+)/).slice(0, OPERANDS_NUMBER); |
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.
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.
Resolved
dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(metric[1], scriptedFields); | ||
if (metric[0] === 'percentiles' && metric[2]) { | ||
let percentList = metric[2].split(','); | ||
dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(field, scriptedFields); |
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.
what if we do it a little bit obvious. I see we are dealing with 3 cases.
const [metricName, metricArgs] = metric.split(/:(.+)/);
if (metricName === 'count') {
} else if (metricName === 'percentiles') {
} else if (metricName, metricArgs){
}
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.
oh... sorry, I see we need
dateAgg.time_buckets.aggs[metricName] = {};
dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(field, scriptedFields);
for percentiles too.
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.
Now, it's cleaned up from array indexes at least
@elasticmachine merge upstream |
Jenkins test this |
'cardinality::sample', | ||
'sum::beer', | ||
'percentiles::bytes:1', | ||
'percentiles:::bytes:1.2,1.3,2.7', |
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.
Nice ❤️
(config.metric || []).forEach((metric) => { | ||
const metricBody = {}; | ||
const [metricName, metricArgs] = metric.split(/:(.+)/); | ||
if (metricName === 'count') { |
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.
I know that this is how it was before but do you want to use instead of count
and percentiles
the METRIC_TYPES.COUNT
and METRIC_TYPES.PERCENTILES
from the data plugin?
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.
Added
needs more work, suggestions are not working fine with fields started from |
@elasticmachine merge upstream |
Pinging @elastic/kibana-app (Team:KibanaApp) |
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.
Thank you Dima, it seems to work fine now 👏 LGTM
@alexwizp can you also check it again?
import { buildAggBody } from './agg_body'; | ||
import { search } from '../../../../../../plugins/data/server'; | ||
import { METRIC_TYPES } from '../../../../../data/common/search/aggs/metrics/index'; |
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.
wrong import. Please replace to '../../../../../data/server'
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.
Resolved
const metricBody = {}; | ||
const [metricName, metricArgs] = metric.split(/:(.+)/); | ||
console.log('METRIC_TYPES.COUNT', METRIC_TYPES.COUNT); | ||
console.log('METRIC_TYPES.PERCENTILES', METRIC_TYPES.PERCENTILES); |
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.
@dmitriynj please remove the console.logs :D
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.
Sorry, done
Jenkins test this |
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.
LGTM! Thank you
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @dmitriynj |
…split parameter (elastic#96770) * [Timelion] add colons support in field names for metric * [Timelion] support percent for metric * [Timelion] get rid of array indexes * [Timelion] get rid of lodash methods * [Timelion] support colons in split. fix expression suggestions * [Timelion] escape colons for metric * [Timelion] use metric types common constants * [Timelion] support one symbol field name * [Timelion] resolve duplicate imports * [Timelion] remove console logs Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…split parameter (#96770) (#97606) * [Timelion] add colons support in field names for metric * [Timelion] support percent for metric * [Timelion] get rid of array indexes * [Timelion] get rid of lodash methods * [Timelion] support colons in split. fix expression suggestions * [Timelion] escape colons for metric * [Timelion] use metric types common constants * [Timelion] support one symbol field name * [Timelion] resolve duplicate imports * [Timelion] remove console logs Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@dmitriynj , @alexwizp , & @stratoula : Thanks for all your hard work on this! Our team is stoked about the change. Can't wait for the next release! |
Closes #95954
Summary
:te:st:1
:te:st1: