Skip to content

Grafana

Grafana is the main visualization tool of PerfShop. It aggregates the four telemetry sinks (Prometheus, Loki, Tempo, Pyroscope), exposes 13 shipped dashboards (7 Students, including the PerfShop — Accueil home and perfshop-test-ai provisioned from the test-ai/ package, + 6 Instructors, including the reference dashboard of the lab cahier-des-charges-dashboard) with a differentiated access policy, and allows interactive exploration in Explore mode.

Source of truth

This page is taken from the grafana block in the compose files, the provisioning files grafana/provisioning/datasources/*.yml, grafana/provisioning/dashboards/dashboards.yml, and the initialization script grafana-seed/seed.py.

Pinned version

PerfShop pins Grafana to version 12.0.0 (image grafana/grafana:12.0.0). The other observability components are pinned too in the shipped compose files (docker-compose.desktop.yml, docker-compose.build.yml: Prometheus v3.2.1, Loki and Promtail 3.4.2, Tempo 2.4.2, Pyroscope 1.13.0). For Grafana, an upgrade is especially sensitive, because:

  • The 13 shipped dashboards rely on panel features (flamegraph, traces table, TraceQL editor, auto-units format) introduced in Grafana 11+ and stabilized in 12.
  • The Python seed uses the legacy API POST /api/folders/{uid}/permissions which could evolve in a future major version.
  • The Pyroscope and Tempo datasources depend on native plugins whose configuration format may change.

Upgrading to a later version will require manual validation against the 13 dashboards.

Configuration via environment variables

environment:
  - GF_SECURITY_ADMIN_USER=admin
  - GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD:-perfshop}
  - GF_USERS_ALLOW_SIGN_UP=false
  - GF_SERVER_ROOT_URL=${PUBLIC_GRAFANA_URL:-http://localhost:3002}
  - GF_PANELS_DISABLE_SANITIZE_HTML=true
  - GF_AUTH_ANONYMOUS_ENABLED=true
  - GF_AUTH_ANONYMOUS_ORG_NAME=Main Org.
  - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
  - GF_USERS_DEFAULT_LANGUAGE=${PERFSHOP_UI_LOCALE:-en-US}
Variable Effect
GF_SECURITY_ADMIN_USER / _PASSWORD Grafana superadmin account, used by the seed and by the instructor
GRAFANA_STUDENT_USER / GRAFANA_STUDENT_PASSWORD (perfshop-grafana-seed service) Shared student account, Editor role, created at first start (default values: environment variables)
GF_USERS_ALLOW_SIGN_UP=false Disables self-signup from the UI
GF_SERVER_ROOT_URL Public URL used for absolute links (emails, sharing, OAuth)
GF_PANELS_DISABLE_SANITIZE_HTML=true Allows Text panels to use raw HTML (used by the "Guide" panels of the APM dashboards)
GF_AUTH_ANONYMOUS_ENABLED=true Anonymous access enabled — the key of the pedagogical strategy
GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer Anonymous users only get the Viewer role (read-only)
GF_USERS_DEFAULT_LANGUAGE Grafana UI locale (fr-FR or en-US), driven by PERFSHOP_UI_LOCALE

The internal management port of Grafana is 3000, exposed on host port 3002 by default (GRAFANA_HTTP_PORT variable).

The Docker healthcheck queries /api/health every 10 seconds with start_period: 30s:

healthcheck:
  test: ["CMD-SHELL", "wget -q --spider http://localhost:3000/api/health || exit 1"]
  interval: 10s
  timeout: 5s
  retries: 10
  start_period: 30s

Provisioned datasources

Grafana automatically reads the grafana/provisioning/datasources/ folder at startup and declares four datasources, each with a stable UID used by the JSON dashboards.

flowchart LR
  G["Grafana 12.0.0"]
  G --> P["uid: prometheus<br/>http://prometheus:9090<br/>(default)"]
  G --> L["uid: loki<br/>http://perfshop-loki:3100"]
  G --> T["uid: tempo<br/>http://perfshop-tempo:3200"]
  G --> PY["uid: pyroscope<br/>http://perfshop-pyroscope:4040"]

Prometheus datasource

- name: Prometheus
  type: prometheus
  uid: prometheus
  access: proxy
  url: http://prometheus:9090
  isDefault: true
  editable: true
  jsonData:
    timeInterval: "5s"
  • isDefault: true: this is the datasource selected by default in the panel editor and in Explore.
  • timeInterval: "5s": tells Grafana about the actual scrape_interval so that rate() and irate() functions are properly calibrated when the user does not specify the window.

Loki datasource

- name: Loki
  type: loki
  uid: loki
  access: proxy
  url: http://perfshop-loki:3100
  isDefault: false
  editable: true
  jsonData:
    maxLines: 1000
    timeout: 60
  • maxLines: 1000: limits the number of lines returned by default in log panels (can be overridden per panel).
  • timeout: 60: query timeout on the Grafana side, in seconds.

Tempo datasource

- name: Tempo
  type: tempo
  uid: tempo
  access: proxy
  url: http://perfshop-tempo:3200
  isDefault: false
  editable: true
  jsonData:
    httpMethod: GET
    tracesToLogsV2:
      datasourceUid: loki
      spanStartTimeShift: "-1m"
      spanEndTimeShift: "1m"
      tags:
        - key: service.name
          value: app
      filterByTraceID: true
      filterBySpanID: false
      customQuery: false
    tracesToMetrics:
      datasourceUid: prometheus
      spanStartTimeShift: "-1m"
      spanEndTimeShift: "1m"
      tags:
        - key: service.name
          value: app
    serviceMap:
      datasourceUid: prometheus
    search:
      hide: false
    nodeGraph:
      enabled: true
    lokiSearch:
      datasourceUid: loki

This is the most richly configured datasource. Three cross-correlations are enabled:

  • tracesToLogsV2 → Loki: from any span in the trace view, you can click to open Loki with a ±1 min time filter around the span and an automatic traceID filter.
  • tracesToMetrics → Prometheus: from a span, you can display the Prometheus metrics for the operation over the same time window.
  • serviceMap: uses the traces_service_graph_* metrics produced by Tempo's metrics_generator and stored in Prometheus to generate the service map.
  • nodeGraph: enabled: true: enables the graph visualization for traces.
  • lokiSearch: enables searching for correlated logs directly from the Tempo editor.

Pyroscope datasource

- name: Pyroscope
  type: grafana-pyroscope-datasource
  uid: pyroscope
  access: proxy
  url: http://perfshop-pyroscope:4040
  isDefault: false
  editable: true

Minimal configuration — Pyroscope has no special correlations to configure; the native Grafana plugin handles everything.

Folders and dashboard provisioning

The shipped dashboards are organized into two provisioned folders, with two separate providers; a third folder, created by the seed, receives the dashboards built by students.

# grafana/provisioning/dashboards/dashboards.yml
apiVersion: 1
providers:
  - name: 'PerfShop Dashboards — Élèves'
    orgId: 1
    folder: 'Élèves'
    folderUid: 'perfshop-eleves'
    type: file
    disableDeletion: false
    updateIntervalSeconds: 10
    allowUiUpdates: true
    options:
      path: /etc/grafana/dashboards/eleves

  - name: 'PerfShop Dashboards — Formateurs'
    orgId: 1
    folder: 'Formateurs'
    folderUid: 'perfshop-formateurs'
    type: file
    disableDeletion: false
    updateIntervalSeconds: 10
    allowUiUpdates: true
    options:
      path: /etc/grafana/dashboards/formateurs

A third folder, Ateliers élèves (perfshop-ateliers), is not provisioned from files: the seed creates it at first start. Students save there the dashboards they build (lab observabilite-apm/cahier-des-charges-dashboard).

Aspect Students folder (Élèves) Instructors folder (Formateurs) Ateliers élèves folder
folderUid perfshop-eleves perfshop-formateurs perfshop-ateliers
Origin provisioning: ./grafana/dashboards/eleves/ + ./test-ai/docker/grafana/dashboards/ (external provider) provisioning: ./grafana/dashboards/formateurs/ created by the seed (empty at first)
Shipped dashboards 7: PerfShop — Accueil, APM, Backend, Frontend, Logs, JMeter (under eleves/) + perfshop-test-ai (test-ai/ package, see qa/test-ai-live-viewer.md) 6: APM, Backend, Frontend, Logs, Vue Générale Containers, SRE — Première minute (backend) (reference dashboard of the lab cahier-des-charges-dashboard) —
ACL set by the seed read-only for every role (Viewer, Editor) Admin only Viewer: read; Editor: write
updateIntervalSeconds / allowUiUpdates / disableDeletion 10 / true / false 10 / true / false —

The bind mounts in compose:

volumes:
  - grafana-data:/var/lib/grafana
  - ./grafana/provisioning:/etc/grafana/provisioning
  - ./grafana/dashboards:/etc/grafana/dashboards

Access strategy — the key element

PerfShop distinguishes three user populations on Grafana:

flowchart TB
  V["Anonymous visitor<br/>(not signed in)"]
  E["Student account « eleve »<br/>(Editor role)"]
  A["Administrator account<br/>(instructor)"]

  subgraph G["Grafana"]
    direction TB
    FE["Students folder (Élèves)<br/>(read-only)"]
    FA["Ateliers élèves folder<br/>(write: Editor)"]
    FF["Instructors folder (Formateurs)<br/>(Admin only)"]
  end

  V -->|read| FE
  V -->|read| FA
  V -.-|❌ 403| FF
  E -->|read| FE
  E -->|✅ builds dashboards| FA
  E -.-|❌ 403| FF
  A -->|✅| FE
  A -->|✅| FA
  A -->|✅| FF

How it works in practice

  1. GF_AUTH_ANONYMOUS_ENABLED=true + GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer → any visitor is an anonymous user with the Viewer role. They land on PerfShop — Accueil (Students folder), the organization home set by the seed: which dashboard to open for which signal.
  2. The student account (GRAFANA_STUDENT_USER, eleve by default) has the Editor role: it can use Explore and build dashboards, which it saves in Ateliers élèves; the Students and Instructors folders stay closed to it for writing (ACL). Its default credentials are shown on the platform's welcome page ("Account(s)" column); the instructor can change the password in Grafana: the seed never resets it.
  3. The administrator account (instructor) sees everything; its home is Vue Générale Containers (Instructors folder).

\"Blind\" assessments

Default credentials are public (documentation, welcome page). For an assessment, change the administrator password (GF_SECURITY_ADMIN_PASSWORD) before the session: otherwise a student can open the Instructors folder.

The grafana-seed/seed.py seed

The perfshop-grafana-seed service (python:3.11-slim image, standard library only: nothing is downloaded at startup, the platform deploys offline) runs at every docker compose up, then stops. It:

  1. waits for Grafana on /api/health (5 s × 90), then for the provisioned folders;
  2. creates the Ateliers élèves folder if missing;
  3. sets the ACLs (POST /api/folders/{uid}/permissions, which replaces the whole ACL): Instructors Admin=4; Students Viewer=1, Editor=1, Admin=4; Ateliers élèves Viewer=1, Editor=2, Admin=4 (1 = View, 2 = Edit, 4 = Admin);
  4. creates the student account if missing (POST /api/admin/users) and gives it the Editor role (PATCH /api/org/users/{id});
  5. sets the homes: PerfShop — Accueil for the organization (PATCH /api/org/preferences), Vue Générale Containers for the administrator account (PATCH /api/user/preferences);
  6. checks the result from the users' point of view: Instructors folder refused to anonymous visitors, correct anonymous home, student account read-only in Students and allowed to save in Ateliers élèves.

Exit code: 0 when everything is in place, 1 otherwise — a failure shows in docker compose ps -a (Exited (1)) and in docker logs perfshop-grafana-seed. Tests: grafana-seed/test_seed.py (in-memory fake Grafana, standard library).

sequenceDiagram
  autonumber
  participant S as perfshop-grafana-seed
  participant G as Grafana

  S->>G: GET /api/health (5 s × 90)
  G-->>S: 200 OK
  S->>G: GET /api/folders/{perfshop-formateurs, perfshop-eleves}
  G-->>S: 200 (provisioned folders)
  S->>G: GET /api/folders/perfshop-ateliers → 404 ⇒ POST /api/folders
  S->>G: POST /api/folders/{uid}/permissions × 3
  S->>G: GET /api/users/lookup?loginOrEmail=eleve → 404 ⇒ POST /api/admin/users
  S->>G: PATCH /api/org/users/{id} {"role":"Editor"}
  S->>G: PATCH /api/org/preferences {"homeDashboardUID":"perfshop-accueil"}
  S->>G: PATCH /api/user/preferences {"homeDashboardUID":"perfshop-general-v1"}
  S->>G: checks (anonymous, student account)
  Note over S: exit code 0 (1 on failure)

Seed idempotency

The seed can be re-run at any time (docker compose up perfshop-grafana-seed): ACLs and homes are set again identically, the folder and the student account are only created when missing, and the student account's password is never reset.

Volumes and persistent data

Volume Mount Content
grafana-data (named volume) /var/lib/grafana Grafana SQLite database, user sessions, installed plugins, manually created dashboards, custom ACLs
./grafana/provisioning (bind mount) /etc/grafana/provisioning Provisioning files for datasources and dashboards (read-only in practice)
./grafana/dashboards (bind mount) /etc/grafana/dashboards 12 shipped JSON files (6 Students + 6 Instructors)
./test-ai/docker/grafana/dashboards (nested bind mount) /etc/grafana/dashboards/test-ai (:ro) 1 SSOT JSON file test-ai.json from the sibling package (T1-1 pattern, see ../qa/test-ai-live-viewer.md#installation)

Modifying a shipped dashboard

The shipped JSON dashboards are reloaded every 10 s by Grafana (updateIntervalSeconds: 10). A change made in the UI is kept for 10 s then overwritten by the JSON file content. To durably modify a shipped dashboard, edit the corresponding JSON file in grafana/dashboards/{eleves|formateurs}/ and repackage it in the deployment. For perfshop-test-ai, the SSOT lives outside these two folders — edit test-ai/docker/grafana/dashboards/test-ai.json then follow the 5-step workflow documented in ../qa/test-ai-live-viewer.md#installation.

To go further