Skip to content

Commit 267d5a8

Browse files
authored
Aligned data pulls to calendar days (#13020)
* Aligned data pulls to calendar days * Added changelog entry * Fixed type conversion
1 parent 8cba01a commit 267d5a8

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

packages/ess_billing/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.3.0"
3+
changes:
4+
- description: Aligned billing data pulls to calendar days
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/13020
27
- version: "1.2.0"
38
changes:
49
- description: Added Agentless deployment mode

packages/ess_billing/data_stream/billing/agent/stream/cel.yml.hbs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@ resource.timeout: {{http_client_timeout}}
1616
resource.url: {{url}}/api/v2/billing/organizations/{{organization_id}}/costs/instances
1717
state:
1818
api_key: {{api_key}}
19-
organization_id: "{{organization_id}}"
20-
lookbehind: "{{lookbehind}}h"
19+
organization_id: {{organization_id}}
20+
lookbehind: {{lookbehind}}
2121
redact:
2222
fields:
2323
- api_key
2424
program: |
2525
state.with({
26-
"from": has(state.?cursor.last_to) ?
26+
"from": (has(state.?cursor.last_to) ?
2727
timestamp(state.cursor.last_to)
2828
:
29-
(now().format(time_layout.DateOnly).parse_time(time_layout.DateOnly) - duration(state.lookbehind)),
30-
"to": has(state.?cursor.last_to) ?
29+
(now() - duration(string(int(state.lookbehind)*24) + "h"))
30+
).format(time_layout.DateOnly).parse_time(time_layout.DateOnly),
31+
"to": (has(state.?cursor.last_to) ?
3132
(timestamp(state.cursor.last_to) + duration("24h"))
3233
:
33-
(now().format(time_layout.DateOnly).parse_time(time_layout.DateOnly) - duration(state.lookbehind) + duration("24h")),
34+
(now() - duration(string(int(state.lookbehind)*24) + "h") + duration("24h"))
35+
).format(time_layout.DateOnly).parse_time(time_layout.DateOnly),
3436
}.as(req, (req.to > now()) ?
3537
// We would fetch data in the future, back off
3638
{

packages/ess_billing/data_stream/billing/manifest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ streams:
1313
- name: lookbehind
1414
type: integer
1515
title: Lookbehind
16-
description: How far back to fetch data for the first run (in hours), default to 8760 hours (1 year).
17-
default: 8760
16+
description: How far back to fetch data for the first run (in days), default to 1 year.
17+
default: 365
1818
multi: false
1919
required: true
2020
show_user: true

packages/ess_billing/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: 3.3.2
22
name: ess_billing
33
title: "Elasticsearch Service Billing"
4-
version: 1.2.0
4+
version: 1.3.0
55
source:
66
license: "Elastic-2.0"
77
description: "Collects billing metrics from Elasticsearch Service billing API"

0 commit comments

Comments
 (0)