https://github.com/prom-client-net/prom-client-metricpusher
Push metrics to Pushgateway
https://github.com/prom-client-net/prom-client-metricpusher
metrics prometheus prometheus-client
Last synced: 7 months ago
JSON representation
Push metrics to Pushgateway
- Host: GitHub
- URL: https://github.com/prom-client-net/prom-client-metricpusher
- Owner: prom-client-net
- License: mit
- Created: 2017-09-18T12:46:49.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2026-01-02T01:32:40.000Z (7 months ago)
- Last Synced: 2026-01-07T16:03:56.534Z (7 months ago)
- Topics: metrics, prometheus, prometheus-client
- Language: C#
- Homepage:
- Size: 339 KB
- Stars: 19
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Prometheus.Client.MetricPusher
[](https://github.com/prom-client-net/prom-client-metricpusher/actions/workflows/ci.yml)
[](https://www.nuget.org/packages/Prometheus.Client.MetricPusher)
[](https://www.nuget.org/packages/Prometheus.Client.MetricPusher)
[](https://app.codecov.io/gh/prom-client-net/prom-client-metricpusher)
[](https://github.com/prom-client-net/prom-client-metricpusher/blob/main/LICENSE)
## Pushgateway
Sometimes when it is not possible to pull e.g. - nodes behind LB or there is a worker like daemon or windows service that does not have HTTP endpoint still there is way to push your metrics to Pushgateway server that you can install from [here](https://github.com/prometheus/pushgateway/releases).
## Install
```sh
dotnet add package Prometheus.Client.MetricPusher
```
## Use
[Examples](https://github.com/prom-client-net/prom-examples)
One push. You can use Timer for regularly push to Pushgateway:
```c#
var pusher = new MetricPusher(new MetricPusherOptions
{
Endpoint = "http://localhost:9091",
Job = "pushgateway",
Instance = "instance"
});
await pusher.PushAsync();
```
Push with Auth:
```c#
var pusher = new MetricPusher(new MetricPusherOptions
{
Endpoint = "http://localhost:9091",
Job = "pushgateway",
Instance = "instance",
AdditionalHeaders = new Dictionary { { "Authorization", "Bearer " + accessToken } }
});
```
Background server:
```c#
var pusher = new MetricPusher(new MetricPusherOptions
{
Endpoint = "http://localhost:9091",
Job = "pushgateway"
});
var worker = new MetricPushServer(pusher);
worker.Start();
// code
worker.Stop();
```
## Contribute
Contributions to the package are always welcome!
* Report any bugs or issues you find on the [issue tracker](https://github.com/prom-client-net/prom-client-metricpusher/issues).
* You can grab the source code at the package's [git repository](https://github.com/prom-client-net/prom-client-metricpusher).
## License
All contents of this package are licensed under the [MIT license](https://opensource.org/licenses/MIT).