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

Navigating to http://localhost:9090/metrics/ shows my_counter 0.0 if I 
navigate to the /inc I can observe the number increasing.

For the setup within Grafana I only add a Prometheus data source and set 
the url to http://127.0.0.1:9090/metrics

However 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?

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/a1f106d4-2595-4b2e-b8ec-1f75e32a497dn%40googlegroups.com.

Reply via email to