Skip to content

Add HELP and TYPE lines to the legacy stats Prometheus text #2734

Closed

Description

@josecelano-bot

Goal

Make the Prometheus text of GET /api/v1/stats?format=prometheus follow the ADR rule that every Prometheus text of the tracker carries # HELP and # TYPE for each metric family, without changing any metric name or value.

Background

The ADR "Define the stats and metrics endpoints and require HELP and TYPE in Prometheus output" (merged with #2727) decided that /stats is not deprecated and that every Prometheus text the tracker exports must carry # HELP and # TYPE. It recorded the legacy /stats text as a known exception and named this issue as the follow-up.

#2719 made the text parseable. Today the 32 lines are bare name value pairs, so every metric is untyped and promtool check metrics reports "no help text" for each (exit code 3). Every Stats field already has a doc comment that describes it.

Proposal

  • Print # HELP and # TYPE before each sample line, in the order of the JSON fields.
  • Choose a type (gauge or counter) and one description per name; keep the names unchanged (API v1).
  • Keep one source for the descriptions shared with the Stats documentation.
  • Update the tests and the stats module docs, then recheck with Prometheus 3.5.0 and promtool (target: exit code 0, 32 samples, target up).

The full specification, including the proposed type table and options, is in docs/issues/open/2734-stats-prometheus-text-help-and-type/ISSUE.md (added by the spec PR).

Related: #2719.

Activity

  1. added 2 commits that reference this issue on Nov 5, 2026
  2. josecelano-bot commented on Nov 5, 2026

    @josecelano-bot
    ContributorAuthor

    Implemented in #2741.

    Note on AC4: with HELP and TYPE, promtool check metrics 3.5.0 exits 3, not 0. No "no help text" or type warning remains; the 28 warnings are naming lint on frozen API v1 names (24 counters without _total, 3 *_ns abbreviated units, the gauge udp_banned_ips_total). Renaming is a breaking change of API v1, so by the maintainer's decision AC4 was amended and the rename is written down for the next API version (spec section "Next API version", doc comment on STATS_DESCRIPTIONS).

  3. added a commit that references this issue on Nov 5, 2026
  4. added 4 commits that reference this issue on Nov 5, 2026
  5. added 2 commits that reference this issue on Nov 6, 2026
  6. added a commit that references this issue on Nov 9, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions