[data views] Default field formatters based on field meta values#174973
[data views] Default field formatters based on field meta values#174973mattkime merged 18 commits intoelastic:mainfrom
Conversation
| // need to consider if we want this, 1 microsecond will display as 0.001ms | ||
| micros: timeUnitToDurationFmt('microseconds'), |
There was a problem hiding this comment.
I saw that you've removed the nanos formatter. I understand that there can be issues with the current formatting library. For example, 1 ns would be formatted as 0.00 ms. However, I think that we should still support nanos, and file an issue for this known limitation/bug. In observability, we'd like to map the span duration as nanos. However, we don't expect spans to have a duration of only a few nanoseconds. It's much more typical to have something in the millisecond or second magnitude. So we'd miss not having support for nanos.
There was a problem hiding this comment.
So you want nanosecond values to display as millisecond even if nanosecond values less than 10,000 are displayed as 0.00 ms?
There was a problem hiding this comment.
I think that's better than not having a default formatter for nanoseconds by default, yes.
If this turns out to be a problem for a specific visualization, users can still change the formatting. This is just setting a default formatter if none has been configured explicitly. Did I get that right?
There was a problem hiding this comment.
Yes, thats correct. I'll restore the formatter
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
felixbarny
left a comment
There was a problem hiding this comment.
Just a question on the test case, otherwise LGTM.
src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.test.js
Outdated
Show resolved
Hide resolved
…nto field_caps_meta_fields
src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.test.js
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: cc @mattkime |
lukasolson
left a comment
There was a problem hiding this comment.
This is awesome! Are there any docs we could update to make this feature known, as well as explain the units that will work here? I made the mistake of using min instead of m and was confused for a second when it wasn't working.
|
@lukasolson I think I'll do docs as a follow up so this can get merged for the current release. |
* main: (224 commits) [Http] Replace `buildNr` with `buildSha` in static asset paths (#175898) [Ops] Fix GCS bucket access for future buildkite agents (#174756) [api-docs] 2024-02-07 Daily api_docs build (#176362) skip flaky suite (#176002) skip failing es promotion suite (#176359) [Cloud Security] [Grouping] Add URL Params support to the grouping components (#175749) chore(NA): update versions after v8.12.2 bump (#176309) chore(NA): update versions after v7.17.19 bump (#176313) skip failing test suite (#176352) [SLO] Enable burn rate alert by default during creation via UI (#176317) [Fleet] Add the uptime capability to observability projects (#176285) [Security Solution][Endpoint] Fix Manifest Manger so that it works with large (>10k) (#174411) [ResponseOps] Alert creation delay based on user definition (#175851) [data views] Default field formatters based on field meta values (#174973) [Cloud Security]Detection Rules counter on Rules Flyout (#176041) [Security Solution] Data Quality Dashboard persistence (#175673) [Ent Search] Connector client copy cleanup (#176290) [ML] Anomaly Detection: Adds actions menu to anomaly markers in Single Metric Viewer chart. (#175556) [ML] Anomaly Detection: Fix `values-dots` colors (#176303) [Fleet] Logstash Output - being compliant to RFC-952 (#176298) ...
…stic#174973) ## Summary Default field formatters based on field meta units data. Note: the smallest unit our formatter will show is milliseconds which means micro and nanoseconds may round down to zero for smaller values. elastic#176112 Closes: elastic#82318 Mapping and doc setup for testing - ``` PUT my-index-000001 PUT my-index-000001/_mapping { "properties": { "nanos": { "type": "long", "meta": { "unit": "nanos" } }, "micros": { "type": "long", "meta": { "unit": "micros" } }, "ms": { "type": "long", "meta": { "unit": "ms" } }, "second": { "type": "long", "meta": { "unit": "s" } }, "minute": { "type": "long", "meta": { "unit": "m" } }, "hour": { "type": "long", "meta": { "unit": "h" } }, "day": { "type": "long", "meta": { "unit": "d" } }, "percent": { "type": "long", "meta": { "unit": "percent" } }, "bytes": { "type": "long", "meta": { "unit": "byte" } } } } POST my-index-000001/_doc { "nanos" : 1234.5, "micros" : 1234.5, "ms" : 1234.5, "second" : 1234.5, "minute" : 1234.5, "hour" : 1234.5, "day" : 1234.5, "percent" : 1234.5, "bytes" : 1234.5 } ```
…stic#174973) ## Summary Default field formatters based on field meta units data. Note: the smallest unit our formatter will show is milliseconds which means micro and nanoseconds may round down to zero for smaller values. elastic#176112 Closes: elastic#82318 Mapping and doc setup for testing - ``` PUT my-index-000001 PUT my-index-000001/_mapping { "properties": { "nanos": { "type": "long", "meta": { "unit": "nanos" } }, "micros": { "type": "long", "meta": { "unit": "micros" } }, "ms": { "type": "long", "meta": { "unit": "ms" } }, "second": { "type": "long", "meta": { "unit": "s" } }, "minute": { "type": "long", "meta": { "unit": "m" } }, "hour": { "type": "long", "meta": { "unit": "h" } }, "day": { "type": "long", "meta": { "unit": "d" } }, "percent": { "type": "long", "meta": { "unit": "percent" } }, "bytes": { "type": "long", "meta": { "unit": "byte" } } } } POST my-index-000001/_doc { "nanos" : 1234.5, "micros" : 1234.5, "ms" : 1234.5, "second" : 1234.5, "minute" : 1234.5, "hour" : 1234.5, "day" : 1234.5, "percent" : 1234.5, "bytes" : 1234.5 } ```
…6857) ## Summary Adds note to the [Format data fields](https://www.elastic.co/guide/en/kibana/current/managing-data-views.html#managing-fields) section that default formatters use the [`meta.unit` field](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-field-meta.html) for displaying time units, bytes, and percentages.  Relates to: #174973
…stic#174973) ## Summary Default field formatters based on field meta units data. Note: the smallest unit our formatter will show is milliseconds which means micro and nanoseconds may round down to zero for smaller values. elastic#176112 Closes: elastic#82318 Mapping and doc setup for testing - ``` PUT my-index-000001 PUT my-index-000001/_mapping { "properties": { "nanos": { "type": "long", "meta": { "unit": "nanos" } }, "micros": { "type": "long", "meta": { "unit": "micros" } }, "ms": { "type": "long", "meta": { "unit": "ms" } }, "second": { "type": "long", "meta": { "unit": "s" } }, "minute": { "type": "long", "meta": { "unit": "m" } }, "hour": { "type": "long", "meta": { "unit": "h" } }, "day": { "type": "long", "meta": { "unit": "d" } }, "percent": { "type": "long", "meta": { "unit": "percent" } }, "bytes": { "type": "long", "meta": { "unit": "byte" } } } } POST my-index-000001/_doc { "nanos" : 1234.5, "micros" : 1234.5, "ms" : 1234.5, "second" : 1234.5, "minute" : 1234.5, "hour" : 1234.5, "day" : 1234.5, "percent" : 1234.5, "bytes" : 1234.5 } ```
…stic#176857) ## Summary Adds note to the [Format data fields](https://www.elastic.co/guide/en/kibana/current/managing-data-views.html#managing-fields) section that default formatters use the [`meta.unit` field](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-field-meta.html) for displaying time units, bytes, and percentages.  Relates to: elastic#174973
Summary
Default field formatters based on field meta units data.
Note: the smallest unit our formatter will show is milliseconds which means micro and nanoseconds may round down to zero for smaller values. #176112
Closes: #82318
Mapping and doc setup for testing -