-
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] Support custom field format #101245
[TSVB] Support custom field format #101245
Conversation
Add format_label response processor for series vis data and bucket key formatting to process_bucket for table vis data
…r all panel types except markdown
…teCustomFieldFormatter
…on script to set ignore_field_formatting to true for the series
…espect only active metrics field name, refactor vis files and fix label formatting only for grouped by terms series
… and get_table_data, replace getCustomFieldFormatter with createCustomFieldFormatter
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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 and works fine. I think that it is a great addition for TSVB. Thank you @dziyanadzeraviankina for your effort and for your patience with it :D
I would only like @mbondyra to also do a sanity check in case I missed anything ❤️
LGTM, tested locally in chrome! |
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 review only 👍
Left some nitpick comments.
src/plugins/vis_type_timeseries/public/application/components/data_format_picker.tsx
Outdated
Show resolved
Hide resolved
src/plugins/vis_type_timeseries/public/application/components/aggs/agg.tsx
Outdated
Show resolved
Hide resolved
const isFieldFormatter = column.formatter === DATA_FORMATTERS.DEFAULT; | ||
const field = getMetricsField(column.metrics); | ||
const formatter = isFieldFormatter | ||
? createFieldFormatter(field, fieldFormatMap, 'html') | ||
: createTickFormatter(column.formatter, column.value_template, getConfig); |
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.
nitpick: this formula gets repeated over and over in the PR. Maybe it can be isolated in a separated function that returns {isFieldFormatter, formatter}
?
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.
updated createFieldFormatter
function, could you review that part once again, please?
src/plugins/vis_type_timeseries/public/timeseries_vis_renderer.tsx
Outdated
Show resolved
Hide resolved
@dziyanadzeraviankina thanx, bug is fixed 🎉 Gauge changes also look great :) |
@elasticmachine merge upstream |
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 Sass comments. I didn't do any testing of this, just code-owner review of the Sass file.
@elasticmachine merge upstream |
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.
Works as described, couldn't find anything suspicious. Approved! 👍🏼
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsReferences to deprecated APIs
History
To update your PR or re-run it, just comment with: |
* [TSVB] Support custom field format Add format_label response processor for series vis data and bucket key formatting to process_bucket for table vis data * Add ignore_field_formatting for series to support value formatting for all panel types except markdown * Fix type issue for visData and rename getCustomFieldFormatter to createCustomFieldFormatter * Update vis.test to cover custom field formats logic and add a migration script to set ignore_field_formatting to true for the series * Move createCustomFieldFormatter to a separate file, make formatting respect only active metrics field name, refactor vis files and fix label formatting only for grouped by terms series * Remove services, add getFieldFormatsService to use it in format_label and get_table_data, replace getCustomFieldFormatter with createCustomFieldFormatter * Update plugin.ts * Update start for plugin.ts * Add formatting for annotations and markdown values * Refactor some code * Update some naming and conditions * Fix formatting of data type labels * In process_bucket fix case for no getFieldFormatByName * Add field formatting functional tests for all panel types * Update tests to make them run correctly for firefox * Update _tsvb_markdown test setup * Move series ignoreFieldFormatting check to a separate file, change convertSeriesToVars signature, update migration script and refactor a bit functional tests * Fix type check for timeseries_visualization.tsx * Update migrations.js test expected version to 7.15 * Fix tests in _tsvb_chart.ts * Fix merge conflict remove process_bucket.js * Update process_bucket.test.ts * Fix markdown labels formatting * Add ignore_field_formatting for annotations, enhanced migration script to set that flag to true, refactor data_format_picker * Fix migration script and add disabling for ignore component when string index pattern is used * Add supporting URL and color formatters in tsvb table * Fix eslint * Remove ignore formatting component, add field formatting option to TSVB data format picker and make it default, remove migration script, update tests and refactor some files * Fix failing tests, refactor create_field_formatter and add test to it, update some other files * Fix series formatting for top hit when it has not numeric result * Handle no fieldFormatMap case for table/vis.js * Remove "Default" option form DataFormatPicker when index pattern is string, fix markdown variables issue and refactor some code * Chore(TSVB): Replace aggregations lookup with map * Fix types, update test expected data and remove unused translations * Fix i18 check and useEffect in agg.tsx * Handle aggregations field formatting case * Fix agg_utils, vis and check_if_numeric_metric tests * Correct typo and refactor condition in std_metric * Fix type check * Get rid of IFieldType * Add URL and color formatting for topN and metric tabs, fix setting initial custom formatter and switching formatter in agg.tsx * Update tsvb.asciidoc * Remove link icon from Date format field help text, update click logic for top N in case of custom field format and fix CI * Remove unused import * Revert top N bar extra logic for click * Refactor some code in agg.tsx * Add URL and color formatting to Gauge * Fix bug with terms formatting, refactor some code, update create_field_formatter * Add comments to _gauge.scss * Remove unnecessary await Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
…-link-to-kibana-app * 'master' of github.com:elastic/kibana: (120 commits) [TSVB] Support custom field format (elastic#101245) [VisEditors] Add code ownership to the functional tests (elastic#111680) [Lens] Make Lens saved object share-capable (elastic#111403) [Graph] Make Graph saved object share-capable (elastic#111404) [Stack Monitoring] Add breadcrumb support (elastic#111850) Update Jira Cloud to use OAuth2.0 (elastic#111493) Show warning message when attempting to create an APM alert in stack management (elastic#111781) Skip suite blocking ES snapshot promotion (elastic#111907) Respect `auth_provider_hint` if session is not authenticated. (elastic#111521) Added in 'Responses' field in alert telemetry & updated test (elastic#111892) [Usage collection] refactor cloud detector collector (elastic#110439) Make classnames a shared dep (elastic#111636) Fix link to e2e tests in APM testing.md (elastic#111869) [Security Solution] Add host.os.name.caseless mapping and runtime field (elastic#111455) [APM] Removes the beta label from APM tutorial (elastic#111499) (elastic#111828) [RAC] [Observability] Expand Observability alerts page functional tests (elastic#111297) Fix extra white space on the alert table whe page size is 50 or 100 (elastic#111568) [Metrics UI] Add Inventory Timeline open/close state to context and URL state (elastic#111034) [Graph] Switch to SavedObjectClient.resolve (elastic#109617) [APM] Adding lambda icon (elastic#111834) ... # Conflicts: # x-pack/plugins/reporting/public/management/__snapshots__/report_listing.test.tsx.snap
* [TSVB] Support custom field format Add format_label response processor for series vis data and bucket key formatting to process_bucket for table vis data * Add ignore_field_formatting for series to support value formatting for all panel types except markdown * Fix type issue for visData and rename getCustomFieldFormatter to createCustomFieldFormatter * Update vis.test to cover custom field formats logic and add a migration script to set ignore_field_formatting to true for the series * Move createCustomFieldFormatter to a separate file, make formatting respect only active metrics field name, refactor vis files and fix label formatting only for grouped by terms series * Remove services, add getFieldFormatsService to use it in format_label and get_table_data, replace getCustomFieldFormatter with createCustomFieldFormatter * Update plugin.ts * Update start for plugin.ts * Add formatting for annotations and markdown values * Refactor some code * Update some naming and conditions * Fix formatting of data type labels * In process_bucket fix case for no getFieldFormatByName * Add field formatting functional tests for all panel types * Update tests to make them run correctly for firefox * Update _tsvb_markdown test setup * Move series ignoreFieldFormatting check to a separate file, change convertSeriesToVars signature, update migration script and refactor a bit functional tests * Fix type check for timeseries_visualization.tsx * Update migrations.js test expected version to 7.15 * Fix tests in _tsvb_chart.ts * Fix merge conflict remove process_bucket.js * Update process_bucket.test.ts * Fix markdown labels formatting * Add ignore_field_formatting for annotations, enhanced migration script to set that flag to true, refactor data_format_picker * Fix migration script and add disabling for ignore component when string index pattern is used * Add supporting URL and color formatters in tsvb table * Fix eslint * Remove ignore formatting component, add field formatting option to TSVB data format picker and make it default, remove migration script, update tests and refactor some files * Fix failing tests, refactor create_field_formatter and add test to it, update some other files * Fix series formatting for top hit when it has not numeric result * Handle no fieldFormatMap case for table/vis.js * Remove "Default" option form DataFormatPicker when index pattern is string, fix markdown variables issue and refactor some code * Chore(TSVB): Replace aggregations lookup with map * Fix types, update test expected data and remove unused translations * Fix i18 check and useEffect in agg.tsx * Handle aggregations field formatting case * Fix agg_utils, vis and check_if_numeric_metric tests * Correct typo and refactor condition in std_metric * Fix type check * Get rid of IFieldType * Add URL and color formatting for topN and metric tabs, fix setting initial custom formatter and switching formatter in agg.tsx * Update tsvb.asciidoc * Remove link icon from Date format field help text, update click logic for top N in case of custom field format and fix CI * Remove unused import * Revert top N bar extra logic for click * Refactor some code in agg.tsx * Add URL and color formatting to Gauge * Fix bug with terms formatting, refactor some code, update create_field_formatter * Add comments to _gauge.scss * Remove unnecessary await Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
Closes: #97213, Closes: #32318
Summary
This PR implements support of custom field formatting for all TSVB panel types.
Field format was added to
Data formatters
select as default option.Cases to test for those who will review this PR:
Labels formatting
How to test label formatting:
In the index pattern management section set field formatting for any field type that can be used for terms grouping.
Create visualization with series grouped by terms with this field.
Expect:
Include
andExclude
terms functionality should work with raw (not formatted) field names;Values formatting
How to test values formatting:
Expect:
Data formatters
shouldn't includeDefault
option. In case it was selected before and index pattern was switched to a string,Number
option should be selected for numeric value,Custom
for other value type (this could be checked inMetric
with Top Hit aggregation);Date formatters
should have onlyDefault
andCustom
options for kibana index pattern mode and onlyCustom
for string index pattern. (Currently only Top Hit returns not numeric result, this could be checked inMetric
);Custom
formatter selected,Numeral.js format pattern
field shouldn't be displayed, but template could be applied;Default
option formatting selected for kibana index pattern mode andCustom
for string index pattern;Table
,TopN
andMetrics
values could have Color or URL field formatters;TopN
andTable
Data
tabItem url
should have bigger priority than URL formatting;Table
,TopN
andMetrics
color rules should have bigger priority than color formatting;Checklist
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how
they may potentially impact the change:
For maintainers