Is there a way to specify a default value for a value interpolation in the metricbeat configuration.
For example:
modules.autodiscover:
providers:
# prometheus resource auto discovery
- type: kubernetes
cleanup_timeout: 0
include_annotations:
- "prometheus.io.scrape"
- "prometheus.io.port"
- "prometheus.io.path"
- "prometheus.io/scrape_interval"
templates:
- condition:
equals:
kubernetes.annotations.prometheus.io.scrape: "true"
config:
- module: prometheus
period: 10s
# period: ${data.kubernetes.annotations.prometheus.io/scrape_interval}
metricsets: ["collector"]
hosts: ["${data.host}:${data.kubernetes.annotations.prometheus.io/port}"]
metrics_path: "${data.kubernetes.annotations.prometheus.io/path}"
processors:
- add_tags:
tags: ["autodiscover", "prometheus"]
If we look at the value for the period
we'd like to be able to use the value provide IF it exists, and default to 10 seconds if it did not exist and similary for the metrics_path
value.
I'd also be happy if this could be done using the conditions and implement a permutation of configurations to deal with the various cases that it could be.
ie. metrics_path: "{{ default '/metrics' data.kubernetes.annotations.prometheus.io/path }}"
if using something like a golang template string.