How to delete the historical data

579 views
Skip to first unread message

BHARATH KUMAR

unread,
Dec 4, 2022, 11:00:55 AM12/4/22
to Prometheus Users
Hello All,

I installed node exporter in multiple instances. Now I deleted one of those instance(this is unreachable instance) from prometheus.yml file. When I am trying to query up == 0, still I am able to see this instance in the database. 

How to delete that particular instance in database? Any help?

Thanks in advance.


Thanks & regards,
Bharath Kumar 

Shelten

unread,
Dec 4, 2022, 11:21:43 AM12/4/22
to BHARATH KUMAR, Prometheus Users
Remove the target from prometheus.yml file as well

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/58e88b61-58be-441c-9fa8-a89a534d180dn%40googlegroups.com.

Michael Kogelman

unread,
Dec 4, 2022, 11:48:28 AM12/4/22
to BHARATH KUMAR, Prometheus Users

The default retention is set to 15d iirc, so once that ages out it wil disappear. You can also use promtool to manually delete out data if you really wish.

--

BHARATH KUMAR

unread,
Dec 4, 2022, 12:20:00 PM12/4/22
to Prometheus Users
I removed it from the prometheus.yml file... I am still getting that instance while querying.

BHARATH KUMAR

unread,
Dec 4, 2022, 12:20:28 PM12/4/22
to Prometheus Users
could you please help me with the exact command?

Brian Candler

unread,
Dec 4, 2022, 12:56:45 PM12/4/22
to Prometheus Users
Use Google. Enter "prometheus delete timeseries", and you will find:

This gives the exact command.

BHARATH KUMAR

unread,
Dec 4, 2022, 11:40:42 PM12/4/22
to Prometheus Users
I enabled this flag (--web.enable-admin-api) and executed this command  curl -XPOST http://localhost:9090/api/v1/admin/tsdb/clean_tombstones 

Still, I am able to see the deleted instances while executing the prometheus query.  

Brian Candler

unread,
Dec 5, 2022, 2:26:14 AM12/5/22
to Prometheus Users
You're not cleaning tombstones, you're deleting timeseries. This means that the endpoint needs to be
/api/v1/admin/tsdb/delete_series?match[]={instance="foo"}
just like the page I linked you to says.

BHARATH KUMAR

unread,
Dec 11, 2022, 12:10:43 PM12/11/22
to Prometheus Users
curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={instance="instance:port"}'

Is the above query correct? If so, I am able to see those instances' values that were removed from the prometheus.yml file. Will it take time to reflect on those changes?

Brian Candler

unread,
Dec 11, 2022, 1:01:06 PM12/11/22
to Prometheus Users
Looks OK to me, if your instance labels are of the form name:port.  It should take effect pretty much instantaneously.

You could add -v to the the curl command line, to see the response code (204 / 400 etc)

Of course, the metrics will reappear if you are still scraping them, which might be because:
- you've changed prometheus.yml without sending a HUP signal to reload the config
- you've changed prometheus.yml, you've sent a HUP signal, but the new config has a syntax error (in which case prometheus will keep running with the old config)

Check with: journalctl -eu prometheus
Reply all
Reply to author
Forward
0 new messages