Skip to content

Inconsistent handling of Stat Prefix between StatsD sinks and prometheus when a Custom Stat Namespace is registered. #19087

@karanvasnani

Description

@karanvasnani

Title: Inconsistent handling of stat prefix between StatsD stats sinks and prometheus when a Custom Stat Namespace is registered.

Description:
In #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 #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:

  1. Requires a wasm stats extension with user-defined metrics
  2. Query stats endpoint at 9901/stats and verify the stat format as wasmcustom.<user-defined-metric-name> with the "wasmcustom." prefix.
  3. Use a statsD sink for exposing metrics e.g., DogStatsD.
  4. Observe the exposed statsD stat is in the format envoy.wasmcustom.<user-defined-metric-name> with the additional "envoy." prefix.
  5. Now query the prometheus endpoint at 9901/stats/prometheus to verify the stat format to be <user-defined-metric-name> without any prefix.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions