You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -280,6 +280,36 @@ from prometheus_client import start_wsgi_server
280
280
start_wsgi_server(8000)
281
281
```
282
282
283
+
#### Flask
284
+
285
+
To use Prometheus with [Flask](http://flask.pocoo.org/) we need to serve metrics through a Prometheus WSGI application. This can be achieved using [Flask's application dispatching](http://flask.pocoo.org/docs/latest/patterns/appdispatch/). Below is a working example.
286
+
287
+
Save the snippet below in a `myapp.py` file
288
+
289
+
```python
290
+
from flask import Flask
291
+
from werkzeug.wsgi import DispatcherMiddleware
292
+
from prometheus_client import make_wsgi_app
293
+
294
+
# Create my app
295
+
app = Flask(__name__)
296
+
297
+
# Add prometheus wsgi middleware to route /metrics requests
0 commit comments