Monitoring stack for K3s based on Prometheus, Grafana, Loki, Alloy, and Blackbox Exporter.
Prometheusscraping application metrics, blackbox HTTP healthchecks, and K3s cAdvisor metrics from kubelet.Grafanawith provisioned dashboards, alerting, and datasources mounted from KubernetesConfigMaps.Lokifor log storage with persistent volume.Alloyrunning as aDaemonSetto collect Kubernetes pod logs and forward them to Loki.Blackbox Exporterfor external HTTP healthchecks.
monitoring-namespace.yaml: namespace for the monitoring stack.prometheus/:Deployment,Service,ConfigMap, and RBAC for Prometheus.grafana/:Deployment,Service,PVC, provisionedConfigMaps, and Grafana source files.loki/:Deployment,Service,PVC, andConfigMapfor Loki.alloy/:DaemonSet, RBAC,ServiceAccount, andConfigMapfor log collection in Kubernetes.blackbox/:Deployment,Service, andConfigMapfor blackbox checks.config/: legacy Docker-era source configs kept as references.compose.yaml: older Docker-based production stack kept in the repo for reference.
The current deployment target is K3s.
Apply the namespace first:
kubectl apply -f monitoring-namespace.yamlThen apply the components:
kubectl apply -f loki/configmap.yaml
kubectl apply -f loki/pvc.yaml
kubectl apply -f loki/deployment.yaml
kubectl apply -f loki/service.yaml
kubectl apply -f blackbox/configmap.yaml
kubectl apply -f blackbox/deployment.yaml
kubectl apply -f blackbox/service.yaml
kubectl apply -f alloy/serviceaccount.yaml
kubectl apply -f alloy/rbac.yaml
kubectl apply -f alloy/configmap.yaml
kubectl apply -f alloy/daemonset.yaml
kubectl apply -f prometheus/rbac.yaml
kubectl apply -f prometheus/configmap.yaml
kubectl apply -f prometheus/deployment.yaml
kubectl apply -f prometheus/service.yaml
kubectl apply -f grafana/configmap-grafana-ini.yaml
kubectl apply -f grafana/configmap-grafana-datasources.yaml
kubectl apply -f grafana/configmap-grafana-alerting.yaml
kubectl apply -f grafana/configmap-grafana-dashboards.yaml
kubectl apply -f grafana/configmap-grafana-dashboards-2.yaml
kubectl apply -f grafana/pvc.yaml
kubectl apply -f grafana/deployment.yaml
kubectl apply -f grafana/service.yamlGrafana expects an existing secret named grafana-secret in namespace monitoring with these keys:
EMAIL_USERNAMEEMAIL_PASSWORDKEYCLOAK_CLIENT_IDKEYCLOAK_CLIENT_SECRET
Grafana provisions:
- Prometheus as the default datasource
- Loki as the logs datasource
- dashboards from
grafana/dashboards/ - alerting resources from
grafana/alerting/ - configuration from
grafana/config/grafana.ini
Dashboard manifests are split across two ConfigMaps to stay below Kubernetes object size limits:
grafana/configmap-grafana-dashboards.yamlgrafana/configmap-grafana-dashboards-2.yaml
In Kubernetes, Alloy collects logs from pods via Kubernetes discovery and sends them to Loki.
Projects can still send OTLP logs separately if needed, but the current K3s deployment is focused on Kubernetes pod log collection rather than the older Docker OTLP pipeline.