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

Parameter to round date histograms up instead of rounding down, to support a right-aligned histogram #69078

Closed
wylieconlon opened this issue Feb 16, 2021 · 4 comments
Labels
:Analytics/Aggregations Aggregations >enhancement feedback_needed Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@wylieconlon
Copy link

I couldn't find any previous issues in Elasticsearch, but it's been a long-standing open issue in Kibana to allow "align to now" instead of "align to round intervals". I appreciate that we documented the rounding last year.

The requirement is that instead of rounding based on the Epoch time, we should allow the user to provide a fixed time to round from. For example:

POST /sales/_search?size=0
{
  "aggs": {
    "sales_over_time": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "1h",
        "rounding": {
          "mode": "down",
          "from": "now"
        }
      }
    }
  }
}

So instead of generating buckets at the beginning of each hour, it would generate buckets that align with the time of the request.

@wylieconlon wylieconlon added >enhancement :Analytics/Aggregations Aggregations Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) needs:triage Requires assignment of a team area label labels Feb 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@jimczi
Copy link
Contributor

jimczi commented Feb 17, 2021

That looks like something that you could implement client-side with the offset parameter of the date_histogram:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html#search-aggregations-bucket-datehistogram-offset ?

@jtibshirani jtibshirani removed the needs:triage Requires assignment of a team area label label Feb 19, 2021
@imotov
Copy link
Contributor

imotov commented Mar 9, 2021

@wylieconlon does this work for you? Should we close this issue or you want to continue?

@wylieconlon
Copy link
Author

@imotov Yes, I think this workaround works now that Kibana does datemath conversion in the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >enhancement feedback_needed Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

5 participants