Skip to content

Incorrect rate agg with custom _doc_count #77734

@sorenlouv

Description

@sorenlouv

Versions affected: 7.15 and up

I'm seeing some odd results with the rate agg on documents that have a custom _doc_count and wondering if it's a bug, similar to #74617.

Reproduce problem

PUT rate-bug

POST rate-bug/_doc
{
  "_doc_count": 10,
  "@timestamp": "2021-09-14T22:33:37.477Z"
}

GET rate-bug/_search
{
  "size": 0,
  "aggs": {
    "timeseries": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "60s"
      },
      "aggs": {
        "throughput": {
          "rate": {
            "unit": "minute"
          }
        }
      }
    }
  }
}

Response
The search request will return:

{
  "aggregations" : {
    "timeseries" : {
      "buckets" : [
        {
          "key_as_string" : "2021-09-14T22:33:00.000Z",
          "key" : 1631658780000,
          "doc_count" : 10,
          "throughput" : {
            "value" : 1.0
          }
        }
      ]
    }
  }
}

Expectation
I'd expect that a bucket for 1 minute with 10 documents should have a rate of 10.

Actual
Rate is 1.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions