-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Telemetry option disable_hostname always true when only one sink is used #31747
Description
Describe the bug
If disable_hostname is set to false in the telemetry configuration and only a single sink is configured (for example, Prometheus), metric names do not include the hostname prefix.
If enable_hostname_label is set to true, the host label containing the hostname appears in the metrics.
This behavior differs from what is described in the documentation.
To Reproduce
Steps to reproduce the behavior:
- Run vault with
telemetry.disable_hostname=falsein configuration - Get prometheus metrics from
http://localhost:8200/v1/sys/metrics?format=prometheus - Observe that metric names do not contain a hostname prefix, even though telemetry.disable_hostname is set to false.
Expected behavior
The presence of a hostname prefix in metric names when the telemetry.disable_hostname option is set to false.
Environment:
- Vault Server Version (retrieve with
vault status): 1.21.2 - Vault CLI Version (retrieve with
vault version): 1.21.2 - Server Operating System/Architecture: Ubuntu 24.04 x86_64
Vault server configuration file(s):
api_addr = "http://localhost:8200"
storage "file" {
path = "/vault/data"
}
listener "tcp" {
address = "0.0.0.0:8200"
tls_disable = 1
telemetry {
unauthenticated_metrics_access = true
}
}
telemetry {
disable_hostname = false
}
disable_mlock = trueAdditional context
Most likely, the issue is related to this part of the code. If the number of configured sinks is less than 2, EnableHostname is set to false, which is equivalent to the behavior when telemetry.disable_hostname=true is set in the configuration.
Either the condition needs to be changed to > 0, or this code should be moved slightly lower, after the inm is added to the fanout.