Skip to content

Prometheus formatter should escape '"' and other characters and degrade gracefully when it cannot #18589

Closed

Description

@mandarjog

If a new StasScope is created by a filter with a number of dimensions, and one of the dimensions has a " inside the value, the Prometheus formatter ends up producing invalid prometheus output at /stats/prometheus .

Prometheus formatter should not produce invalid prometheus output regardless of the input.

  1. Since prometheus-text is a line oriented format, if a valid encoding cannot be generated, the line should be elided, with some comment indicating that this has happened.
  2. Escape " as '"` in the output

example when path=/foor"bar

request_total{path="/foo"bar"} 250

The above line is not parseable.

One could argue that Prometheus scraper should degrade gracefully by only discarding lines that cannot be parsed.

ref: istio/istio#35575

@kyessenov

Activity

  1. added
    triage
    on Oct 12, 2021
  2. mandarjog commented on Oct 12, 2021

    @mandarjog
    ContributorAuthor
  3. kyessenov commented on Oct 12, 2021

    @kyessenov
    Contributor

    Per envoy trust model, stats are not supposed to take untrusted data path values. There's also invalid utf-8 issue since envoy will pass latin1 bytes through and break scraping.

  4. added
    help wanted
    and removed
    triage
    on Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions