Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T23:01:06.000Z (9 months ago)
- Last Synced: 2024-04-13T18:32:47.544Z (9 months 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
[![ci](https://img.shields.io/github/actions/workflow/status/prom-client-net/prom-client-metricserver/ci.yml?branch=main&label=ci&logo=github&style=flat-square)](https://github.com/prom-client-net/prom-client-metricserver/actions/workflows/ci.yml)
[![nuget](https://img.shields.io/nuget/v/Prometheus.Client.MetricServer?logo=nuget&style=flat-square)](https://www.nuget.org/packages/Prometheus.Client.MetricServer)
[![nuget](https://img.shields.io/nuget/dt/Prometheus.Client.MetricServer?logo=nuget&style=flat-square)](https://www.nuget.org/packages/Prometheus.Client.MetricServer)
[![codecov](https://img.shields.io/codecov/c/github/prom-client-net/prom-client-metricserver?logo=codecov&style=flat-square)](https://app.codecov.io/gh/prom-client-net/prom-client-metricserver)
[![codefactor](https://img.shields.io/codefactor/grade/github/prom-client-net/prom-client-metricserver?logo=codefactor&style=flat-square)](https://www.codefactor.io/repository/github/prom-client-net/prom-client-metricserver)
[![license](https://img.shields.io/github/license/prom-client-net/prom-client-metricserver?style=flat-square)](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).