当前位置:网站首页>Prometheus API deletes all data of a specified job

Prometheus API deletes all data of a specified job

2022-07-07 16:23:00 shy_ snow

modify job Of name Later, I found that the data was repeated , Don't want to delete all the data , Just want to delete one of them job Previous data , I saw it on the Internet api You can delete .
First , To pass the prometheus Launch parameters –web.enable-admin-api To open admin HTTP API The interview of .

# stop it prometheus
ps -ef |grep -v grep | grep prometheus.yml | awk '{print $2}' | xargs kill
# increase --web.enable-admin-api Post start prometheus
nohup /home/xxx/prometheus-2.25.2.linux-amd64/prometheus --config.file=prometheus.yml --web.enable-admin-api --web.enable-lifecycle > nohup.out 2>&1 &

Then you can choose the appropriate way to delete the data :

# Delete all time series indicators that match a tag 
curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={kubernetes_name="redis"}'
# Delete  job  Task or  instance  Data indicators of :
curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={job="youjobname"}'
curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={instance="192.168.129.110:9090"}'
#Prometheus  Delete all data in , You can use the following command :
curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={__name__=~".+"}'
原网站

版权声明
本文为[shy_ snow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071402431847.html