Skip to content

prom-client-net/prom-client-metricpusher

Repository files navigation

Prometheus.Client.MetricPusher

ci nuget nuget 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 PushGateaway server that you can install from here.

Install

dotnet add package Prometheus.Client.MetricPusher

Use

Examples

One push. You can use Timer for regularly push to PushGateway:

var pusher = new MetricPusher(new MetricPusherOptions
{
    Endpoint = "http://localhost:9091",
    Job = "pushgateway",
    Instance = "instance"
});

await pusher.PushAsync();

Push with Auth:

var pusher = new MetricPusher(new MetricPusherOptions
{
    Endpoint = "http://localhost:9091",
    Job = "pushgateway",
    Instance = "instance",
    AdditionalHeaders = new Dictionary<string, string> { { "Authorization", "Bearer " + accessToken } }
});

Background server:

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!

License

All contents of this package are licensed under the MIT license.