Push metrics to Pushgateaway for Prometheus.Client
$ dotnet add package Prometheus.Client.MetricPusherdotnet add package Prometheus.Client.MetricPusherOne 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();
...
worker.Stop();
Contributions to the package are always welcome!
All contents of this package are licensed under the MIT license.