Skip to content

Metric type 'untyped' not recognized in config on v0.7.0 despite documented support #393

Open

Description

@sergueik

Summary

The official release of json_exporter v0.7.0 fails to recognize type: counter, type: gauge, or even type: untyped in the config YAML under metrics.

This worked in earlier versions, and documentation still describes these types as supported.

Reproduction Steps

Config (json_exporter_config.yml)

---
modules:
  stub:
    method: GET
    headers:
      Accept: application/json
    url: http://localhost:80/data
    params:
      ts: "{{.Labels.timestamp}}"
    response_format:
      type: json
    metrics:
    - name: stub_metric_value
      path: "{.metric_value}"
      type: counter

(any of counter gauge untyped fail.

Sample Data

dummy Endpoint returns:

{ "metric_value": 42, "timestamp": "1317532336" }
Run Command
json_exporter --config.file=json_exporter_config.yml

Probe Call

curl "http://localhost:7979/probe?target=http://localhost:80/data?ts=1317532336&module=stub"

error

err="Unknown metric type: 'counter', for metric: 'stub_metric_value'"

same with
gauge

untyped

uppercase variants (e.g., COUNTER)

Only omitting the type field avoids the error (defaulting to “untyped”).

Environment

json_exporter, version 0.7.0 (branch: HEAD, revision: 06fb506a4c5d242186f198b9c8bf072212f3a134)
  build user:       root@6a86be1e0b11
  build date:       20250205-13:57:47
  go version:       go1.18.10
  platform:         linux/amd64

type: counter should be accepted and produce a # TYPE ... counter metric in Prometheus format.

Activity

  1. Curtisjk commented on Aug 7, 2025

    @Curtisjk

    I ran into the same issue, the config you need is valuetype:

        metrics:
        - name: stub_metric_value
          path: "{.metric_value}"
          valuetype: counter
    
  2. xenon898 commented on Sep 10, 2026

    @xenon898

    The underlying confusion: type selects the scrape mode (value / object), while the Prometheus metric type is a separate valuetype key (gauge / counter / untyped) — and neither was documented. So type: counter is parsed as an (invalid) scrape mode.Opened #477: validate both fields at config-load time with an actionable error that points at valuetype, plus docs in the README and examples/config.yml. One deliberate behavior change — an invalid valuetype now fails config load instead of silently becoming untyped; can soften to a warning if maintainers prefer.

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