Prometheus Pushgateway: The Push Model for Short-Lived Jobs
73%
Configuring Prometheus to Scrape Metrics
At this point, you have the Pushgateway running and metrics are being pushed to it. The final step is to configure Prometheus to pull these metrics.
This is how to do it:
cat < /etc/prometheus/prometheus.yml && kill -HUP $(pidof prometheus)
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'pushgateway'
static_configs:
- targets: ['localhost:9091']
EOF
Check the Prometheus targets to ensure the Pushgateway has been added.
curl -s http://localhost:9090/api/v1/targets | jq
Test sending a metric to the Pushgateway and check if Prometheus scrapes it.
# Push a metric to the Pushgateway
echo "this_is_a_test{job=\"test\",instance=\"localhost\"} 1" | \
curl --data-binary \
@- http://localhost:9091/metrics/job/test
# Sleep for 15 seconds to allow Prometheus to scrape the metric
sleep 15
# Query the metric from Prometheus
curl -s http://localhost:9090/api/v1/query?query=this_is_a_test | jq
You should be able to see the metric in the Prometheus query output.
{
"status": "success", // > Query status
"data": {
"resultType": "vector", // > Type of resultObservability with Prometheus and Grafana
A Complete Hands-On Guide to Operational Clarity in Cloud-Native SystemsEnroll now to unlock all content and receive all future updates for free.
