diff --git a/push/include/prometheus/gateway.h b/push/include/prometheus/gateway.h index 202ed284..e6acd0f0 100644 --- a/push/include/prometheus/gateway.h +++ b/push/include/prometheus/gateway.h @@ -52,6 +52,12 @@ class PROMETHEUS_CPP_PUSH_EXPORT Gateway { // Delete metrics from the given pushgateway. std::future AsyncDelete(); + // Delete metrics from the given pushgateway (for configured instance labels). + int DeleteForInstance(); + + // Delete metrics from the given pushgateway (for configured instance labels). + std::future AsyncDeleteForInstance(); + private: std::string jobUri_; std::string labels_; diff --git a/push/src/gateway.cc b/push/src/gateway.cc index 205a3196..17cedb2d 100644 --- a/push/src/gateway.cc +++ b/push/src/gateway.cc @@ -146,6 +146,15 @@ std::future Gateway::AsyncDelete() { return std::async(std::launch::async, [&] { return Delete(); }); } +int Gateway::DeleteForInstance() { + return curlWrapper_->performHttpRequest(detail::HttpMethod::Delete, + jobUri_ + labels_, {}); +} + +std::future Gateway::AsyncDeleteForInstance() { + return std::async(std::launch::async, [&] { return DeleteForInstance(); }); +} + void Gateway::CleanupStalePointers( std::vector& collectables) { collectables.erase(