Skip to content

Sanitize metric labels in metrics-exporter-dogstatsd to avoid generating invalid DogStatsD payloads. #603

@tobz

Description

@tobz

Context

DogStatsD as a protocol is underspecified in terms of what it will accept which can lead to issues where a label value is theoretically valid but generate an invalid DogStatsD payload. A simple example of this is a label where the value contains the pipe character: |. This character is essentially reserved for separating structured fields in the DSD payload.

The public Datadog documentation for tagging states that tags will be sanitized according to a small ruleset. When sending the same type of labels as described above, the values would be sanitized such that they would actually allow generating a valid DSD payload. Following the existing example, if our label value was Foo|Bar, it would be sanitized to foo_bar on the Datadog platform. If we simply sent foo_bar in the first place, then the DSD payload would be valid.

We should add an enabled-by-default sanitization step to labels so that we generate them in a way that matches the Datadog tagging rules and allows for them to generate valid DSD payloads. This should be enabled by default because the exporter targets communication with the Datadog Agent. We should add a way to opt-out of this behavior if users are targeting something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-exporterComponent: exporters such as Prometheus, TCP, etc.E-simpleEffort: simple.T-bugType: bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions