Convert Counter to Gauge

Hello !
I’ve a custom metric that change of type in the metric file (mistake from developper).

So I’ve start to scrap metrics as counter, but it is really a gauge.
We have change in the metric file, but prometheus continue as it is a counter.

I’ve try to delete serie like this :

That work fine to clean data, but the serie stay work as a counter (and it has not reset the counter).

I can’t change the serie name (due to application obligations).

Is it a solution to fully remove a serie (values, history, config, type) and recreate it with a new scrap ?


Hello, everyone … no idee ?

up ?
I have actually no solutions …
If anyone has an idea, tell me

What do you mean by “the time series still works as a counter”?

The metrics file has been modified.
The original serie was set as a counter, so prometheus create it as counter.
We have modify the metrics file because the data must be traited as gauge.

Prometheus continue to treat it as a counter. So it always increase the value but in the metric file, the value move up and down.

Is it more clear ?
Sorry for my bad english

What do you mean by the metric file?

# HELP mystat_nblead Nombre de lead
# TYPE mystat_nblead gauge
mystat_nblead {client="client1"} 172 
mystat_nblead {client="client2"} 3867 
mystat_nblead {client="client3"} 19409

in the original file :

# TYPE mystat_nblead counter

So are you scraping these metrics via the Node Exporter textfile collector?

When you are saying the metric is always increasing in Prometheus, are you saying that the values being returned from queries don’t match what was put in the file? If you query the /metrics endpoint of the Node Exporter do you see the values you’d expect? What queries are you trying in Prometheus?

The texte file has the value up and down,
Prometheus always up (counter mode).