|
442 | 442 | - close_to: { aggregations.ts.buckets.0.rate-month.value: { value: 63958020.00, error: 0.01 }}
|
443 | 443 | - close_to: { aggregations.ts.buckets.0.rate-quarter.value: { value: 191874060.00, error: 0.01 }}
|
444 | 444 | - close_to: { aggregations.ts.buckets.0.rate-year.value: { value: 767496240.00, error: 0.01 }}
|
| 445 | + |
| 446 | +--- |
| 447 | +"rate aggregation on counter field partial bucket": |
| 448 | + - skip: |
| 449 | + version: " - 8.6.99" |
| 450 | + reason: "counter field support added in 8.7" |
| 451 | + features: close_to |
| 452 | + |
| 453 | + - do: |
| 454 | + indices.create: |
| 455 | + index: test-rate |
| 456 | + body: |
| 457 | + settings: |
| 458 | + index: |
| 459 | + mode: time_series |
| 460 | + routing_path: [ host ] |
| 461 | + time_series: |
| 462 | + start_time: 2021-04-28T00:00:00Z |
| 463 | + end_time: 2021-04-29T00:00:00Z |
| 464 | + mappings: |
| 465 | + properties: |
| 466 | + "@timestamp": |
| 467 | + type: date |
| 468 | + host: |
| 469 | + type: keyword |
| 470 | + time_series_dimension: true |
| 471 | + bytes_counter: |
| 472 | + type: long |
| 473 | + time_series_metric: counter |
| 474 | + |
| 475 | + - do: |
| 476 | + bulk: |
| 477 | + refresh: true |
| 478 | + index: test-rate |
| 479 | + body: |
| 480 | + - '{"index": {}}' |
| 481 | + - '{"@timestamp": "2021-04-28T18:01:04.000Z", "host": "one", "bytes_counter": 1000 }' |
| 482 | + - '{"index": {}}' |
| 483 | + - '{"@timestamp": "2021-04-28T18:01:14.000Z", "host": "one", "bytes_counter": 1100 }' |
| 484 | + - '{"index": {}}' |
| 485 | + - '{"@timestamp": "2021-04-28T18:01:24.000Z", "host": "one", "bytes_counter": 1200 }' |
| 486 | + - '{"index": {}}' |
| 487 | + - '{"@timestamp": "2021-04-28T18:01:34.000Z", "host": "one", "bytes_counter": 1250 }' |
| 488 | + - '{"index": {}}' |
| 489 | + - '{"@timestamp": "2021-04-28T18:01:44.000Z", "host": "one", "bytes_counter": 1310 }' |
| 490 | + - '{"index": {}}' |
| 491 | + - '{"@timestamp": "2021-04-28T18:01:54.000Z", "host": "one", "bytes_counter": 1350 }' |
| 492 | + - '{"index": {}}' |
| 493 | + - '{"@timestamp": "2021-04-28T18:01:01.000Z", "host": "two", "bytes_counter": 1000 }' |
| 494 | + - '{"index": {}}' |
| 495 | + - '{"@timestamp": "2021-04-28T18:01:11.000Z", "host": "two", "bytes_counter": 1100 }' |
| 496 | + - '{"index": {}}' |
| 497 | + - '{"@timestamp": "2021-04-28T18:01:21.000Z", "host": "two", "bytes_counter": 1200 }' |
| 498 | + - '{"index": {}}' |
| 499 | + - '{"@timestamp": "2021-04-28T18:01:31.000Z", "host": "two", "bytes_counter": 1250 }' |
| 500 | + - '{"index": {}}' |
| 501 | + - '{"@timestamp": "2021-04-28T18:01:41.000Z", "host": "two", "bytes_counter": 1310 }' |
| 502 | + - '{"index": {}}' |
| 503 | + - '{"@timestamp": "2021-04-28T18:01:51.000Z", "host": "two", "bytes_counter": 1350 }' |
| 504 | + |
| 505 | + - do: |
| 506 | + search: |
| 507 | + index: test-rate |
| 508 | + body: |
| 509 | + size: 0 |
| 510 | + query: |
| 511 | + bool: |
| 512 | + filter: |
| 513 | + range: |
| 514 | + "@timestamp": |
| 515 | + gte: "2021-04-28T18:01:03.000Z" |
| 516 | + lte: "2021-04-28T18:18:00.000Z" |
| 517 | + aggs: |
| 518 | + date_histogram: |
| 519 | + date_histogram: |
| 520 | + field: "@timestamp" |
| 521 | + calendar_interval: 1h |
| 522 | + time_zone: Europe/Ljubljana |
| 523 | + min_doc_count: 1 |
| 524 | + aggs: |
| 525 | + counter_rate: |
| 526 | + time_series: |
| 527 | + keyed: false |
| 528 | + aggs: |
| 529 | + bytes_counter_rate: |
| 530 | + rate: |
| 531 | + field: bytes_counter |
| 532 | + unit: second |
| 533 | + |
| 534 | + - match: { hits.total.value: 11 } |
| 535 | + - length: { aggregations.date_histogram.buckets: 1 } |
| 536 | + - match: { aggregations.date_histogram.buckets.0.key_as_string: "2021-04-28T20:00:00.000+02:00" } |
| 537 | + - match: { aggregations.date_histogram.buckets.0.doc_count: 11 } |
| 538 | + # NOTE: (1350 - 1000) / (54 - 4) = 350 / 50 = 7.0 |
| 539 | + - close_to: { aggregations.date_histogram.buckets.0.counter_rate.buckets.0.bytes_counter_rate.value: { value: 7.00, error: 0.01 } } |
| 540 | + # NOTE: (1350 - 1100) / (51 - 11) = 250 / 40 = 6.25 (we filter out the first sample due to the bool range filter) |
| 541 | + - close_to: { aggregations.date_histogram.buckets.0.counter_rate.buckets.1.bytes_counter_rate.value: { value: 6.25, error: 0.01 } } |
0 commit comments