Skip to content

Commit 9f79306

Browse files
authored
Merge pull request #14 from faucetsdn/v0.19.0
Upgrade python3-prometheus-client to v0.19.0.
2 parents dc7e54e + 90b97b4 commit 9f79306

281 files changed

Lines changed: 3857 additions & 758 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 755 deletions
Large diffs are not rendered by default.

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.hugo_build.lock

docs/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Docs
2+
----
3+
4+
This directory contains [hugo](https://gohugo.io) documentation to be published in Github pages.
5+
6+
Run Locally
7+
-----------
8+
9+
```
10+
hugo server -D
11+
```
12+
13+
This will serve the docs on [http://localhost:1313](http://localhost:1313).
14+
15+
Deploy to Github Pages
16+
----------------------
17+
18+
Changes to the `main` branch will be deployed automatically with Github actions.
19+
20+
Update Geekdocs
21+
---------------
22+
23+
The docs use the [Geekdocs](https://geekdocs.de/) theme. The theme is checked in to Github in the `./docs/themes/hugo-geekdoc/` folder. To update [Geekdocs](https://geekdocs.de/), remove the current folder and create a new one with the latest [release](https://github.com/thegeeklab/hugo-geekdoc/releases). There are no local modifications in `./docs/themes/hugo-geekdoc/`.
24+
25+
Notes
26+
-----
27+
28+
Here's how the initial `docs/` folder was set up:
29+
30+
```
31+
hugo new site docs
32+
cd docs/
33+
mkdir -p themes/hugo-geekdoc/
34+
curl -L https://github.com/thegeeklab/hugo-geekdoc/releases/download/v0.41.1/hugo-geekdoc.tar.gz | tar -xz -C themes/hugo-geekdoc/ --strip-components=1
35+
```
36+
37+
Create the initial `hugo.toml` file as described in [https://geekdocs.de/usage/getting-started/](https://geekdocs.de/usage/getting-started/).

docs/archetypes/default.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
3+
date = {{ .Date }}
4+
draft = true
5+
+++

docs/content/_index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "client_python"
3+
---
4+
5+
This is the documentation for the [Prometheus Python client library](https://github.com/prometheus/client_python).

docs/content/bridges/_index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Bridges
3+
weight: 5
4+
---
5+
6+
It is also possible to expose metrics to systems other than Prometheus.
7+
This allows you to take advantage of Prometheus instrumentation even
8+
if you are not quite ready to fully transition to Prometheus yet.

docs/content/bridges/graphite.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Graphite
3+
weight: 1
4+
---
5+
6+
Metrics are pushed over TCP in the Graphite plaintext format.
7+
8+
```python
9+
from prometheus_client.bridge.graphite import GraphiteBridge
10+
11+
gb = GraphiteBridge(('graphite.your.org', 2003))
12+
# Push once.
13+
gb.push()
14+
# Push every 10 seconds in a daemon thread.
15+
gb.start(10.0)
16+
```
17+
18+
Graphite [tags](https://grafana.com/blog/2018/01/11/graphite-1.1-teaching-an-old-dog-new-tricks/) are also supported.
19+
20+
```python
21+
from prometheus_client.bridge.graphite import GraphiteBridge
22+
23+
gb = GraphiteBridge(('graphite.your.org', 2003), tags=True)
24+
c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])
25+
c.labels('get', '/').inc()
26+
gb.push()
27+
```

docs/content/collector/_index.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Collector
3+
weight: 3
4+
---
5+
6+
# Process Collector
7+
8+
The Python client automatically exports metrics about process CPU usage, RAM,
9+
file descriptors and start time. These all have the prefix `process`, and
10+
are only currently available on Linux.
11+
12+
The namespace and pid constructor arguments allows for exporting metrics about
13+
other processes, for example:
14+
```
15+
ProcessCollector(namespace='mydaemon', pid=lambda: open('/var/run/daemon.pid').read())
16+
```
17+
18+
# Platform Collector
19+
20+
The client also automatically exports some metadata about Python. If using Jython,
21+
metadata about the JVM in use is also included. This information is available as
22+
labels on the `python_info` metric. The value of the metric is 1, since it is the
23+
labels that carry information.
24+
25+
# Disabling Default Collector metrics
26+
27+
By default the collected `process`, `gc`, and `platform` collector metrics are exported.
28+
If this information is not helpful, it can be disabled using the following:
29+
30+
```python
31+
import prometheus_client
32+
33+
prometheus_client.REGISTRY.unregister(prometheus_client.GC_COLLECTOR)
34+
prometheus_client.REGISTRY.unregister(prometheus_client.PLATFORM_COLLECTOR)
35+
prometheus_client.REGISTRY.unregister(prometheus_client.PROCESS_COLLECTOR)
36+
```

docs/content/collector/custom.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Custom Collectors
3+
weight: 1
4+
---
5+
6+
Sometimes it is not possible to directly instrument code, as it is not
7+
in your control. This requires you to proxy metrics from other systems.
8+
9+
To do so you need to create a custom collector, for example:
10+
11+
```python
12+
from prometheus_client.core import GaugeMetricFamily, CounterMetricFamily, REGISTRY
13+
from prometheus_client.registry import Collector
14+
15+
class CustomCollector(Collector):
16+
def collect(self):
17+
yield GaugeMetricFamily('my_gauge', 'Help text', value=7)
18+
c = CounterMetricFamily('my_counter_total', 'Help text', labels=['foo'])
19+
c.add_metric(['bar'], 1.7)
20+
c.add_metric(['baz'], 3.8)
21+
yield c
22+
23+
REGISTRY.register(CustomCollector())
24+
```
25+
26+
`SummaryMetricFamily`, `HistogramMetricFamily` and `InfoMetricFamily` work similarly.
27+
28+
A collector may implement a `describe` method which returns metrics in the same
29+
format as `collect` (though you don't have to include the samples). This is
30+
used to predetermine the names of time series a `CollectorRegistry` exposes and
31+
thus to detect collisions and duplicate registrations.
32+
33+
Usually custom collectors do not have to implement `describe`. If `describe` is
34+
not implemented and the CollectorRegistry was created with `auto_describe=True`
35+
(which is the case for the default registry) then `collect` will be called at
36+
registration time instead of `describe`. If this could cause problems, either
37+
implement a proper `describe`, or if that's not practical have `describe`
38+
return an empty list.

docs/content/exporting/_index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Exporting
3+
weight: 4
4+
---
5+
6+
There are several options for exporting metrics.

0 commit comments

Comments
 (0)