https://github.com/PrometheusClientNet/Prometheus.Client.MetricServer
Standalone Kestrel server for the Prometheus.Client
https://github.com/PrometheusClientNet/Prometheus.Client.MetricServer
metrics prometheus prometheus-client
Last synced: 5 months ago
JSON representation
Standalone Kestrel server for the Prometheus.Client
- Host: GitHub
- URL: https://github.com/PrometheusClientNet/Prometheus.Client.MetricServer
- Owner: prom-client-net
- License: mit
- Created: 2017-05-05T23:06:02.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T23:01:06.000Z (about 1 year ago)
- Last Synced: 2024-04-13T18:32:47.544Z (about 1 year ago)
- Topics: metrics, prometheus, prometheus-client
- Language: C#
- Homepage:
- Size: 294 KB
- Stars: 14
- Watchers: 2
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- fucking-awesome-dotnet-core - Prometheus.Client.MetricServer - MetricServer for the Prometheus.Client. (Frameworks, Libraries and Tools / Code Analysis and Metrics)
- awesome-dotnet-core - Prometheus.Client.MetricServer - MetricServer for the Prometheus.Client. (Frameworks, Libraries and Tools / Code Analysis and Metrics)
- awesome-dotnet-core - Prometheus.Client.MetricServer - MetricServer for the Prometheus.Client. (Frameworks, Libraries and Tools / Code Analysis and Metrics)
README
# Prometheus.Client.MetricServer
[](https://github.com/prom-client-net/prom-client-metricserver/actions/workflows/ci.yml)
[](https://www.nuget.org/packages/Prometheus.Client.MetricServer)
[](https://www.nuget.org/packages/Prometheus.Client.MetricServer)
[](https://app.codecov.io/gh/prom-client-net/prom-client-metricserver)
[](https://www.codefactor.io/repository/github/prom-client-net/prom-client-metricserver)
[](https://github.com/prom-client-net/prom-client-metricserver/blob/main/LICENSE)Extension for [Prometheus.Client](https://github.com/prom-client-net/prom-client)
## Install
```sh
dotnet add package Prometheus.Client.MetricServer
```## Use
[Examples](https://github.com/prom-client-net/prom-examples)
Simple Console App with static MetricFactory:
```c#
public static void Main(string[] args)
{
var options = new MetricServerOptions
{
Port = 9091
};var metricServer = new MetricServer(options);
metricServer.Start();var counter = Metrics.DefaultFactory.CreateCounter("test_count", "helptext");
counter.Inc();metricServer.Stop();
}```
Worker with DI [Prometheus.Client.DependencyInjection](https://github.com/prom-client-net/prom-client-dependencyinjection):
```c#
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices((_, services) =>
{
services.AddMetricFactory();
services.AddSingleton(sp => new MetricServer(
new MetricServerOptions
{
CollectorRegistryInstance = sp.GetRequiredService(),
UseDefaultCollectors = true
}));
services.AddHostedService();
}).Build();var metricServer = host.Services.GetRequiredService();
try
{
metricServer.Start();
await host.RunAsync();
}
catch (Exception ex)
{
Console.WriteLine("Host Terminated Unexpectedly");
}
finally
{
metricServer.Stop();
}
}```
## License
All contents of this package are licensed under the [MIT license](https://opensource.org/licenses/MIT).