Skip to content

Commit 4ea303f

Browse files
committed
feat(push): Add method to delete metrics for instance
Fixes: #303
1 parent 207139d commit 4ea303f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

push/include/prometheus/gateway.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ class PROMETHEUS_CPP_PUSH_EXPORT Gateway {
5252
// Delete metrics from the given pushgateway.
5353
std::future<int> AsyncDelete();
5454

55+
// Delete metrics from the given pushgateway (for configured instance labels).
56+
int DeleteForInstance();
57+
58+
// Delete metrics from the given pushgateway (for configured instance labels).
59+
std::future<int> AsyncDeleteForInstance();
60+
5561
private:
5662
std::string jobUri_;
5763
std::string labels_;

push/src/gateway.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ std::future<int> Gateway::AsyncDelete() {
146146
return std::async(std::launch::async, [&] { return Delete(); });
147147
}
148148

149+
int Gateway::DeleteForInstance() {
150+
return curlWrapper_->performHttpRequest(detail::HttpMethod::Delete,
151+
jobUri_ + labels_, {});
152+
}
153+
154+
std::future<int> Gateway::AsyncDeleteForInstance() {
155+
return std::async(std::launch::async, [&] { return DeleteForInstance(); });
156+
}
157+
149158
void Gateway::CleanupStalePointers(
150159
std::vector<CollectableEntry>& collectables) {
151160
collectables.erase(

0 commit comments

Comments
 (0)