You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/09-object-types.md
+64-4Lines changed: 64 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1246,9 +1246,6 @@ you can specify the certificates with the `ca_path`, `cert_path` and `cert_key`
1246
1246
Writes check result metrics and performance data to an Elasticsearch timeseries datastream.
1247
1247
This configuration object is available as the [elasticsearch datastream feature](14-features.md#elasticsearchdatastream-writer).
1248
1248
1249
-
> **Note:**
1250
-
>
1251
-
> This feature is experimental right now and behind a compilation flag.
1252
1249
1253
1250
Example:
1254
1251
@@ -1302,9 +1299,72 @@ Changing the behavior of the writer:
1302
1299
host\_tags\_template | Array | **Optional.** Allows add [tags](https://www.elastic.co/docs/reference/ecs/ecs-base#field-tags) to the document for a Host check result.
1303
1300
service\_tags\_template | Array | **Optional.** Allows add [tags](https://www.elastic.co/docs/reference/ecs/ecs-base#field-tags) to the document for a Service check result.
1304
1301
host\_labels\_template | Dictionary | **Optional.** Allows add [labels](https://www.elastic.co/docs/reference/ecs/ecs-base#field-labels) to the document for a Host check result.
1305
-
service\_labels\_template | Array | **Optional.** Allows add [labels](https://www.elastic.co/docs/reference/ecs/ecs-base#field-labels) to the document for a Service check result.
1302
+
service\_labels\_template | Dictionary | **Optional.** Allows add [labels](https://www.elastic.co/docs/reference/ecs/ecs-base#field-labels) to the document for a Service check result.
1306
1303
filter | Function | **Optional.** An expression to filter which check results should be sent to Elasticsearch. Defaults to sending all check results.
1307
1304
1305
+
#### Macro Usage (Tags, Labels & Namespace)
1306
+
1307
+
Macros can be used inside the following template attributes:
1308
+
1309
+
- host_tags_template (array of strings)
1310
+
- service_tags_template (array of strings)
1311
+
- host_labels_template (dictionary of key -> string value)
1312
+
- service_labels_template (dictionary of key -> string value)
1313
+
- datastream_namespace (string)
1314
+
1315
+
Behavior:
1316
+
- Tags: Each array element may contain zero or more macros. If at least one macro is missing/unresolvable, the entire tag element is skipped and a debug log entry is written.
1317
+
- Labels: Each dictionary value may contain macros. If at least one macro inside the value is missing, that label key/value pair is skipped and a debug log entry is written.
1318
+
- Namespace: The datastream_namespace string may contain macros. If a macro is missing or resolves to an empty value, the writer falls back to the default namespace "default".
1319
+
- Validation: A template string with an unterminated '$' (e.g. "$host.name") raises a configuration validation error referencing the original string.
1320
+
- Macros never partially substitute: either all macros in the string resolve and the rendered value is used, or (for tags/labels) the entry is skipped.
1321
+
- Normalization: Performance data metric labels and the resolved datastream namespace undergo normalization: any leading whitespace and leading special characters are trimmed; all remaining special (non-alphanumeric) characters are replaced with an underscore; consecutive underscores are collapsed; leading/trailing underscores are removed. This ensures stable, Elasticsearch-friendly field and namespace names.
datastream_namespace = "$host.vars.env$" // Falls back to "default" if $host.vars.env$ is missing
1328
+
1329
+
host_tags_template = [
1330
+
"env-$host.vars.env$",
1331
+
"$host.name$"
1332
+
]
1333
+
1334
+
service_tags_template = [
1335
+
"svc-$service.name$",
1336
+
"$service.display_name$"
1337
+
]
1338
+
1339
+
host_labels_template = {
1340
+
os = "$host.vars.os$"
1341
+
fqdn = "$host.name$"
1342
+
}
1343
+
1344
+
service_labels_template = {
1345
+
check_cmd = "$service.check_command$"
1346
+
attempted_env = "$host.vars.missing_env$" // Skipped if missing_env not set
1347
+
}
1348
+
1349
+
filter = {{ service && "production" in host.groups }}
1350
+
}
1351
+
```
1352
+
1353
+
A missing macro example for a host check result:
1354
+
- service_tags_template element "svc-$service.name$" is skipped (service not in scope).
1355
+
- service_labels_template value "$service.check_command$" is skipped for host check results.
1356
+
1357
+
#### Filter Expression
1358
+
1359
+
The filter accepts an expression (function literal) and only the variables host and service are available. (service is null / undefined for host check results.)
1360
+
1361
+
Examples:
1362
+
```
1363
+
filter = {{ "production" in host.groups }}
1364
+
filter = {{ service && "linux" in host.groups }}
1365
+
```
1366
+
If the filter returns true, the check result is sent; otherwise it is skipped.
0 commit comments