Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding prometheus instrumentator for fastapi app #80

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from fastapi import FastAPI

from app.db import database, User

from prometheus_fastapi_instrumentator import Instrumentator

app = FastAPI(title="FastAPI, Docker, and Traefik")
instrumentator = Instrumentator().instrument(app)


@app.get("/")
Expand All @@ -13,6 +14,9 @@ async def read_root():

@app.on_event("startup")
async def startup():
# Expose prometheus metrics using the Instrumentator
# https://github.com/trallnag/prometheus-fastapi-instrumentator
instrumentator.expose(app)
if not database.is_connected:
await database.connect()
# create a dummy entry
Expand Down
16 changes: 6 additions & 10 deletions app/requirements.txt
gitkvark marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#asyncpg==0.27.0
#fastapi==0.89.1
#ormar==0.12.1
#psycopg2-binary==2.9.5
#uvicorn==0.20.0
asyncpg
fastapi
ormar
psycopg2-binary
uvicorn
asyncpg==0.29.0
fastapi==0.106.0
ormar==0.12.2
psycopg2-binary==2.9.9
uvicorn==0.25.0
prometheus-fastapi-instrumentator==6.1.0