Skip to content

Target ordering inconsistent when using custom metrics path #4001

@roganartu

Description

@roganartu

What did you do?

  • Set targets via file_sd_configs, where each target inside the file has the same instance but adds a unique __metrics_path__ label (for proxying metrics to devices that can't run exporters, similar to snmp_exporter)
  • Refresh /targets endpoint multiple times

What did you expect to see?

  • Consistent, sorted ordering of targets

What did you see instead? Under which circumstances?

  • Randomly ordered targets list each refresh

Cause
Sorting by only the instance label: https://github.com/prometheus/prometheus/blob/master/web/web.go#L690-L694

Proposal
Sort by the full URL (including query params, sorted by key?) instead of just the instance

Happy to do a PR for this is the proposal is acceptable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions