Files
mtusi2026lab7/infra/grafana/provisioning/datasources/datasources.yaml

93 lines
3.1 KiB
YAML

# Grafana datasources, provisioned at start (nothing is clicked by hand). The UIDs are FIXED:
# the dashboard JSON, the trace->logs and logs->trace links refer to exactly these UIDs
# (prometheus / loki / tempo). A datasource without a fixed uid gets a random one and every
# reference to it breaks ("data source not found").
# Lab 7: every datasource is HTTPS with server verification (internal CA, serverName = the SAN)
# and Grafana's own client certificate (SAN grafana): the three backends require one, Prometheus
# also checks the SAN allowlist. The PEM files are read at provisioning time ($__file{}), from
# Docker secrets mounted only into Grafana.
apiVersion: 1
deleteDatasources:
- {name: Prometheus, orgId: 1}
- {name: Loki, orgId: 1}
- {name: Tempo, orgId: 1}
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: https://prometheus:9090
isDefault: true
editable: false
secureJsonData: &tls_files
tlsCACert: $__file{/run/secrets/internal-ca.crt}
tlsClientCert: $__file{/run/secrets/grafana.crt}
tlsClientKey: $__file{/run/secrets/grafana.key}
jsonData:
tlsAuth: true
tlsAuthWithCACert: true
serverName: prometheus
httpMethod: POST
timeInterval: 15s # = scrape/evaluation interval: $__rate_interval >= 4 x 15 s
prometheusType: Prometheus
prometheusVersion: 3.16.0
manageAlerts: true # show the Prometheus alert rules in Grafana's alert list
exemplarTraceIdDestinations: []
- name: Loki
uid: loki
type: loki
access: proxy
url: https://loki:3100
editable: false
secureJsonData: *tls_files
jsonData:
tlsAuth: true
tlsAuthWithCACert: true
serverName: loki
maxLines: 1000
# log line -> its trace in Tempo (trace_id is structured metadata of the OTLP record)
derivedFields:
- name: trace_id
matcherType: label
matcherRegex: trace_id
datasourceUid: tempo
url: "$${__value.raw}"
urlDisplayLabel: "Trace in Tempo"
- name: Tempo
uid: tempo
type: tempo
access: proxy
url: https://tempo:3200
editable: false
secureJsonData: *tls_files
jsonData:
tlsAuth: true
tlsAuthWithCACert: true
serverName: tempo
# span -> the log records of the same trace (and service) in Loki
tracesToLogsV2:
datasourceUid: loki
spanStartTimeShift: "-5m"
spanEndTimeShift: "5m"
customQuery: true
query: '{service_name="$${__span.tags["service.name"]}"} | trace_id="$${__trace.traceId}"'
tracesToMetrics:
datasourceUid: prometheus
spanStartTimeShift: "-5m"
spanEndTimeShift: "5m"
tags:
- {key: service.name, value: job}
queries:
- name: HTTP p95 of this service
query: 'histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{$$__tags}[1m])))'
search:
hide: false
nodeGraph:
enabled: false
lokiSearch:
datasourceUid: loki