Faactory.Channels.Prometheus
0.10.0
dotnet add package Faactory.Channels.Prometheus --version 0.10.0
NuGet\Install-Package Faactory.Channels.Prometheus -Version 0.10.0
<PackageReference Include="Faactory.Channels.Prometheus" Version="0.10.0" />
paket add Faactory.Channels.Prometheus --version 0.10.0
#r "nuget: Faactory.Channels.Prometheus, 0.10.0"
// Install Faactory.Channels.Prometheus as a Cake Addin
#addin nuget:?package=Faactory.Channels.Prometheus&version=0.10.0
// Install Faactory.Channels.Prometheus as a Cake Tool
#tool nuget:?package=Faactory.Channels.Prometheus&version=0.10.0
Prometheus Metrics
Extends Channels by providing Prometheus metrics.
The exported metrics are:
channels_active_total
: Total number of active channels.channels_bytes_received_total
: Total number of bytes received.channels_bytes_sent_total
: Total number of bytes sent.
The project makes use of prometheus-net.
Usage
Install the package from NuGet
dotnet add package Faactory.Channels.Prometheus
To calculate the metrics, you just need to register the metrics middleware. This can be applied to either a service or a client channel builder.
IChannelBuilder channel = ...;
channel.UsePrometheusMetrics();
To export the metrics, the easiest way is to install prometheus-net.AspNetCore
package and register the pre-built middleware. If no other HTTP functionality is required, this is a good option.
IServiceCollection services = ...;
services.AddMetricServer( options =>
{
options.Port = 8081;
} );
You can find a more detailed sample project under the example folder. There are other ways to export the metrics, which can be found in the prometheus-net documentation.
Labels
By default, metrics are created just with the channelId
label, which contains the channel identifier. However, it is possible to extend this and add more labels to the metrics.
To add more labels, you can add items to the channel's data dictionary. The middleware will automatically add all items with the prefix prometheus.label.
to the metrics.
public class SampleIdentityHandler : ChannelHandler<IdentityInformation>
{
public override Task ExecuteAsync( IChannelContext context, IdentityInformation data )
{
// ...
/*
This adds an `uuid` label to the metrics. The label will be included in all metrics.
*/
context.Channel.Data["prometheus.label.uuid"] = data.UUId;
return Task.CompletedTask;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Faactory.Channels.Core (>= 0.10.0)
- prometheus-net (>= 8.2.1)
-
net8.0
- Faactory.Channels.Core (>= 0.10.0)
- prometheus-net (>= 8.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.