-
What Grafana version and what operating system are you using?
Grafana Version 12.0.2 & operating system - Windows 11 -
What are you trying to achieve?
To Connect Grafana’s Infinity plugin / Json fetcher / Json API to a FastAPI backend (JSON API) via a button panel.
Trigger API calls (e.g.,POST /predict
) when the button is clicked to send input value from to FastAPI . -
How are you trying to achieve it?
-
Configured a JSON API data source in Grafana pointing to
http://localhost:8000
(FastAPI). -
Used a button panel with an action to trigger Post call the API endpoint.
-
Enabled CORS in FastAPI to allow requests from Grafana (
http://localhost:3000
). -
What happened?
When Button clicked : “GET / HTTP/1.1” 404 Not Found in backend API
Button panel actions do not trigger successful API calls. -
CORS preflight (
OPTIONS
request) fails despite CORS middleware in FastAPI. -
What did you expect to happen?
-
- Clicking the button should trigger a
POST
request to/predict
and send value from frontend to FastAPI (eg. input value from Text box)
- Clicking the button should trigger a
-
CORS should allow requests from Grafana’s origin (
http://localhost:3000
). -
Can you copy/paste the configuration(s) that you are having problems with?
-
FastAPI CORS Setup
-
app.add_middleware(
CORSMiddleware,
allow_origins=[““], # Or specify your Grafana origin
allow_credentials=True,
allow_methods=[””], # Allow all methods for testing
allow_headers=[“*”],
)
Button Panel Configuration
-
Issue: Missing or incorrect URL/API endpoint in the button action.
-
Fix:
- Set the button’s Link to
http://localhost:8000/predict
. - Use
${__variables}
for dynamic values.
- Set the button’s Link to
-
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
INFO: 127.0.0.1:55699 - “GET / HTTP/1.1” 404 Not Found
INFO: 127.0.0.1:59093 - “GET / HTTP/1.1” 404 Not Found -
Did you follow any online instructions? If so, what is the URL?
*I have tried with cursor AI/ deep seek to fix the issue