In this article, we are going to figure out, how to delete PushGateway metrics/groups. Let’s also answer the question – why “PushGateway metrics delete not working” or “PushGateway groups delete not working”.
First of all, you must specify all the keys of the group that you want to delete.
You need to delete groups with such keys, that you used to when pushing metrics.
For example, your group only contains the key
job="myjob". Then you can remove it in this way:
curl --location --request DELETE 'http://localhost:9091/metrics/job/myjob’
If your group has key
job="myjob", then you need to add this key when deleting:
curl --location --request DELETE 'http://localhost:9091/metrics/job/myjob/instance/myinstance’
Map<String, String> keyMap = new HashMap<>(); keyMap.put("instance", "myinstance"); pushGateway.delete("myjob", keyMap);
If you don’t specified all keys during deletion, then despite a positive 202 response from the server, the deletion will not occurs.
Therefore, if groups deletions from the PushGateway not works, make sure that you have specified all the existing keys of the group that you want to delete!
If you still have any questions, feel free to ask me in the comments under this article, or write me on firstname.lastname@example.org.
If I saved your day, you can support me :)