Allegro.Prometheus.TrueRpsMetric
1.0.0
Prefix Reserved
dotnet add package Allegro.Prometheus.TrueRpsMetric --version 1.0.0
NuGet\Install-Package Allegro.Prometheus.TrueRpsMetric -Version 1.0.0
<PackageReference Include="Allegro.Prometheus.TrueRpsMetric" Version="1.0.0" />
paket add Allegro.Prometheus.TrueRpsMetric --version 1.0.0
#r "nuget: Allegro.Prometheus.TrueRpsMetric, 1.0.0"
// Install Allegro.Prometheus.TrueRpsMetric as a Cake Addin #addin nuget:?package=Allegro.Prometheus.TrueRpsMetric&version=1.0.0 // Install Allegro.Prometheus.TrueRpsMetric as a Cake Tool #tool nuget:?package=Allegro.Prometheus.TrueRpsMetric&version=1.0.0
Allegro.Prometheus.TrueRpsMetric
This library contains the "true RPS" aka "max RPS in last scrapping period" metric, based on prometheus-net library.
What is the "true RPS" metric
The prometheus-net library provides some useful metrics for monitoring the HTTP traffic
of your app, such as http_request_duration_seconds
histogram or the http_requests_in_progress
gauge. However, when monitoring a high
throughput system it is sometimes hard to notice very short peaks in HTTP calls - let's say originating from some marketing campaign.
The typical scrapping interval for Prometheus is 1 minute, but even shorter intervals might be too long to catch a peak that lasted for
a few seconds.
This is where the idea of the "true RPS" metric came from. At Allegro Pay, we wanted to be aware that our services received short, but high
peaks of incoming calls. The "true RPS" metric can be also described as "max RPS over scrapping period". Every time prometheus scrapes
the metrics endpoint, the http_request_max_rps
gives the max RPS that was observed since the previous scrape.
To avoid the collected metrics to be disturbed by developers or administrators manually calling the metrics endpoint, there is
a MinPublishInterval
configuration property available. If the interval between two scrapes is shorter than the MinPublishInterval
,
the counter will not be reset. This should be set to an interval just a bit shorter than prometheus scrapping interval.
How to...
Use the metric
Just add the TrueRpsMiddleware
somewhere between the UseRouting()
and UseEndpoints()
invocations.
app.UseRouting();
(...)
app.UseMiddleware<TrueRpsMiddleware>();
(...)
app.UseHttpMetrics();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapMetrics();
});
Use custom collector registry
services.Configure<TrueRpsMetricConfiguration>(opt => opt.Registry = myRegistry);
Run the Demo
You can test the metric using the provided Demo app. It is located under /samples/Allegro.Prometheus.Demo
. Just run the project and call following endpoints:
GET https://localhost:7274/demo
GET https://localhost:7274/metrics
You should be able to see the http_request_max_rps
metric.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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 was computed. 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. |
-
net6.0
- Microsoft.AspNetCore.Routing.Abstractions (>= 2.2.0)
- prometheus-net (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 263 | 10/14/2022 |