feat: add native Prometheus metrics exporter to stats server#2754
Open
lavr wants to merge 1 commit intounbit:masterfrom
Open
feat: add native Prometheus metrics exporter to stats server#2754lavr wants to merge 1 commit intounbit:masterfrom
lavr wants to merge 1 commit intounbit:masterfrom
Conversation
ecd5a27 to
93c1a79
Compare
Add a built-in Prometheus exposition format endpoint to the uWSGI stats server, eliminating the need for external sidecar exporters like uwsgi_exporter. Metric names are compatible with timonwong/uwsgi_exporter for drop-in replacement. GET /metrics returns Prometheus text format (42 metrics covering global, socket, worker, app, core, and cache stats). All other paths return JSON as before. The prometheus path is configurable via --stats-prometheus-path. The HTTP stats layer is split into uwsgi_stats_read_request() and uwsgi_stats_send_http_header() with an enum uwsgi_stats_format for clean format selection. Includes integration tests for both JSON and Prometheus endpoints.
93c1a79 to
0590ae6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Prometheus has become the de facto standard for application monitoring. In practice, virtually no production deployment goes without Prometheus metrics - it is the first thing teams set up for observability.
In real-world production environments, it is essential to monitor uWSGI internals: worker busyness, request rates, memory consumption, harakiri counts, queue lengths. Currently, the only way to expose these metrics to Prometheus is to run a sidecar exporter (typically uwsgi_exporter). This adds operational complexity - an extra container/process to deploy, configure, and maintain - and consumes additional resources, all just to translate JSON stats into Prometheus format.
This PR eliminates the need for a sidecar by adding native Prometheus exposition format support directly into the uWSGI stats server.
Changes
Usage
No additional flags required in uwsgi config. The
/metricsendpoint is automatically available on the existing stats HTTP server:Prometheus scrape config:
No extra flags, no sidecar.
Closes #1733