Pushgateway: Difference between revisions
From wikinotes
(→Usage) |
No edit summary |
||
(14 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The push gateway | 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 5: | Line 17: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| | | github || https://github.com/prometheus/pushgateway | ||
|- | |- | ||
|} | |} | ||
Line 13: | Line 25: | ||
<blockquote> | <blockquote> | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
| port || <code>9091</code> | |||
|- | |- | ||
| push metrics || <code>POST http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}</code> | | push metrics || <code>POST http://${IPADDR}:9091/metrics/job/${YOUR_JOB_NAME}</code> | ||
Line 20: | Line 34: | ||
|} | |} | ||
</blockquote><!-- Routes --> | </blockquote><!-- Routes --> | ||
= Install = | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
aura -A pushgateway # Archlinux | |||
pkg install pushgateway # FreeBSD | |||
</syntaxhighlight> | |||
</blockquote><!-- Install --> | |||
= Configuration = | |||
<blockquote> | |||
== Pushgateway Config == | |||
<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 --> | |||
== Prometheus Config == | |||
<blockquote> | |||
<syntaxhighlight lang="yaml"> | |||
scrape_configs: | |||
- job_name: gateway | |||
honor_labels: True | |||
- targets: | |||
- 127.0.0.1:9091 | |||
</syntaxhighlight> | |||
</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 --> | |||
= Usage = | = Usage = | ||
<blockquote> | |||
== Overview == | |||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 40: | Line 93: | ||
EOF | EOF | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash"> | |||
# query | |||
curl -X GET http://${IPADDR}:9091/api/v1/metrics | |||
</syntaxhighlight> | |||
</blockquote><!-- Overview --> | |||
== API == | |||
<blockquote> | |||
<syntaxhighlight lang="yaml"> | |||
# HTTP Statuses | |||
200: success | |||
202: when `--push.disable-consistency-check` is used, push has been queued | |||
400: malformed, inconsistent metrics, metric collisions | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="yaml"> | |||
# 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: | |||
</syntaxhighlight> | |||
</blockquote><!-- API --> | |||
</blockquote><!-- Usage --> | </blockquote><!-- Usage --> |
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: