Skip to content
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

Add support for aggregate_metric_double field type #500

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Apr 12, 2023

What does this PR do?

It adds support for the aggregate_metric_double field type.

Why is it important?

This field type is used in TSDB use cases.

Checklist

Related issues

@jsoriano jsoriano requested a review from a team as a code owner April 12, 2023 19:09
@jsoriano jsoriano self-assigned this Apr 12, 2023
@elasticmachine
Copy link

elasticmachine commented Apr 12, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-04-17T15:15:53.902+0000

  • Duration: 9 min 31 sec

Test stats 🧪

Test Results
Failed 0
Passed 758
Skipped 0
Total 758

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (8/8) 💚
Files 70.37% (19/27) 👍
Classes 77.778% (28/36) 👍
Methods 55.172% (64/116) 👍
Lines 42.479% (593/1396) 👍 0.041
Conditionals 100.0% (0/0) 💚

kpollich
kpollich previously approved these changes Apr 17, 2023
Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

`field 1: default_metric is required`,
`field 2.metrics.2: 2.metrics.2 must be one of the following: "min", "max", "sum", "value_count", "avg"`,
`field 3: Must not be present`,
`field 3: Must not be present`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shame we don't report the field name with this error, but I remember that wasn't trivial.

Copy link
Member Author

@jsoriano jsoriano Apr 17, 2023

Choose a reason for hiding this comment

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

Yep, I tried some things, but I didn't manage to do it. Maybe we can do it directly in the underlying library, we already have it forked in https://github.com/elastic/gojsonschema.

type:
const: aggregate_metric_double
required:
- type
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this add?

required:
  - type

Copy link
Member Author

Choose a reason for hiding this comment

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

It avoids the condition to match when the type is not defined, what happens with external fields. Like this one:

- name: "@timestamp"
  external: ecs

required:
- default_metric
properties:
default_metric:
Copy link
Contributor

Choose a reason for hiding this comment

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

type: string is not needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

type: string is defined in the referenced definition.

Copy link
Contributor

@jillguyonnet jillguyonnet left a comment

Choose a reason for hiding this comment

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

Nice!

@jsoriano jsoriano merged commit d4510a9 into elastic:main Apr 17, 2023
@jsoriano jsoriano deleted the aggregate-metric-double branch April 17, 2023 16:20
jsoriano added a commit to elastic/kibana that referenced this pull request Apr 17, 2023
## Summary

Add support for fields of type `aggregate_metric_double` in EPM.

Change in package spec introduced in
elastic/package-spec#500.

Fixes #154867
Closes elastic/package-spec#457

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios.

### How to test

* Modify a package to include a field with type
`aggregate_metric_double`, for example like this:
```
    - name: some_metric
      type: aggregate_metric_double
      metrics: [ "min", "max", "sum", "value_count" ]
      default_metric: "max"
```
* Install elastic package with this branch of the package-spec included:
elastic/package-spec#500, for this, from an
elastic-package working directory:
* `go mod edit -replace
github.com/elastic/package-spec/v2=github.com/elastic/package-spec@main`
  * `go mod tidy`
  * `make install`
* Build the package with `elastic-package build -v`.
* Install the package with `elastic-package install -v`.
* Check that the template contains the expected field.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
nikitaindik pushed a commit to nikitaindik/kibana that referenced this pull request Apr 18, 2023
…ic#154920)

## Summary

Add support for fields of type `aggregate_metric_double` in EPM.

Change in package spec introduced in
elastic/package-spec#500.

Fixes elastic#154867
Closes elastic/package-spec#457

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios.

### How to test

* Modify a package to include a field with type
`aggregate_metric_double`, for example like this:
```
    - name: some_metric
      type: aggregate_metric_double
      metrics: [ "min", "max", "sum", "value_count" ]
      default_metric: "max"
```
* Install elastic package with this branch of the package-spec included:
elastic/package-spec#500, for this, from an
elastic-package working directory:
* `go mod edit -replace
github.com/elastic/package-spec/v2=github.com/elastic/package-spec@main`
  * `go mod tidy`
  * `make install`
* Build the package with `elastic-package build -v`.
* Install the package with `elastic-package install -v`.
* Check that the template contains the expected field.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
saarikabhasi pushed a commit to saarikabhasi/kibana that referenced this pull request Apr 19, 2023
…ic#154920)

## Summary

Add support for fields of type `aggregate_metric_double` in EPM.

Change in package spec introduced in
elastic/package-spec#500.

Fixes elastic#154867
Closes elastic/package-spec#457

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios.

### How to test

* Modify a package to include a field with type
`aggregate_metric_double`, for example like this:
```
    - name: some_metric
      type: aggregate_metric_double
      metrics: [ "min", "max", "sum", "value_count" ]
      default_metric: "max"
```
* Install elastic package with this branch of the package-spec included:
elastic/package-spec#500, for this, from an
elastic-package working directory:
* `go mod edit -replace
github.com/elastic/package-spec/v2=github.com/elastic/package-spec@main`
  * `go mod tidy`
  * `make install`
* Build the package with `elastic-package build -v`.
* Install the package with `elastic-package install -v`.
* Check that the template contains the expected field.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants