Skip to content

Commit

Permalink
feat(push): Add method to delete metrics for instance
Browse files Browse the repository at this point in the history
Fixes: #303
  • Loading branch information
gjasny committed Nov 17, 2021
1 parent 207139d commit 4ea303f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions push/include/prometheus/gateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class PROMETHEUS_CPP_PUSH_EXPORT Gateway {
// Delete metrics from the given pushgateway.
std::future<int> 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<int> AsyncDeleteForInstance();

private:
std::string jobUri_;
std::string labels_;
Expand Down
9 changes: 9 additions & 0 deletions push/src/gateway.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ std::future<int> Gateway::AsyncDelete() {
return std::async(std::launch::async, [&] { return Delete(); });
}

int Gateway::DeleteForInstance() {
return curlWrapper_->performHttpRequest(detail::HttpMethod::Delete,
jobUri_ + labels_, {});
}

std::future<int> Gateway::AsyncDeleteForInstance() {
return std::async(std::launch::async, [&] { return DeleteForInstance(); });
}

void Gateway::CleanupStalePointers(
std::vector<CollectableEntry>& collectables) {
collectables.erase(
Expand Down

0 comments on commit 4ea303f

Please sign in to comment.