Add Metrics (OpenTelemetry with Prometheus Export endpoint) #2010
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ever since .NET 8.0, there are built-in metrics for both ASP.NET Core and also our PostgreSQL Npgsql.
With the OpenTelemetry nuget package, we collect these metrics. And with the Prometheus Export nuget package we can expose them on an endpoint
/Metrics
, which I guarded behind the SeeDiagnostics permission.If you access that endpoint you will see all live metric data in Prometheus format, which is a very big text file of stuff like
And that's all this PR does. No data is stored, no data is visualized.
Actually visualizing this data is difficult, because nothing is ever simple.
You need to set up your own Prometheus server that scrapes off this data. This is where data is actually stored: in your own Prometheus instance.
To visualize this data, you need another server like Grafana that queries your Prometheus server and makes cool lines on charts and stuff.
Did I say nothing is ever simple? You can't send http headers with the Prometheus server, so you need another server that acts as a reverse proxy and adds your authentication cookie with the request.