Pushing Metrics via HTTP Request
You can push metrics by sending an HTTP POST request to a URL formatted as follows:- The Push Gateway address and port specify the destination.
- The “job” segment designates the job label, with
<job_name>indicating the associated metric’s job name. - Additional label/value pairs not only supplement the metrics with extra labels but also serve as a grouping key, allowing you to update or delete metrics as a collection.
Pushing metrics via HTTP requests involves manually constructing these requests and sending them directly to the Push Gateway.

Example: Pushing Metrics Using curl
To demonstrate, here is an example where we push a metric namedexample_metric with a value of 4421 under the job db_backup. This is done using the curl command:
- The metric data is sent as binary using
--data-binary. - The
echocommand outputs the metric string. - The
@-flag directs curl to read the binary data from standard input. - The URL targets the local Push Gateway at port 9091, appending the necessary job label.
Grouping Metrics
The URL path, which includes the job name and any additional label-value pairs, functions as a grouping key. Metrics pushed to the same URL are part of a group, enabling bulk updates or deletion.Grouping Example
Imagine you want to push two metrics—metric_one (counter) and metric_two (gauge)—together under a group labeled as archive with an additional label db=mysql. Use the following command:
- The job is named
archive. - The label
db=mysqlgroups these metrics. - All metrics pushed via this URL belong to the same group.
app=web:
- Group one:
archivewithdb=mysql - Group two:
archivewithapp=web
Updating Metrics: POST vs. PUT
The HTTP method used to update metrics affects how the group is modified.Using POST
A POST request updates only the metrics that have the same name as those in the new payload, leaving other metrics in the group unchanged. For example, to updatemetric_one in the archive/app/web group:
A POST request selectively updates the metric(s) matching the payload without affecting the rest of the group.
Using PUT
A PUT request, by contrast, replaces all metrics within the specified group with the new set provided. For instance, to completely replace the group contents with onlymetric_one:
metric_one exists in the archive/app/web group, and all previous metrics (e.g., metric_two) are removed.
Deleting Metrics
To remove all metrics from a specific group, send a DELETE request to that group’s URL:archive/app/web is deleted, leaving other groups (like archive/db/mysql) unaffected.
Summary
- Use a POST request to update specific metrics by name within a group.
- Use a PUT request to completely replace all metrics in a group.
- Use a DELETE request to remove all metrics belonging to a given group.