Inconsistent handling of Stat Prefix between StatsD sinks and prometheus when a Custom Stat Namespace is registered.
#19.087 geöffnet am 23. Nov. 2021
Repository-Metriken
- Stars
- (27.997 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 8T) (378 gemergte PRs in 30 T)
Beschreibung
Title: Inconsistent handling of stat prefix between StatsD stats sinks and prometheus when a Custom Stat Namespace is registered.
Description:
In https://github.com/envoyproxy/envoy/pull/17357, support for specifying a Custom Stat Namespace was added for extensions and stat sinks to register a namespace to distinguish between user-defined stats and Envoy native stats. Additionally, a default namespace of "wasmcustom" was registered for Wasm extensions. With these changes the exposed StatsD metrics changed from envoy.<metric_name> to be envoy.wasmcustom.<metric_name> where "envoy." is the default prefix added for all stats in Envoy.
Also in https://github.com/envoyproxy/envoy/pull/17357, the prometheus stats handler was updated to handle the prefix when a custom stat namespace is registered. Changes made were as follows:
- Check for a registered custom namespace and strip the namespace prefix if it is defined from the exposed metric.
- Also remove the default "envoy_" prefix for user-defined metrics.
Therefore, with that change the user-defined metrics are exposed as-is with no prefix from prometheus and the format therefore changed from envoy_<metrics_name> to just <metric_name>.
This has made the behavior between StatsD sinks and prometheus exposed metrics inconsistent. Ideally, similar changes should be made for StatsD to make the behavior consistent with prometheus.
Repro steps:
- Requires a wasm stats extension with user-defined metrics
- Query stats endpoint at
9901/statsand verify the stat format aswasmcustom.<user-defined-metric-name>with the "wasmcustom." prefix. - Use a statsD sink for exposing metrics e.g., DogStatsD.
- Observe the exposed statsD stat is in the format
envoy.wasmcustom.<user-defined-metric-name>with the additional "envoy." prefix. - Now query the prometheus endpoint at
9901/stats/prometheusto verify the stat format to be<user-defined-metric-name>without any prefix.