• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.circleci/H11-Oct-2021-4645

.github/H11-Oct-2021-6945

api/v1/H11-Oct-2021-505401

asset/H11-Oct-2021-772627

handler/H11-Oct-2021-1,3471,016

resources/static/H03-May-2022-21,87320,124

storage/H11-Oct-2021-2,3611,971

testutil/H11-Oct-2021-4220

vendor/H03-May-2022-1,685,0531,467,569

.dockerignoreH A D11-Oct-2021103 86

.gitattributesH A D11-Oct-2021199 54

.gitignoreH A D11-Oct-202175 109

.golangci.ymlH A D11-Oct-2021134 65

.promu.ymlH A D11-Oct-2021647 1918

CHANGELOG.mdH A D11-Oct-20217.2 KiB170120

CODE_OF_CONDUCT.mdH A D11-Oct-2021155 42

CONTRIBUTING.mdH A D11-Oct-2021950 2115

DockerfileH A D11-Oct-2021421 1712

LICENSEH A D11-Oct-202111.1 KiB202169

MAINTAINERS.mdH A D11-Oct-202148 21

MakefileH A D11-Oct-2021897 246

Makefile.commonH A D11-Oct-202110.3 KiB318237

NOTICEH A D11-Oct-2021487 2014

README.mdH A D11-Oct-202127.4 KiB629487

SECURITY.mdH A D11-Oct-2021170 74

VERSIONH A D11-Oct-20216 21

go.modH A D11-Oct-2021535 1714

go.sumH A D11-Oct-202148 KiB492491

main.goH A D11-Oct-20219.5 KiB267200

README.md

1# Prometheus Pushgateway
2
3[![CircleCI](https://circleci.com/gh/prometheus/pushgateway/tree/master.svg?style=shield)][circleci]
4[![Docker Repository on Quay](https://quay.io/repository/prometheus/pushgateway/status)][quay]
5[![Docker Pulls](https://img.shields.io/docker/pulls/prom/pushgateway.svg?maxAge=604800)][hub]
6
7The Prometheus Pushgateway exists to allow ephemeral and batch jobs to
8expose their metrics to Prometheus. Since these kinds of jobs may not
9exist long enough to be scraped, they can instead push their metrics
10to a Pushgateway. The Pushgateway then exposes these metrics to
11Prometheus.
12
13## Non-goals
14
15First of all, the Pushgateway is not capable of turning Prometheus into a
16push-based monitoring system. For a general description of use cases for the
17Pushgateway, please read [When To Use The
18Pushgateway](https://prometheus.io/docs/practices/pushing/).
19
20The Pushgateway is explicitly not an _aggregator or distributed counter_ but
21rather a metrics cache. It does not have
22[statsd](https://github.com/etsy/statsd)-like semantics. The metrics pushed are
23exactly the same as you would present for scraping in a permanently running
24program. If you need distributed counting, you could either use the actual
25statsd in combination with the [Prometheus statsd
26exporter](https://github.com/prometheus/statsd_exporter), or have a look at
27[Weavework's aggregation
28gateway](https://github.com/weaveworks/prom-aggregation-gateway). With more
29experience gathered, the Prometheus project might one day be able to provide a
30native solution, separate from or possibly even as part of the Pushgateway.
31
32For machine-level metrics, the
33[textfile](https://github.com/prometheus/node_exporter/blob/master/README.md#textfile-collector)
34collector of the Node exporter is usually more appropriate. The Pushgateway is
35intended for service-level metrics.
36
37The Pushgateway is not an _event store_. While you can use Prometheus as a data
38source for
39[Grafana annotations](http://docs.grafana.org/reference/annotations/), tracking
40something like release events has to happen with some event-logging framework.
41
42A while ago, we
43[decided to not implement a “timeout” or TTL for pushed metrics](https://github.com/prometheus/pushgateway/issues/19)
44because almost all proposed use cases turned out to be anti-patterns we
45strongly discourage. You can follow a more recent discussion on the
46[prometheus-developers mailing list](https://groups.google.com/forum/#!topic/prometheus-developers/9IyUxRvhY7w).
47
48## Run it
49
50Download binary releases for your platform from the
51[release page](https://github.com/prometheus/pushgateway/releases) and unpack
52the tarball.
53
54If you want to compile yourself from the sources, you need a working Go
55setup. Then use the provided Makefile (type `make`).
56
57For the most basic setup, just start the binary. To change the address
58to listen on, use the `--web.listen-address` flag (e.g. "0.0.0.0:9091" or ":9091").
59By default, Pushgateway does not persist metrics. However, the `--persistence.file` flag
60allows you to specify a file in which the pushed metrics will be
61persisted (so that they survive restarts of the Pushgateway).
62
63### Using Docker
64
65You can deploy the Pushgateway using the [prom/pushgateway](https://hub.docker.com/r/prom/pushgateway) Docker image.
66
67For example:
68
69```bash
70docker pull prom/pushgateway
71
72docker run -d -p 9091:9091 prom/pushgateway
73```
74
75## Use it
76
77### Configure the Pushgateway as a target to scrape
78
79The Pushgateway has to be configured as a target to scrape by Prometheus, using
80one of the usual methods. _However, you should always set `honor_labels: true`
81in the scrape config_ (see [below](#about-the-job-and-instance-labels) for a
82detailed explanation).
83
84### Libraries
85
86Prometheus client libraries should have a feature to push the
87registered metrics to a Pushgateway. Usually, a Prometheus client
88passively presents metric for scraping by a Prometheus server. A
89client library that supports pushing has a push function, which needs
90to be called by the client code. It will then actively push the
91metrics to a Pushgateway, using the API described below.
92
93### Command line
94
95Using the Prometheus text protocol, pushing metrics is so easy that no
96separate CLI is provided. Simply use a command-line HTTP tool like
97`curl`. Your favorite scripting language has most likely some built-in
98HTTP capabilities you can leverage here as well.
99
100*Note that in the text protocol, each line has to end with a line-feed
101character (aka 'LF' or '\n'). Ending a line in other ways, e.g. with 'CR' aka
102'\r', 'CRLF' aka '\r\n', or just the end of the packet, will result in a
103protocol error.*
104
105Pushed metrics are managed in groups, identified by a grouping key of any
106number of labels, of which the first must be the `job` label. The groups are
107easy to inspect via the web interface.
108
109*For implications of special characters in label values see the [URL
110section](#url) below.*
111
112Examples:
113
114* Push a single sample into the group identified by `{job="some_job"}`:
115
116        echo "some_metric 3.14" | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/some_job
117
118  Since no type information has been provided, `some_metric` will be of type `untyped`.
119
120* Push something more complex into the group identified by `{job="some_job",instance="some_instance"}`:
121
122        cat <<EOF | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/some_job/instance/some_instance
123        # TYPE some_metric counter
124        some_metric{label="val1"} 42
125        # TYPE another_metric gauge
126        # HELP another_metric Just an example.
127        another_metric 2398.283
128        EOF
129
130  Note how type information and help strings are provided. Those lines
131  are optional, but strongly encouraged for anything more complex.
132
133* Delete all metrics in the group identified by
134  `{job="some_job",instance="some_instance"}`:
135
136        curl -X DELETE http://pushgateway.example.org:9091/metrics/job/some_job/instance/some_instance
137
138* Delete all metrics in the group identified by `{job="some_job"}` (note that
139  this does not include metrics in the
140  `{job="some_job",instance="some_instance"}` group from the previous example,
141  even if those metrics have the same job label):
142
143        curl -X DELETE http://pushgateway.example.org:9091/metrics/job/some_job
144
145* Delete all metrics in all groups (requires to enable the admin API via the command line flag `--web.enable-admin-api`):
146
147        curl -X PUT http://pushgateway.example.org:9091/api/v1/admin/wipe
148
149### About the job and instance labels
150
151The Prometheus server will attach a `job` label and an `instance` label to each
152scraped metric. The value of the `job` label comes from the scrape
153configuration. When you configure the Pushgateway as a scrape target for your
154Prometheus server, you will probably pick a job name like `pushgateway`. The
155value of the `instance` label is automatically set to the host and port of the
156target scraped. Hence, all the metrics scraped from the Pushgateway will have
157the host and port of the Pushgateway as the `instance` label and a `job` label
158like `pushgateway`. The conflict with the `job` and `instance` labels you might
159have attached to the metrics pushed to the Pushgateway is solved by renaming
160those labels to `exported_job` and `exported_instance`.
161
162However, this behavior is usually undesired when scraping a
163Pushgateway. Generally, you would like to retain the `job` and `instance`
164labels of the metrics pushed to the Pushgateway. That's why you have set
165`honor_labels: true` in the scrape config for the Pushgateway. It enables the
166desired behavior. See the
167[documentation](https://prometheus.io/docs/operating/configuration/#scrape_config)
168for details.
169
170This leaves us with the case where the metrics pushed to the Pushgateway do not
171feature an `instance` label. This case is quite common as the pushed metrics
172are often on a service level and therefore not related to a particular
173instance. Even with `honor_labels: true`, the Prometheus server will attach an
174`instance` label if no `instance` label has been set in the first
175place. Therefore, if a metric is pushed to the Pushgateway without an instance
176label (and without instance label in the grouping key, see below), the
177Pushgateway will export it with an empty instance label (`{instance=""}`),
178which is equivalent to having no `instance` label at all but prevents the
179server from attaching one.
180
181### About metric inconsistencies
182
183The Pushgateway exposes all pushed metrics together with its own metrics via
184the same `/metrics` endpoint. (See the section about [exposed
185metrics](#exposed-metrics) for details.) Therefore, all the metrics have to be
186consistent with each other: Metrics of the same name must have
187the same type, even if they are pushed to different groups, and there must be
188no duplicates, i.e. metrics with the same name and the exact same label
189pairs. Pushes that would lead to inconsistencies are rejected with status
190code 400.
191
192Inconsistent help strings are tolerated, though. The Pushgateway will pick a
193winning help string and log about it at info level.
194
195_Legacy note: The help string of Pushgateway's own `push_time_seconds` metric
196has changed in v0.10.0. By using a persistence file, metrics pushed to a
197Pushgateway of an earlier version can make it into a Pushgateway of v0.10.0 or
198later. In this case, the above mentioned log message will show up. Once each
199previously pushed group has been deleted or received a new push, the log
200message will disappear._
201
202The consistency check performed during a push is the same as it happens anyway
203during a scrape. In common use cases, scrapes happen more often than
204pushes. Therefore, the performance cost of the push-time check isn't
205relevant. However, if a large amount of metrics on the Pushgateway is combined
206with frequent pushes, the push duration might become prohibitively long. In
207this case, you might consider using the command line flag
208`--push.disable-consistency-check`, which saves the cost of the consistency
209check during a push but allows pushing inconsistent metrics. The check will
210still happen during a scrape, thereby failing all scrapes for as long as
211inconsistent metrics are stored on the Pushgateway. Setting the flag therefore
212puts you at risk to disable the Pushgateway by a single inconsistent push.
213
214### About timestamps
215
216If you push metrics at time *t*<sub>1</sub>, you might be tempted to believe
217that Prometheus will scrape them with that same timestamp
218*t*<sub>1</sub>. Instead, what Prometheus attaches as a timestamp is the time
219when it scrapes the Pushgateway. Why so?
220
221In the world view of Prometheus, a metric can be scraped at any
222time. A metric that cannot be scraped has basically ceased to
223exist. Prometheus is somewhat tolerant, but if it cannot get any
224samples for a metric in 5min, it will behave as if that metric does
225not exist anymore. Preventing that is actually one of the reasons to
226use a Pushgateway. The Pushgateway will make the metrics of your
227ephemeral job scrapable at any time. Attaching the time of pushing as
228a timestamp would defeat that purpose because 5min after the last
229push, your metric will look as stale to Prometheus as if it could not
230be scraped at all anymore. (Prometheus knows only one timestamp per
231sample, there is no way to distinguish a 'time of pushing' and a 'time
232of scraping'.)
233
234As there aren't any use cases where it would make sense to attach a
235different timestamp, and many users attempting to incorrectly do so (despite no
236client library supporting this), the Pushgateway rejects any pushes with
237timestamps.
238
239If you think you need to push a timestamp, please see [When To Use The
240Pushgateway](https://prometheus.io/docs/practices/pushing/).
241
242In order to make it easier to alert on failed pushers or those that have not
243run recently, the Pushgateway will add in the metrics `push_time_seconds` and
244`push_failure_time_seconds` with the Unix timestamp of the last successful and
245failed `POST`/`PUT` to each group. This will override any pushed metric by that
246name. A value of zero for either metric implies that the group has never seen a
247successful or failed `POST`/`PUT`.
248
249## API
250
251All pushes are done via HTTP. The interface is vaguely REST-like.
252
253### URL
254
255The default port the Pushgateway is listening to is 9091. The path looks like
256
257    /metrics/job/<JOB_NAME>{/<LABEL_NAME>/<LABEL_VALUE>}
258
259`<JOB_NAME>` is used as the value of the `job` label, followed by any
260number of other label pairs (which might or might not include an
261`instance` label). The label set defined by the URL path is used as a
262grouping key. Any of those labels already set in the body of the
263request (as regular labels, e.g. `name{job="foo"} 42`)
264_will be overwritten to match the labels defined by the URL path!_
265
266If `job` or any label name is suffixed with `@base64`, the following job name
267or label value is interpreted as a base64 encoded string according to [RFC
2684648, using the URL and filename safe
269alphabet](https://tools.ietf.org/html/rfc4648#section-5). (Padding is optional,
270but a single `=` is required to encode an empty label value.) This is the only
271way to handle the following cases:
272
273* A job name or a label value that contains a `/`, because the plain (or even
274  URI-encoded) `/` would otherwise be interpreted as a path separator.
275* An empty label value, because the resulting `//` or trailing `/` would
276  disappear when the path is sanitized by the HTTP router code. Note that an
277  empty `job` name is invalid. Empty label values are valid but rarely
278  useful. To encode them with base64, you have to use at least one `=` padding
279  character to avoid a `//` or a trailing `/`.
280
281For other special characters, the usual URI component encoding works, too, but
282the base64 might be more convenient.
283
284Ideally, client libraries take care of the suffixing and encoding.
285
286Examples:
287
288* To use the grouping key `job="directory_cleaner",path="/var/tmp"`, the
289  following path will _not_ work:
290
291      /metrics/job/directory_cleaner/path//var/tmp
292
293  Instead, use the base64 URL-safe encoding for the label value and mark it by
294  suffixing the label name with `@base64`:
295
296      /metrics/job/directory_cleaner/path@base64/L3Zhci90bXA
297
298  If you are not using a client library that handles the encoding for you, you
299  can use encoding tools. For example, there is a command line tool `base64url`
300  (Debian package `basez`), which you could combine with `curl` to push from
301  the command line in the following way:
302
303      echo 'some_metric{foo="bar"} 3.14' | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/directory_cleaner/path@base64/$(echo -n '/var/tmp' | base64url)
304
305* To use a grouping key containing an empty label value such as
306  `job="example",first_label="",second_label="foobar"`, the following path will
307  _not_ work:
308
309       /metrics/job/example/first_label//second_label/foobar
310
311  Instead, use the following path including the `=` padding character:
312
313      /metrics/job/example/first_label@base64/=/second_label/foobar
314
315* The grouping key `job="titan",name="Προμηθεύς"` can be represented
316  “traditionally” with URI encoding:
317
318      /metrics/job/titan/name/%CE%A0%CF%81%CE%BF%CE%BC%CE%B7%CE%B8%CE%B5%CF%8D%CF%82
319
320  Or you can use the more compact base64 encoding:
321
322      /metrics/job/titan/name@base64/zqDPgc6_zrzOt864zrXPjc-C
323
324### `PUT` method
325
326`PUT` is used to push a group of metrics. All metrics with the
327grouping key specified in the URL are replaced by the metrics pushed
328with `PUT`.
329
330The body of the request contains the metrics to push either as delimited binary
331protocol buffers or in the simple flat text format (both in version 0.0.4, see
332the
333[data exposition format specification](https://docs.google.com/document/d/1ZjyKiKxZV83VI9ZKAXRGKaUKK2BIWCT7oiGBKDBpjEY/edit?usp=sharing)).
334Discrimination between the two variants is done via the `Content-Type`
335header. (Use the value `application/vnd.google.protobuf;
336proto=io.prometheus.client.MetricFamily; encoding=delimited` for protocol
337buffers, otherwise the text format is tried as a fall-back.)
338
339The response code upon success is either 200, 202, or 400. A 200 response
340implies a successful push, either replacing an existing group of metrics or
341creating a new one. A 400 response can happen if the request is malformed or if
342the pushed metrics are inconsistent with metrics pushed to other groups or
343collide with metrics of the Pushgateway itself. An explanation is returned in
344the body of the response and logged on error level. A 202 can only occur if the
345`--push.disable-consistency-check` flag is set. In this case, pushed metrics
346are just queued and not checked for consistency. Inconsistencies will lead to
347failed scrapes, however, as described [above](#about-metric-inconsistencies).
348
349In rare cases, it is possible that the Pushgateway ends up with an inconsistent
350set of metrics already pushed. In that case, new pushes are also rejected as
351inconsistent even if the culprit is metrics that were pushed earlier. Delete
352the offending metrics to get out of that situation.
353
354_If using the protobuf format, do not send duplicate MetricFamily
355proto messages (i.e. more than one with the same name) in one push, as
356they will overwrite each other._
357
358Note that the Pushgateway doesn't provide any strong guarantees that the pushed
359metrics are persisted to disk. (A server crash may cause data loss. Or the
360Pushgateway is configured to not persist to disk at all.)
361
362A `PUT` request with an empty body effectively deletes all metrics with the
363specified grouping key. However, in contrast to the
364[`DELETE` request](#delete-method) described below, it does update the
365`push_time_seconds` metrics.
366
367### `POST` method
368
369`POST` works exactly like the `PUT` method but only metrics with the
370same name as the newly pushed metrics are replaced (among those with
371the same grouping key).
372
373A `POST` request with an empty body merely updates the `push_time_seconds`
374metrics but does not change any of the previously pushed metrics.
375
376### `DELETE` method
377
378`DELETE` is used to delete metrics from the Pushgateway. The request
379must not contain any content. All metrics with the grouping key
380specified in the URL are deleted.
381
382The response code upon success is always 202. The delete
383request is merely queued at that moment. There is no guarantee that the
384request will actually be executed or that the result will make it to
385the persistence layer (e.g. in case of a server crash). However, the
386order of `PUT`/`POST` and `DELETE` request is guaranteed, i.e. if you
387have successfully sent a `DELETE` request and then send a `PUT`, it is
388guaranteed that the `DELETE` will be processed first (and vice versa).
389
390Deleting a grouping key without metrics is a no-op and will not result
391in an error.
392
393## Admin API
394
395The Admin API provides administrative access to the Pushgateway, and must be
396explicitly enabled by setting `--web.enable-admin-api` flag.
397
398### URL
399
400The default port the Pushgateway is listening to is 9091. The path looks like:
401
402    /api/<API_VERSION>/admin/<HANDLER>
403
404 * Available endpoints:
405
406| HTTP_METHOD| API_VERSION |  HANDLER | DESCRIPTION |
407| :-------: |:-------------:| :-----:| :----- |
408| PUT     | v1 | wipe |  Safely deletes all metrics from the Pushgateway. |
409
410
411* For example to wipe all metrics from the Pushgateway:
412
413        curl -X PUT http://pushgateway.example.org:9091/api/v1/admin/wipe
414
415## Query API
416
417The query API allows accessing pushed metrics and build and runtime information.
418
419### URL
420
421    /api/<API_VERSION>/<HANDLER>
422
423 * Available endpoints:
424
425| HTTP_METHOD| API_VERSION |  HANDLER | DESCRIPTION |
426| :-------: |:-------------:| :-----:| :----- |
427| GET     | v1 | status |  Returns build information, command line flags, and the start time in JSON format. |
428| GET     | v1 | metrics |  Returns the pushed metric families in JSON format. |
429
430
431* For example :
432
433        curl -X GET http://pushgateway.example.org:9091/api/v1/status | jq
434
435        {
436          "status": "success",
437          "data": {
438            "build_information": {
439              "branch": "master",
440              "buildDate": "20200310-20:14:39",
441              "buildUser": "flipbyte@localhost.localdomain",
442              "goVersion": "go1.13.6",
443              "revision": "eba0ec4100873d23666bcf4b8b1d44617d6430c4",
444              "version": "1.1.0"
445            },
446            "flags": {
447              "log.format": "logfmt",
448              "log.level": "info",
449              "persistence.file": "",
450              "persistence.interval": "5m0s",
451              "push.disable-consistency-check": "false",
452              "web.enable-admin-api": "false",
453              "web.enable-lifecycle": "false",
454              "web.external-url": "",
455              "web.listen-address": ":9091",
456              "web.route-prefix": "",
457              "web.telemetry-path": "/metrics"
458            },
459            "start_time": "2020-03-11T01:44:49.9189758+05:30"
460          }
461        }
462
463        curl -X GET http://pushgateway.example.org:9091/api/v1/metrics | jq
464
465        {
466          "status": "success",
467          "data": [
468            {
469              "labels": {
470                "job": "batch"
471              },
472              "last_push_successful": true,
473              "my_job_duration_seconds": {
474                "time_stamp": "2020-03-11T02:02:27.716605811+05:30",
475                "type": "GAUGE",
476                "help": "Duration of my batch jon in seconds",
477                "metrics": [
478                  {
479                    "labels": {
480                      "instance": "",
481                      "job": "batch"
482                    },
483                    "value": "0.2721322309989773"
484                  }
485                ]
486              },
487              "push_failure_time_seconds": {
488                "time_stamp": "2020-03-11T02:02:27.716605811+05:30",
489                "type": "GAUGE",
490                "help": "Last Unix time when changing this group in the Pushgateway failed.",
491                "metrics": [
492                  {
493                    "labels": {
494                      "instance": "",
495                      "job": "batch"
496                    },
497                    "value": "0"
498                  }
499                ]
500              },
501              "push_time_seconds": {
502                "time_stamp": "2020-03-11T02:02:27.716605811+05:30",
503                "type": "GAUGE",
504                "help": "Last Unix time when changing this group in the Pushgateway succeeded.",
505                "metrics": [
506                  {
507                    "labels": {
508                      "instance": "",
509                      "job": "batch"
510                    },
511                    "value": "1.5838723477166057e+09"
512                  }
513                ]
514              }
515            }
516          ]
517        }
518
519## Management API
520
521The Pushgateway provides a set of management API to ease automation and integrations.
522
523* Available endpoints:
524
525| HTTP_METHOD |  PATH | DESCRIPTION |
526| :-------: | :-----| :----- |
527| GET    | /-/healthy |  Returns 200 whenever the Pushgateway is healthy. |
528| GET    | /-/ready |  Returns 200 whenever the Pushgateway is ready to serve traffic. |
529
530* The following endpoint is disabled by default and can be enabled via the `--web.enable-lifecycle` flag.
531
532| HTTP_METHOD |  PATH | DESCRIPTION |
533| :-------: | :-----| :----- |
534| PUT    | /-/quit |  Triggers a graceful shutdown of Pushgateway. |
535
536Alternatively, a graceful shutdown can be triggered by sending a `SIGTERM` to the Pushgateway process.
537
538## Exposed metrics
539
540The Pushgateway exposes the following metrics via the configured
541`--web.telemetry-path` (default: `/metrics`):
542- The pushed metrics.
543- For each pushed group, a metric `push_time_seconds` and
544  `push_failure_time_seconds` as explained above.
545- The usual metrics provided by the [Prometheus Go client library](https://github.com/prometheus/client_golang), i.e.:
546  - `process_...`
547  - `go_...`
548  - `promhttp_metric_handler_requests_...`
549- A number of metrics specific to the Pushgateway, as documented by the example
550  scrape below.
551
552```
553# HELP pushgateway_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which pushgateway was built.
554# TYPE pushgateway_build_info gauge
555pushgateway_build_info{branch="master",goversion="go1.10.2",revision="8f88ccb0343fc3382f6b93a9d258797dcb15f770",version="0.5.2"} 1
556# HELP pushgateway_http_push_duration_seconds HTTP request duration for pushes to the Pushgateway.
557# TYPE pushgateway_http_push_duration_seconds summary
558pushgateway_http_push_duration_seconds{method="post",quantile="0.1"} 0.000116755
559pushgateway_http_push_duration_seconds{method="post",quantile="0.5"} 0.000192608
560pushgateway_http_push_duration_seconds{method="post",quantile="0.9"} 0.000327593
561pushgateway_http_push_duration_seconds_sum{method="post"} 0.001622878
562pushgateway_http_push_duration_seconds_count{method="post"} 8
563# HELP pushgateway_http_push_size_bytes HTTP request size for pushes to the Pushgateway.
564# TYPE pushgateway_http_push_size_bytes summary
565pushgateway_http_push_size_bytes{method="post",quantile="0.1"} 166
566pushgateway_http_push_size_bytes{method="post",quantile="0.5"} 182
567pushgateway_http_push_size_bytes{method="post",quantile="0.9"} 196
568pushgateway_http_push_size_bytes_sum{method="post"} 1450
569pushgateway_http_push_size_bytes_count{method="post"} 8
570# HELP pushgateway_http_requests_total Total HTTP requests processed by the Pushgateway, excluding scrapes.
571# TYPE pushgateway_http_requests_total counter
572pushgateway_http_requests_total{code="200",handler="static",method="get"} 5
573pushgateway_http_requests_total{code="200",handler="status",method="get"} 8
574pushgateway_http_requests_total{code="202",handler="delete",method="delete"} 1
575pushgateway_http_requests_total{code="202",handler="push",method="post"} 6
576pushgateway_http_requests_total{code="400",handler="push",method="post"} 2
577
578```
579
580### Alerting on failed pushes
581
582It is in general a good idea to alert on `push_time_seconds` being much farther
583behind than expected. This will catch both failed pushes as well as pushers
584being down completely.
585
586To detect failed pushes much earlier, alert on `push_failure_time_seconds >
587push_time_seconds`.
588
589Pushes can also fail because they are malformed. In this case, they never reach
590any metric group and therefore won't set any `push_failure_time_seconds`
591metrics. Those pushes are still counted as
592`pushgateway_http_requests_total{code="400",handler="push"}`. You can alert on
593the `rate` of this metric, but you have to inspect the logs to identify the
594offending pusher.
595
596## TLS and basic authentication
597
598The Pushgateway supports TLS and basic authentication. This enables better
599control of the various HTTP endpoints.
600
601To use TLS and/or basic authentication, you need to pass a configuration file
602using the `--web.config.file` parameter. The format of the file is described
603[in the exporter-toolkit repository](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md).
604
605Note that the TLS and basic authentication settings affect all HTTP endpoints:
606/metrics for scraping, the API to push metrics via /metrics/..., the admin API
607via /api/..., and the web UI.
608
609## Development
610
611The normal binary embeds the web files in the `resources` directory.
612For development purposes, it is handy to have a running binary use
613those files directly (so that you can see the effect of changes immediately).
614To switch to direct usage, add `-tags dev` to the `flags` entry in
615`.promu.yml`, and then `make build`. Switch back to "normal" mode by
616reverting the changes to `.promu.yml` and typing `make assets`.
617
618##  Contributing
619
620Relevant style guidelines are the [Go Code Review
621Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments)
622and the _Formatting and style_ section of Peter Bourgon's [Go:
623Best Practices for Production
624Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style).
625
626[hub]: https://hub.docker.com/r/prom/pushgateway/
627[circleci]: https://circleci.com/gh/prometheus/pushgateway
628[quay]: https://quay.io/repository/prometheus/pushgateway
629