# `telemetry.metric_invalid`

A `metric` isn't in a domain's `monitoring.jadpo`, isn't a `Counter`, `Measure` or `Gauge`, or doesn't list its labels by name.

Area 16, [Built-in services](/docs/built-in-services.md); not declinable; the next step is usually the agent's.

## Why Jadpo refuses it

A domain's metrics are declared in its `monitoring.jadpo`, beside its
thresholds, so a reviewer reads everything that watches the domain in
one place. Each is one of three kinds the monitoring service understands,
and its `by:` names the labels every value carries, so its series can be
added up. Anything else would send values no tool could read the same
way twice.

## What it looks like

`visits` is declared a `Count`, which isn't a kind of metric:

```jadpo
/// Visits, by whether they came back.
metric visits = Count {
    by: [returning]
}
```

```text
error: `Count` isn't a kind of metric
 --> main.jadpo:2:17
  |
2 | metric visits = Count {
  |                 ^^^^^ not `Counter`, `Measure` or `Gauge`
  reason: A metric is declared in a domain's `monitoring.jadpo` as `metric name = Counter { by: [label] }`: a `Counter`, a count that only rises, a `Measure`, a distribution, or a `Gauge`, a value at a moment. `by:` names its labels, which code gives as enums or `Bool`, so the number of series stays bounded.
  next: Use `Counter` instead of `Count` (agent)
  fix:
    2 - metric visits = Count {
    2 + metric visits = Counter {
  rule: telemetry.metric_invalid
  help: https://jadpo.dev/docs/errors/telemetry.metric_invalid

check failed: 1 error, 1 file

next: jadpo fix  fixes this error for you, then checks again
```

`(agent)` at the end of the `next:` line means your coding agent can make
the fix itself.

## How to fix it

**If it counts something**, declare it a `Counter`, the kind for a
count that only rises:

```jadpo
metric visits = Counter {
    by: [returning]
}
```


`visits` is now a count each visit adds to, by whether it came back.

## Related

- [Custom metrics](/docs/telemetry.md#custom-metrics)
- [`telemetry.record_invalid`](/docs/errors/telemetry.record_invalid.md)
