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

[aggregations] add API support for rate aggregation #131386

Closed
ppisljar opened this issue May 3, 2022 · 2 comments · Fixed by #143487
Closed

[aggregations] add API support for rate aggregation #131386

ppisljar opened this issue May 3, 2022 · 2 comments · Fixed by #143487
Labels
Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@ppisljar
Copy link
Member

ppisljar commented May 3, 2022

add support for elasticsearch rate aggregation https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-rate-aggregation.html

@ppisljar ppisljar added Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Team:AppServicesSv labels May 3, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServicesSv)

@exalate-issue-sync exalate-issue-sync bot added impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. loe:medium Medium Level of Effort labels May 3, 2022
@exalate-issue-sync exalate-issue-sync bot added impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. and removed impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. labels Aug 24, 2022
@petrklapka petrklapka added Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed Team:AppServicesSv labels Nov 9, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations)

@timductive timductive changed the title [aggregations] add support for rate aggregation [aggregations] add api support for rate aggregation Nov 18, 2022
@exalate-issue-sync exalate-issue-sync bot changed the title [aggregations] add api support for rate aggregation [aggregations] add API support for rate aggregation Nov 18, 2022
lukasolson added a commit that referenced this issue Dec 15, 2022
## Summary

Resolves #131386.

Adds support for the rate aggregation. Usage may look something like the
following:

```ts
const aggs = [
  {
    type: 'date_histogram',
    params: {
      field: '@timestamp',
      interval: '1h',
    },
  },
  {
    type: 'rate',
    params: {
      field: 'bytes', // optional
      unit: 'hour',
    },
  },
];
const aggsDsl = data.search.aggs.createAggConfigs(dataView, aggs).toDsl();

// Which generates the following DSL:
{
  "1": {
    "date_histogram": {
      "field": "@timestamp",
      "calendar_interval": "1h",
      "time_zone": "America/Phoenix",
      "min_doc_count": 1
    },
    "aggs": {
      "2": {
        "rate": {
          "field": "bytes",
          "unit": "hour"
        }
      }
    }
  }
}
```

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

Co-authored-by: Peter Pisljar <peter.pisljar@elastic.co>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Dec 15, 2022
## Summary

Resolves elastic#131386.

Adds support for the rate aggregation. Usage may look something like the
following:

```ts
const aggs = [
  {
    type: 'date_histogram',
    params: {
      field: '@timestamp',
      interval: '1h',
    },
  },
  {
    type: 'rate',
    params: {
      field: 'bytes', // optional
      unit: 'hour',
    },
  },
];
const aggsDsl = data.search.aggs.createAggConfigs(dataView, aggs).toDsl();

// Which generates the following DSL:
{
  "1": {
    "date_histogram": {
      "field": "@timestamp",
      "calendar_interval": "1h",
      "time_zone": "America/Phoenix",
      "min_doc_count": 1
    },
    "aggs": {
      "2": {
        "rate": {
          "field": "bytes",
          "unit": "hour"
        }
      }
    }
  }
}
```

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

Co-authored-by: Peter Pisljar <peter.pisljar@elastic.co>
(cherry picked from commit 5a6bf1d)
kibanamachine referenced this issue Dec 16, 2022
…147661)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[data.search.aggs] Add support for rate aggregation
(#143487)](#143487)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Lukas
Olson","email":"lukas@elastic.co"},"sourceCommit":{"committedDate":"2022-12-15T23:49:20Z","message":"[data.search.aggs]
Add support for rate aggregation (#143487)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/131386.\r\n\r\nAdds support for
the rate aggregation. Usage may look something like
the\r\nfollowing:\r\n\r\n```ts\r\nconst aggs = [\r\n {\r\n type:
'date_histogram',\r\n params: {\r\n field: '@timestamp',\r\n interval:
'1h',\r\n },\r\n },\r\n {\r\n type: 'rate',\r\n params: {\r\n field:
'bytes', // optional\r\n unit: 'hour',\r\n },\r\n },\r\n];\r\nconst
aggsDsl = data.search.aggs.createAggConfigs(dataView,
aggs).toDsl();\r\n\r\n// Which generates the following DSL:\r\n{\r\n
\"1\": {\r\n \"date_histogram\": {\r\n \"field\": \"@timestamp\",\r\n
\"calendar_interval\": \"1h\",\r\n \"time_zone\":
\"America/Phoenix\",\r\n \"min_doc_count\": 1\r\n },\r\n \"aggs\": {\r\n
\"2\": {\r\n \"rate\": {\r\n \"field\": \"bytes\",\r\n \"unit\":
\"hour\"\r\n }\r\n }\r\n }\r\n }\r\n}\r\n```\r\n\r\n###
Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\nCo-authored-by:
Peter Pisljar
<peter.pisljar@elastic.co>","sha":"5a6bf1dacdb0d0a8969459c761dcdcf7347efb51","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Search","Feature:Aggregations","Team:AppServicesSv","release_note:skip","v8.6.0","v8.7.0"],"number":143487,"url":"https://github.com/elastic/kibana/pull/143487","mergeCommit":{"message":"[data.search.aggs]
Add support for rate aggregation (#143487)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/131386.\r\n\r\nAdds support for
the rate aggregation. Usage may look something like
the\r\nfollowing:\r\n\r\n```ts\r\nconst aggs = [\r\n {\r\n type:
'date_histogram',\r\n params: {\r\n field: '@timestamp',\r\n interval:
'1h',\r\n },\r\n },\r\n {\r\n type: 'rate',\r\n params: {\r\n field:
'bytes', // optional\r\n unit: 'hour',\r\n },\r\n },\r\n];\r\nconst
aggsDsl = data.search.aggs.createAggConfigs(dataView,
aggs).toDsl();\r\n\r\n// Which generates the following DSL:\r\n{\r\n
\"1\": {\r\n \"date_histogram\": {\r\n \"field\": \"@timestamp\",\r\n
\"calendar_interval\": \"1h\",\r\n \"time_zone\":
\"America/Phoenix\",\r\n \"min_doc_count\": 1\r\n },\r\n \"aggs\": {\r\n
\"2\": {\r\n \"rate\": {\r\n \"field\": \"bytes\",\r\n \"unit\":
\"hour\"\r\n }\r\n }\r\n }\r\n }\r\n}\r\n```\r\n\r\n###
Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\nCo-authored-by:
Peter Pisljar
<peter.pisljar@elastic.co>","sha":"5a6bf1dacdb0d0a8969459c761dcdcf7347efb51"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/143487","number":143487,"mergeCommit":{"message":"[data.search.aggs]
Add support for rate aggregation (#143487)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/131386.\r\n\r\nAdds support for
the rate aggregation. Usage may look something like
the\r\nfollowing:\r\n\r\n```ts\r\nconst aggs = [\r\n {\r\n type:
'date_histogram',\r\n params: {\r\n field: '@timestamp',\r\n interval:
'1h',\r\n },\r\n },\r\n {\r\n type: 'rate',\r\n params: {\r\n field:
'bytes', // optional\r\n unit: 'hour',\r\n },\r\n },\r\n];\r\nconst
aggsDsl = data.search.aggs.createAggConfigs(dataView,
aggs).toDsl();\r\n\r\n// Which generates the following DSL:\r\n{\r\n
\"1\": {\r\n \"date_histogram\": {\r\n \"field\": \"@timestamp\",\r\n
\"calendar_interval\": \"1h\",\r\n \"time_zone\":
\"America/Phoenix\",\r\n \"min_doc_count\": 1\r\n },\r\n \"aggs\": {\r\n
\"2\": {\r\n \"rate\": {\r\n \"field\": \"bytes\",\r\n \"unit\":
\"hour\"\r\n }\r\n }\r\n }\r\n }\r\n}\r\n```\r\n\r\n###
Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\nCo-authored-by:
Peter Pisljar
<peter.pisljar@elastic.co>","sha":"5a6bf1dacdb0d0a8969459c761dcdcf7347efb51"}}]}]
BACKPORT-->

Co-authored-by: Lukas Olson <lukas@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants