Skip to content

[data views] Default field formatters based on field meta values#174973

Merged
mattkime merged 18 commits intoelastic:mainfrom
mattkime:field_caps_meta_fields
Feb 6, 2024
Merged

[data views] Default field formatters based on field meta values#174973
mattkime merged 18 commits intoelastic:mainfrom
mattkime:field_caps_meta_fields

Conversation

@mattkime
Copy link
Contributor

@mattkime mattkime commented Jan 16, 2024

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 -

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
}

@mattkime mattkime changed the title partial progress field caps meta content Jan 16, 2024
@mattkime mattkime added Feature:Data Views Data Views code and UI - index patterns before 8.0 Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// labels Feb 2, 2024
@mattkime mattkime self-assigned this Feb 2, 2024
@mattkime mattkime changed the title field caps meta content [data views] Default feild formatters based on field meta values Feb 2, 2024
@mattkime mattkime changed the title [data views] Default feild formatters based on field meta values [data views] Default field formatters based on field meta values Feb 2, 2024
Comment on lines +27 to +28
// need to consider if we want this, 1 microsecond will display as 0.001ms
micros: timeUnitToDurationFmt('microseconds'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you want nanosecond values to display as millisecond even if nanosecond values less than 10,000 are displayed as 0.00 ms?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thats correct. I'll restore the formatter

@mattkime mattkime marked this pull request as ready for review February 6, 2024 18:36
@mattkime mattkime requested a review from a team as a code owner February 6, 2024 18:36
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@mattkime mattkime added the release_note:skip Skip the PR/issue when compiling release notes label Feb 6, 2024
Copy link
Member

@felixbarny felixbarny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question on the test case, otherwise LGTM.

@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dataViews 53 54 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
data 2583 2585 +2
dataViews 273 276 +3
total +5

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
dataViews 48.4KB 48.9KB +584.0B
Unknown metric groups

API count

id before after diff
data 3235 3237 +2
dataViews 940 943 +3
total +5

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @mattkime

Copy link
Contributor

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mattkime
Copy link
Contributor Author

mattkime commented Feb 6, 2024

@lukasolson I think I'll do docs as a follow up so this can get merged for the current release.

@mattkime mattkime merged commit cde8f2b into elastic:main Feb 6, 2024
@kibanamachine kibanamachine added v8.13.0 backport:skip This PR does not require backporting labels Feb 6, 2024
jloleysens added a commit that referenced this pull request Feb 7, 2024
* 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)
  ...
fkanout pushed a commit to fkanout/kibana that referenced this pull request Feb 7, 2024
…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
}

```
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
…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
}

```
amyjtechwriter added a commit that referenced this pull request Feb 19, 2024
fkanout pushed a commit to fkanout/kibana that referenced this pull request Mar 4, 2024
…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
}

```
fkanout pushed a commit to fkanout/kibana that referenced this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:FieldFormatters release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.13.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Index patterns] Store field-specific metadata from mappings

6 participants