-
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
[TSVB] Top_hit supports runtime fields #103401
[TSVB] Top_hit supports runtime fields #103401
Conversation
@elasticmachine merge upstream |
@@ -110,7 +110,7 @@ const TopHitAggUi = (props) => { | |||
PANEL_TYPES.METRIC, | |||
PANEL_TYPES.MARKDOWN, | |||
].includes(panel.type) | |||
? [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING] | |||
? [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING, KBN_FIELD_TYPES.DATE] |
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 here.
- For
TimeSeries/Gauge
we support onlyKBN_FIELD_TYPES.NUMBER
field type. - For
Table/Metric/Markdown
-KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING, KBN_FIELD_TYPES.DATE
The main problem in your PR and code which was implemented before your changes that there are no correct Aggregation
function for String
and Date
.
Currenly it's undefined but I prefer to do it like in classical visualizations with Concatenate option
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.
Needs some changes
@@ -45,7 +45,7 @@ export const getAggValue = (row, metric) => { | |||
} | |||
|
|||
const hits = get(row, [metric.id, 'docs', 'hits', 'hits'], []); | |||
const values = hits.map((doc) => get(doc, `_source.${metric.field}`)); | |||
const [values] = hits.map((doc) => doc.fields[metric.field]); |
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.
should be double checked. Why you take only first value?
@@ -110,7 +110,7 @@ const TopHitAggUi = (props) => { | |||
PANEL_TYPES.METRIC, | |||
PANEL_TYPES.MARKDOWN, | |||
].includes(panel.type) | |||
? [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING] | |||
? [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING, KBN_FIELD_TYPES.DATE] | |||
: [KBN_FIELD_TYPES.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.
@dziyanadzeraviankina @stratoula I see after switching from numbers
to strings
(and now to dates
) our model keep wrong value (value which was selected to numbers
). On UI we see Select...
. This is issue should be fixed.
Please think about adding UI effect to set first option from available list
useEffect(() => {
const defaultFn = aggWithOptions?.[0].value;
const aggWith = model[AGG_WITH_KEY];
if (aggWith && defaultFn && aggWith !== defaultFn && !selectedAggWithOption) {
handleChange({
AGG_WITH_KEY: defaultFn,
});
}
}, [model, selectedAggWithOption, aggWithOptions, handleChange]);
or fix it using different way, e.g. set agg_with
to noop
. I don't have strong opinion here
order: 'desc', | ||
}; | ||
const model = { ...defaults, ...props.model }; | ||
const defaults = useMemo( |
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.
in this case it looks like additional optimization. In fact, this will lead to a slight degradation in performance, since each time the React
caching mechanism will be used to get the value.
If you want you can move it to one level up and create getDefaults()
method or move it directly in line 108
with removing defaults at all
Please run https://kibana-ci.elastic.co/job/kibana+flaky-test-suite-runner/ to be sure that your new tests are not flucky |
Sure, no failures |
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, tested locally
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.
LGTM! Thank you
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
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.
Code LGTM,
I tested it with runtime fields and "normal" ones. It works fine. Thanx for all the tests added ❤️
* [TSVB] Refactor top-hit aggregation to work with fields instead of _source * Allow select date strings for top_hit aggregation in table, metric, and markdown * Fix agg_with handling for top_hit and add some tests * Refactor get_agg_value and fix type check for _tsvb_chart * Refactor top_hit.js Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Refactor top-hit aggregation to work with fields instead of _source * Allow select date strings for top_hit aggregation in table, metric, and markdown * Fix agg_with handling for top_hit and add some tests * Refactor get_agg_value and fix type check for _tsvb_chart * Refactor top_hit.js Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Closes #101705
Summary
Replaced
top_hits
search request_source
option with thefields
option to retrieve the fields.Fix unnecessary symbol escaping for table cells values.
Before:
After:
Checklist
For maintainers