Skip to content

Commit e2d466b

Browse files
authored
Add Serverless compatibility (elastic#15003)
* Added a deployment_type parameter (values: deployment, elasticsearch, observability, security). * Added dedicated dashboards for ECH and serverless consumption breakdown
1 parent 789f3d8 commit e2d466b

File tree

10 files changed

+1303
-312
lines changed

10 files changed

+1303
-312
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.5.0"
3+
changes:
4+
- description: Add Serverless compatibility
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/15003
27
- version: "1.4.4"
38
changes:
49
- description: Removed empty ess.billing.quantities field from billing data output.

packages/ess_billing/data_stream/billing/_dev/test/pipeline/test-billing.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"billing": {
2727
"deployment_id": "4679751e171d403d8603cb1639b67e57",
2828
"deployment_name": "example-deployment",
29+
"deployment_type": "deployment",
2930
"display_quantity": {
3031
"formatted_value": "24 hours",
3132
"type": "default",
@@ -61,6 +62,69 @@
6162
"forwarded",
6263
"billing"
6364
]
65+
},
66+
{
67+
"@timestamp": "2025-08-20T14:08:02.403Z",
68+
"agent": {
69+
"ephemeral_id": "082a402e-e376-4e6a-8ae4-9fcd12471589",
70+
"id": "e4875ac3-72d6-4ad5-87bc-1e0030128d0a",
71+
"name": "elastic-agent-89987",
72+
"type": "filebeat",
73+
"version": "9.0.4"
74+
},
75+
"data_stream": {
76+
"dataset": "ess_billing.billing",
77+
"namespace": "68465",
78+
"type": "metrics"
79+
},
80+
"ecs": {
81+
"version": "8.0.0"
82+
},
83+
"elastic_agent": {
84+
"id": "e4875ac3-72d6-4ad5-87bc-1e0030128d0a",
85+
"snapshot": false,
86+
"version": "9.0.4"
87+
},
88+
"ess": {
89+
"billing": {
90+
"deployment_id": "b7ffa6ecae534f81a2778ca1ce685254",
91+
"deployment_name": "example-serverless",
92+
"deployment_type": "observability",
93+
"display_quantity": {
94+
"value": 0.0055175,
95+
"formatted_value": "0.0055 GBs",
96+
"type": "default"
97+
},
98+
"from": "2025-08-19T00:00:00Z",
99+
"kind": "",
100+
"organization_id": "1111",
101+
"quantities": [],
102+
"quantity": {
103+
"value": 0.0055175,
104+
"formatted_value": "0.0055 GBs"
105+
},
106+
"rate": {
107+
"value": 0.0,
108+
"formatted_value": "0.0000 per GB"
109+
},
110+
"name": "Serverless Data Out",
111+
"total_ecu": 0.0,
112+
"type": "data transfer",
113+
"sku": "serverless.data-out",
114+
"to": "2025-08-20T00:00:00Z",
115+
"unit": "GB"
116+
}
117+
},
118+
"event": {
119+
"dataset": "ess_billing.billing"
120+
},
121+
"input": {
122+
"type": "cel"
123+
},
124+
"tags": [
125+
"forwarded",
126+
"billing"
127+
]
64128
}
65129
]
66130
}

packages/ess_billing/data_stream/billing/_dev/test/pipeline/test-billing.json-expected.json

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"billing": {
4848
"deployment_id": "4679751e171d403d8603cb1639b67e57",
4949
"deployment_name": "example-deployment",
50+
"deployment_type": "deployment",
5051
"display_quantity": {
5152
"formatted_value": "24 hours",
5253
"type": "default",
@@ -83,6 +84,88 @@
8384
"tags": [
8485
"preserve_original_event"
8586
]
87+
},
88+
{
89+
"@timestamp": "2025-08-19T00:00:00.000Z",
90+
"agent": {
91+
"ephemeral_id": "082a402e-e376-4e6a-8ae4-9fcd12471589",
92+
"id": "e4875ac3-72d6-4ad5-87bc-1e0030128d0a",
93+
"name": "elastic-agent-89987",
94+
"type": "filebeat",
95+
"version": "9.0.4"
96+
},
97+
"cloud": {
98+
"account": {
99+
"id": "1111"
100+
},
101+
"geo": {
102+
"location": {
103+
"lat": 90,
104+
"lon": 135
105+
},
106+
"name": "unknown"
107+
},
108+
"instance": {
109+
"id": "b7ffa6ecae534f81a2778ca1ce685254",
110+
"name": "example-serverless"
111+
},
112+
"provider": "serverless",
113+
"service": {
114+
"type": "data-out"
115+
}
116+
},
117+
"data_stream": {
118+
"dataset": "ess_billing.billing",
119+
"namespace": "68465",
120+
"type": "metrics"
121+
},
122+
"ecs": {
123+
"version": "8.0.0"
124+
},
125+
"elastic_agent": {
126+
"id": "e4875ac3-72d6-4ad5-87bc-1e0030128d0a",
127+
"snapshot": false,
128+
"version": "9.0.4"
129+
},
130+
"ess": {
131+
"billing": {
132+
"deployment_id": "b7ffa6ecae534f81a2778ca1ce685254",
133+
"deployment_name": "example-serverless",
134+
"deployment_type": "observability",
135+
"display_quantity": {
136+
"formatted_value": "0.0055 GBs",
137+
"type": "default",
138+
"value": 0.0055175
139+
},
140+
"from": "2025-08-19T00:00:00Z",
141+
"kind": "",
142+
"name": "Serverless Data Out",
143+
"organization_id": "1111",
144+
"quantity": {
145+
"formatted_value": "0.0055 GBs",
146+
"value": 0.0055175
147+
},
148+
"rate": {
149+
"formatted_value": "0.0000 per GB",
150+
"value": 0.0
151+
},
152+
"sku": "serverless.data-out",
153+
"to": "2025-08-20T00:00:00Z",
154+
"total_ecu": 0.0,
155+
"type": "data transfer",
156+
"unit": "GB"
157+
}
158+
},
159+
"event": {
160+
"created": "2021-11-11T01:02:03.123456789Z",
161+
"dataset": "ess_billing.billing"
162+
},
163+
"input": {
164+
"type": "cel"
165+
},
166+
"tags": [
167+
"preserve_original_event"
168+
]
86169
}
87170
]
88171
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
config_version: 2
22
interval: "24h"
33
{{#if enable_request_tracer}}
4-
resource.tracer.filename: "../../logs/cel/http-request-trace-*.ndjson"
4+
resource.tracer.filename: "/run/service_logs/http-request-trace-*.ndjson"
55
resource.tracer.maxbackups: 5
66
{{/if}}
77
{{#if proxy_url}}
@@ -70,11 +70,13 @@ program: |-
7070
"ess": {
7171
"billing": line_item.with(
7272
{
73-
"deployment_name": instance.name, // Include deployment name
74-
"deployment_id": instance.id, // Include deployment ID
75-
"organization_id": state.organization_id, // Include organization ID
73+
"deployment_name": instance.name, // Include deployment name
74+
"deployment_id": instance.id, // Include deployment ID
75+
"deployment_type": instance.type, // Include deployment type
76+
"organization_id": state.organization_id, // Include organization ID
7677
"from": req.from.format(time_layout.RFC3339),
7778
"to": req.to.format(time_layout.RFC3339),
79+
"quantities": null // overwrite useless quantities to avoid flatten failure
7880
}
7981
),
8082
},

packages/ess_billing/data_stream/billing/elasticsearch/ingest_pipeline/default.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,49 @@ processors:
5454
copy_from: ess.billing.deployment_id
5555
ignore_empty_value: true
5656
tag: cloud_instance_id
57+
- set:
58+
# NOTE(2025-08-25): This 'set' processor is necessary to cope with serverless
59+
# project names being empty in the billing API. to be removed when Names in billing api fixed
60+
field: cloud.instance.name
61+
copy_from: ess.billing.deployment_id
5762
- set:
5863
field: cloud.instance.name
5964
copy_from: ess.billing.deployment_name
6065
ignore_empty_value: true
6166
tag: cloud_instance_name
67+
# =====GROK SECTION=====
68+
# Retrieving billed cloud service details like flavors and regions
69+
#
70+
# These 2 processors are specific to ECH sku's
6271
- grok:
6372
field: "ess.billing.sku"
6473
patterns:
6574
- "(?:Cloud-Enterprise_)?%{CLOUD_PROVIDER:cloud.provider}\\.%{NOTSPACE:cloud.machine.type}_%{NOTSPACE:cloud.region}_%{NUMBER:ess.billing.ram_per_zone:int}_%{NUMBER:ess.billing.zone_count:int}"
6675
pattern_definitions:
6776
CLOUD_PROVIDER: "aws|gcp|azure|global"
68-
if: "ctx.ess.billing.type == 'capacity'"
77+
if: "ctx.ess.billing.type == 'capacity' && ctx.ess.billing.deployment_type == 'deployment'"
6978
ignore_failure: true
7079
tag: grok_sku
7180
- dissect:
7281
field: "ess.billing.sku"
7382
pattern: "%{cloud.provider}.%{}"
74-
if: "ctx.ess.billing.type != 'capacity'"
83+
if: "ctx.ess.billing.type != 'capacity' && ctx.ess.billing.deployment_type == 'deployment'"
7584
ignore_failure: true
7685
tag: dissect_sku
86+
87+
# These 2 processors are specific to serverless sku's
88+
- grok:
89+
field: "ess.billing.sku"
90+
patterns:
91+
- "%{DATA}\\.(?<cloud.service.type>[^_]+)(?:_(?<cloud.region>.+))?"
92+
if: "ctx.ess.billing.deployment_type != 'deployment'"
93+
ignore_failure: true
94+
tag: grok_sku
95+
- set:
96+
field: "cloud.provider"
97+
if: "ctx.ess.billing.deployment_type != 'deployment'"
98+
value: "serverless"
99+
# =====GROK SECTION END=====
77100
- convert:
78101
field: ess.billing.ram_per_zone
79102
type: "integer"
@@ -114,6 +137,7 @@ processors:
114137
'gcp-europe-west9': ['location': ['lon': 4.9041, 'lat': 52.3676], 'name': 'gcp-europe-west9'],
115138
'gcp-me-west1': ['location': ['lon': 34.8516, 'lat': 31.0461], 'name': 'gcp-me-west1'],
116139
'aws-us-east-2': ['location': ['lon': -82.9988, 'lat': 39.9612], 'name': 'aws-us-east-2'],
140+
'aws-us-east-1': ['location': ['lon': -77.0369, 'lat': 39.9612], 'name': 'aws-us-east-2'],
117141
'us-east-1': ['location': ['lon': -77.0369, 'lat': 38.9072], 'name': 'us-east-1'],
118142
'eu-west-1': ['location': ['lon': -6.2603, 'lat': 53.3498], 'name': 'eu-west-1'],
119143
'us-west-1': ['location': ['lon': -122.4194, 'lat': 37.7749], 'name': 'us-west-1'],

packages/ess_billing/data_stream/billing/fields/fields.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99
- name: cloud.machine.type
1010
type: keyword
1111
description: The machine type of the instance (e.g., n2.68x16x45).
12+
- name: cloud.service.type
13+
type: keyword
14+
description: The service type of the serverless project.
1215
- name: deployment_id
1316
type: keyword
1417
description: ID of the Elasticsearch Service deployment.
1518
- name: deployment_name
1619
type: keyword
1720
description: Name of the Elasticsearch Service deployment.
21+
- name: deployment_type
22+
type: keyword
23+
description: Type of the Elasticsearch Service deployment.
1824
- name: display_quantity.formatted_value
1925
type: keyword
2026
description: Human-readable representation of the quantity used (e.g., "24 hours").

packages/ess_billing/docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ An example event for `billing` looks as following:
140140
| data_stream.namespace | Data stream namespace. | constant_keyword |
141141
| data_stream.type | Data stream type. | constant_keyword |
142142
| ess.billing.cloud.machine.type | The machine type of the instance (e.g., n2.68x16x45). | keyword |
143+
| ess.billing.cloud.service.type | The service type of the serverless project. | keyword |
143144
| ess.billing.deployment_id | ID of the Elasticsearch Service deployment. | keyword |
144145
| ess.billing.deployment_name | Name of the Elasticsearch Service deployment. | keyword |
146+
| ess.billing.deployment_type | Type of the Elasticsearch Service deployment. | keyword |
145147
| ess.billing.display_quantity.formatted_value | Human-readable representation of the quantity used (e.g., "24 hours"). | keyword |
146148
| ess.billing.display_quantity.type | Type of quantity displayed (default or custom). | keyword |
147149
| ess.billing.display_quantity.value | Actual quantity used (e.g., 24). | float |

0 commit comments

Comments
 (0)