Pushgateway: Difference between revisions
From wikinotes
(→API) |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The push gateway exposes a REST API that you can push metrics to. | 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)<br> | |||
will overwrite each previous push. Metric names ''must'' be unique }} | |||
{{ WARNING | | |||
Unlike other exporters, the push gateway does not record time-series data.<br> | |||
For example, If you push a metric with the values | |||
* <code>0.5</code> at 1pm | |||
* <code>1.0</code> at 2pm | |||
The graph will show <code>1.0</code> for the entire history of the metric.<br> | |||
If you desire time-series data, you'll need a different solution like [[statsd]] or [[node_exporter]]s textfile collector. | |||
}} | |||
= Documentation = | = Documentation = | ||
Line 35: | Line 47: | ||
== Pushgateway Config == | == Pushgateway Config == | ||
<blockquote> | <blockquote> | ||
The <code>--web.config.file</code> param determines the loaded config.<br> | |||
It can be used to configure TLS/Basic AUTH. | |||
</blockquote><!-- Pushgateway Config --> | </blockquote><!-- Pushgateway Config --> | ||
Line 48: | Line 61: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Prometheus Config --> | </blockquote><!-- Prometheus Config --> | ||
== Alerting == | |||
<blockquote> | |||
<syntaxhighlight lang="yaml"> | |||
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 | |||
</syntaxhighlight> | |||
</blockquote><!-- Alerting --> | |||
</blockquote><!-- Configuration --> | </blockquote><!-- Configuration --> | ||
Latest revision as of 14:43, 27 February 2022
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 1pm1.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:9091Alerting
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/metricsAPI
# 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: