Skip to content

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

@sergueik

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.

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