You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add API reference for pushgateway, textfile, and multiprocess (prometheus#1162)
Closesprometheus#1161
Adds parameter tables and formal API reference sections to three pages
that previously had examples but no parameter documentation.
pushgateway.md: documents push_to_gateway, pushadd_to_gateway,
delete_from_gateway, instance_ip_grouping_key, and all four built-in
handlers (default, basic_auth, tls_auth, passthrough_redirect).
textfile.md: documents write_to_textfile with all four parameters
including the previously undocumented escaping and tmpdir, plus atomic
write semantics and error behavior.
multiprocess/_index.md: documents MultiProcessCollector constructor and
mark_process_dead with parameter tables including the previously
undocumented path parameter on both.
Signed-off-by: k1chik <107162115+k1chik@users.noreply.github.com>
Pushes metrics to the pushgateway, replacing all metrics with the same job and grouping key.
94
+
Uses the HTTP `PUT` method.
95
+
96
+
| Parameter | Type | Default | Description |
97
+
|-----------|------|---------|-------------|
98
+
|`gateway`|`str`| required | URL of the pushgateway. If no scheme is provided, `http://` is assumed. |
99
+
|`job`|`str`| required | Value for the `job` label attached to all pushed metrics. |
100
+
|`registry`|`Collector`| required | Registry whose metrics are pushed. Typically a `CollectorRegistry` instance. |
101
+
|`grouping_key`|`Optional[Dict[str, Any]]`|`None`| Additional labels to identify the group. See the [Pushgateway documentation](https://github.com/prometheus/pushgateway/blob/master/README.md) for details. |
102
+
|`timeout`|`Optional[float]`|`30`| Seconds before the request is aborted. Pass `None` for no timeout. |
103
+
|`handler`|`Callable`|`default_handler`| Function that performs the HTTP request. See [Handlers](#handlers) below. |
104
+
|`compression`|`Optional[str]`|`None`| Compress the payload before sending. Accepts `'gzip'` or `'snappy'`. Snappy requires the [`python-snappy`](https://github.com/andrix/python-snappy) package. |
Writes metrics from the registry to a file in Prometheus text format.
30
+
31
+
The file is written atomically: metrics are first written to a temporary file in the same
32
+
directory as `path` (or in `tmpdir` if provided), then renamed into place. This prevents the
33
+
Node exporter from reading a partially written file.
34
+
35
+
| Parameter | Type | Default | Description |
36
+
|-----------|------|---------|-------------|
37
+
|`path`|`str`| required | Destination file path. Must end in `.prom` for the Node exporter textfile collector to process it. |
38
+
|`registry`|`Collector`| required | Registry whose metrics are written. |
39
+
|`escaping`|`str`|`'allow-utf-8'`| Escaping scheme for metric and label names. Accepted values: `'allow-utf-8'`, `'underscores'`, `'dots'`, `'values'`. |
40
+
|`tmpdir`|`Optional[str]`|`None`| Directory for the temporary file used during the atomic write. Defaults to the same directory as `path`. If provided, must be on the same filesystem as `path`. |
41
+
42
+
Returns `None`. Raises an exception if the file cannot be written; the temporary file is cleaned
Collector that aggregates metrics written by all processes in the multiprocess directory.
105
+
106
+
| Parameter | Type | Default | Description |
107
+
|-----------|------|---------|-------------|
108
+
|`registry`|`CollectorRegistry`| required | Registry to register with. Pass a registry created inside the request context to avoid duplicate metrics. |
109
+
|`path`|`Optional[str]`|`None`| Path to the directory containing the per-process metric files. Defaults to the `PROMETHEUS_MULTIPROC_DIR` environment variable. |
110
+
111
+
Raises `ValueError` if `path` is not set or does not point to an existing directory.
112
+
113
+
```python
114
+
from prometheus_client import multiprocess, CollectorRegistry
0 commit comments