I have grafana and prometheus running on localhost and trying to run a sample app to get some graphs within grafana. This is my first dip into prometheus.
I am running a simple fastapi server
from fastapi import FastAPI
from prometheus_client import make_asgi_app, Gauge
# Create app
app = FastAPI(debug=False)
metrics_app = make_asgi_app()
app.mount("/metrics", metrics_app)
g = Gauge('my_counter', 'Description of gauge')
@app.get('/inc')
def process_request():
g.inc()
return {}
I am running this with
pipenv run uvicorn fastapi_example:app --port 9090
For the setup within Grafana I only add a Prometheus data source and set the url to http://127.0.0.1:9090/metricsHowever when I navigate to add a panel that exposes the counter
my_counter it just says 'No metrics found' I can however see that the fastapi server is seeing requests and responding with 200 OK.
I also have the first example
for
start_http_server running but that is also not giving me any metrics from within Grafana.
It feels like I am missing something glaringly obvious. Can anyone see anything wrong with my test setup?