Awesome
Prometheus.Client.MetricPusher
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
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!
- Report any bugs or issues you find on the issue tracker.
- You can grab the source code at the package's git repository.
License
All contents of this package are licensed under the MIT license.