Pushgateway

From wikinotes

The push gateway exposes a REST API that you can push metrics to.

NOTE:

Multiple pushes with the same metric name (even with different labels)
will overwrite each previous push. Metric names must be unique

WARNING:

Unlike other exporters, the push gateway does not record time-series data.
For example, If you push a metric with the values

  • 0.5 at 1pm
  • 1.0 at 2pm

The graph will show 1.0 for the entire history of the metric.
If you desire time-series data, you'll need a different solution like statsd or node_exporters textfile collector.

Documentation

github https://github.com/prometheus/pushgateway

Routes

port 9091
push metrics POST http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}
push metrics POST http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}/instance/${YOUR_INSTANCE}

Install

aura -A pushgateway     # Archlinux
pkg install pushgateway # FreeBSD

Configuration

Pushgateway Config

The --web.config.file param determines the loaded config.
It can be used to configure TLS/Basic AUTH.

Prometheus Config

scrape_configs:
- job_name: gateway
  honor_labels: True
  - targets:
    - 127.0.0.1:9091

Alerting

push_time_seconds                                           # alert if no push in N seconds
push_failure_time_seconds > push_time_seconds               # alert on failed pushes
pushgateway_http_requests_total{code="400",handler="push"}  # malformed pushes

Usage

Overview

# emit metric without instance
URL="http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}"

echo "some_metric{name="foo"} 1" \
  | curl -X POST --data-binary @- $URL
# emit metric with instance (ex: 192.168.1.100:9000)
URL="http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}/instance/${YOUR_INSTANCE}"

cat <<EOF | curl -X POST --data-binary @- $URL
metric_abc 1.1
metric_def 2.2
EOF
# query
curl -X GET http://${IPADDR}:9091/api/v1/metrics

API

# HTTP Statuses
200: success
202: when `--push.disable-consistency-check` is used, push has been queued
400: malformed, inconsistent metrics, metric collisions
# HTTP Methods

# URL="http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}"
# URL="http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}/instance/${YOUR_INSTANCE}"
PUT:
POST:
DELETE:

# URL="http://${IPADDR}:9091/api/${API_VERSION}/${HANDLER}"
GET: