"Data source" means something specific in Grafana. Prometheus data source has a well defined path for its queries; you can't modify that. There is an HTTP JSON+API datasource for Grafana if you search its plugins - https://marcus.se.net/grafana-json-datasource/

However, that's completely bypassing Prometheus longer-term storage. Prometheus reads scrape targets, then collects and aggregates that.

To do so, your API would need to expose any route that returns Prometheus "exposition format", not JSON. This route is put in the Prometheus config file, not into Grafana anywhere.

While Prometheus can load random data, it's better to use Counter, Guage, etc types it expects

The OpenTelemetry project should be able to be used in any framework, and there are examples in their documentation for the Python module.

If your goal is to just get any data, not metrics, into Grafana, using an RDBMS or Mongodb, or other supported data sources might be better

Answer from OneCricketeer on Stack Overflow
🌐
GitHub
github.com › Kludex › fastapi-prometheus-grafana
GitHub - Kludex/fastapi-prometheus-grafana: FasAPI + Prometheus + Grafana! :tada: · GitHub
FasAPI + Prometheus + Grafana! :tada:. Contribute to Kludex/fastapi-prometheus-grafana development by creating an account on GitHub.
Author: Kludex
🌐
Medium
dimasyotama.medium.com › building-a-powerful-observability-stack-for-fastapi-with-prometheus-grafana-loki-426822422fd6
Building a Powerful Observability Stack for FastAPI with Prometheus, Grafana & Loki | by Dimas Yoga Pratama | Medium
August 21, 2025 - Note the FastAPI service is named the-app and runs on port 5060. version: "3.8" services: prometheus-app: image: prom/prometheus:latest restart: unless-stopped container_name: prometheus-observer ports: - 9090:9090 volumes: - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml networks: - monitoring grafana: image: grafana/grafana container_name: grafana-observer restart: unless-stopped depends_on: - prometheus-app - loki-app ports: - 3000:3000 volumes: - ./grafana/provisioning:/etc/grafana/provisioning environment: - GF_SECURITY_ADMIN_USER=admin - GF_SECURITY_ADMIN_PASSWORD=admin netwo
🌐
DEV Community
dev.to › ken_mwaura1 › getting-started-monitoring-a-fastapi-app-with-grafana-and-prometheus-a-step-by-step-guide-3fbn
Getting Started: Monitoring a FastAPI App with Grafana and Prometheus - A Step-by-Step Guide - DEV Community
January 30, 2025 - With Prometheus now installed and configured in a Docker container, and your FastAPI app instrumented with Prometheus metrics, you are ready to move on to the next steps of integrating Grafana for visualization and analysis.astapi@db/hello_fastapi_dev depends_on: - db db: image: postgres:13.1-alpine volumes: - postgres_data:/var/lib/postgresql/data/ environment: - POSTGRES_USER=hello_fastapi - POSTGRES_PASSWORD=hello_fastapi - POSTGRES_DB=hello_fastapi_dev ports: - "5432:5432" prometheus: image: prom/prometheus container_name: prometheus ports: - 9090:9090 volumes: - ./prometheus_data/promethe
🌐
Grafana
grafana.com › grafana › dashboards › 16110-fastapi-observability
FastAPI Observability | Grafana Labs
Telemetry FastAPI application with three pillars of observability on Grafana: Traces with Tempo and OpenTelemetry Python SDK · Metrics with Prometheus and Prometheus Python Client · Logs with Loki · Check more details on the GitHub repository: FastAPI with Observability.
🌐
Towards AI
pub.towardsai.net › fastapi-observability-lab-with-prometheus-and-grafana-complete-guide-f12da15a15fd
FastAPI Observability Lab with Prometheus and Grafana: Complete Guide | by Faizulkhan | Towards AI
July 2, 2026 - version: "3.8" services: app: build: . container_name: fastapi-observability-app ports: - "8000:8000" networks: - monitoring environment: - PYTHONUNBUFFERED=1 prometheus: image: prom/prometheus:latest container_name: fastapi-observability-prometheus volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml ports: - "9090:9090" networks: - monitoring grafana: image: grafana/grafana:latest container_name: fastapi-observability-grafana ports: - "3030:3000" environment: - GF_SECURITY_ADMIN_USER=admin - GF_SECURITY_ADMIN_PASSWORD=admin volumes: - grafana-storage:/var/lib/grafana depends_on: - prometheus networks: - monitoring networks: monitoring: driver: bridge volumes: grafana-storage:
🌐
Towards AI
towardsai.net › home › publication › latest › fastapi observability lab with prometheus and grafana: complete guide
FastAPI Observability Lab with Prometheus and Grafana: Complete Guide | Towards AI
December 4, 2025 - ┌─────────────────┐ │ FastAPI App │ ← Exposes /metrics endpoint │ (Port 8000) │ └────────┬────────┘ │ HTTP GET /metrics │ (every 15 seconds) ▼ ┌─────────────────┐ │ Prometheus │ ← Scrapes and stores metrics │ (Port 9090) │ └────────┬────────┘ │ PromQL Queries │ (via HTTP API) ▼ ┌─────────────────┐ │ Grafana │ ← Visualizes metrics in dashboards │ (Port 3030) │ └─
🌐
Medium
medium.com › @gribenyukdenis › fastapi-prometheus-graphana-graylog-in-docker-compose-example-c4be14e3057f
FastAPI, Prometheus, Grafana, Graylog in docker-compose example | by Denis Gr | Medium
December 18, 2023 - In this comprehensive guide, we have successfully set up a FastAPI application integrated with Prometheus, Grafana, and Graylog using Docker Compose.
🌐
Medium
medium.com › @bhagyarana80 › monitoring-fastapi-with-prometheus-and-grafana-2a1df999966f
Monitoring FastAPI with Prometheus and Grafana | by Bhagya Rana | Medium
August 16, 2025 - Prometheus excels at collecting time-series metrics. It scrapes your FastAPI app endpoints, stores them efficiently, and makes them queryable. Think of it as the “data warehouse for your service’s heartbeat.” · Grafana makes sense of ...
Find elsewhere
🌐
Binadit
binadit.com › home › tutorials › monitor fastapi applications with prometheus grafana
FastAPI Prometheus Grafana Monitoring Guide - Binadit Tutorials
May 19, 2026 - Complete guide to monitor FastAPI apps with Prometheus metrics and Grafana dashboards. Includes alerting, custom metrics, and production setup.
🌐
GitConnected
levelup.gitconnected.com › monitoring-fastapi-with-grafana-prometheus-a-5-minute-guide-658280c7f358
Monitoring FastAPI with Grafana + Prometheus: A 5-Minute Guide | by Andre Williams | Level Up Coding
August 4, 2025 - Then log into Grafana at ... your preloaded dashboard under “Dashboards”. ... Basically your application (FastAPI) has embedded prometheus code that logs these metrics after the startup of the server....
🌐
Medium
medium.com › @diwasb54 › building-a-production-ready-monitoring-stack-for-fastapi-applications-a-complete-guide-with-bce2af74d258
Building a Production-Ready Monitoring Stack for FastAPI Applications: A Complete Guide with Prometheus and Grafana | by Diwash Bhandari | Software Developer | Medium
August 12, 2025 - # 🔌 Automatic datasource configuration # No manual setup required! apiVersion: 1 datasources: - name: Prometheus type: prometheus access: proxy url: http://prometheus:9090 isDefault: true editable: true jsonData: timeInterval: "5s" ... # 📊 Dashboard auto-provisioning apiVersion: 1 providers: - name: 'FastAPI Dashboards' orgId: 1 folder: 'FastAPI' type: file disableDeletion: false updateIntervalSeconds: 10 allowUiUpdates: true options: path: /etc/grafana/provisioning/dashboards
🌐
DevOps.dev
blog.devops.dev › monitoring-fastapi-using-grafana-and-prometheus-bc9a58c54cf2
Monitoring FastAPI Using Grafana and Prometheus | by Mohit Rathore | DevOps.dev
October 1, 2024 - Monitoring FastAPI Using Grafana and Prometheus Monitoring APIs is crucial to ensure their health, performance, and reliability. In this guide, we’ll walk through setting up monitoring for a …
🌐
DEV Community
dev.to › kaushikcoderpy › fastapi-observability-with-prometheus-loki-grafana-complete-2026-guide-jkj
FastAPI Observability with Prometheus, Loki & Grafana (Complete 2026 Guide) - DEV Community
May 14, 2026 - version: '3.8' volumes: prometheus-data: grafana-data: loki-data: services: api: build: . restart: unless-stopped ports: - "8000:8000" labels: logging_job: fastapi prometheus: image: prom/prometheus:v2.45.0 restart: unless-stopped volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus-data:/prometheus ports: - "9090:9090" loki: image: grafana/loki:2.9.0 restart: unless-stopped volumes: - ./loki-config.yml:/etc/loki/local-config.yaml:ro - loki-data:/loki ports: - "3100:3100" command: -config.file=/etc/loki/local-config.yaml promtail: image: grafana/promtail:2.9.0 restart: unless-stopped volumes: - /var/lib/docker/containers:/var/lib/docker/containers:ro - /var/run/docker.sock:/var/run/docker.sock:ro
Author: Kludex
🌐
GitHub
github.com › blueswen › fastapi-observability
GitHub - blueswen/fastapi-observability: Observe FastAPI app with three pillars of observability: Traces (Tempo), Metrics (Prometheus), Logs (Loki) on Grafana through OpenTelemetry. · GitHub
Observe FastAPI app with three pillars of observability: Traces (Tempo), Metrics (Prometheus), Logs (Loki) on Grafana through OpenTelemetry. - blueswen/fastapi-observability
Author: blueswen
🌐
Medium
medium.com › @hitorunajp › prometheus-on-a-fastapi-application-aa25e5223a9e
Prometheus on a FastAPI application | by Hitoruna | Medium
September 1, 2025 - Prometheus excels at collecting and storing time-series data, while Grafana is a powerful data visualization platform that can display data from various sources, including Prometheus.
🌐
Paragraph
paragraph.com › logic & legacy › fastapi observability with prometheus, loki & grafana (complete 2026 guide)
FastAPI Observability with Prometheus, Loki & Grafana (Complete 2026 Guide)
May 14, 2026 - version: '3.8' volumes: prometheus-data: grafana-data: loki-data: services: api: build: . restart: unless-stopped ports: - "8000:8000" labels: logging_job: fastapi prometheus: image: prom/prometheus:v2.45.0 restart: unless-stopped volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus-data:/prometheus ports: - "9090:9090" loki: image: grafana/loki:2.9.0 restart: unless-stopped volumes: - ./loki-config.yml:/etc/loki/local-config.yaml:ro - loki-data:/loki ports: - "3100:3100" command: -config.file=/etc/loki/local-config.yaml promtail: image: grafana/promtail:2.9.0 restart: unless-stopped volumes: - /var/lib/docker/containers:/var/lib/docker/containers:ro - /var/run/docker.sock:/var/run/docker.sock:ro