|
| 1 | +# Meta-monitoring Loki - Kubernetes Helm Chart |
| 2 | + |
| 3 | +This Helm chart provides comprehensive monitoring for Loki deployments in Kubernetes, based on the [Grafana Kubernetes Monitoring Helm Chart](https://github.com/grafana/k8s-monitoring-helm/tree/main). |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The Meta-monitoring chart collects metrics and logs from Loki deployments using Grafana Alloy (an OpenTelemetry Collector distribution) and sends them to your preferred observability backend. It's designed to work with the pre-compiled Loki mixins to provide dashboards and alerts specifically tailored for Loki monitoring. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +- [kubectl](https://kubernetes.io/docs/reference/kubectl/) |
| 12 | +- Kubernetes cluster |
| 13 | +- Helm 3.x |
| 14 | +- Access to Grafana Cloud or a self-managed Prometheus/Loki/Grafana stack |
| 15 | +- For self-managed destinations: credentials stored in Kubernetes secrets |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +1. Create the required secrets for your observability backend: |
| 20 | + |
| 21 | +```bash |
| 22 | +# For Grafana Cloud or self-managed stack |
| 23 | +kubectl create namespace meta |
| 24 | +kubectl create secret generic metrics --namespace meta \ |
| 25 | + --from-literal=username='YOUR_PROMETHEUS_USERNAME' \ |
| 26 | + --from-literal=password='YOUR_PROMETHEUS_PASSWORD' |
| 27 | + |
| 28 | +kubectl create secret generic logs --namespace meta \ |
| 29 | + --from-literal=username='YOUR_LOKI_USERNAME' \ |
| 30 | + --from-literal=password='YOUR_LOKI_PASSWORD' |
| 31 | +``` |
| 32 | + |
| 33 | +2. Install the Helm chart: |
| 34 | + |
| 35 | +```bash |
| 36 | +helm repo add grafana https://grafana.github.io/helm-charts |
| 37 | +helm install meta-loki grafana/k8s-monitoring \ |
| 38 | + --namespace meta \ |
| 39 | + -f values.yaml |
| 40 | +``` |
| 41 | + |
| 42 | +## Configuration |
| 43 | + |
| 44 | +The default configuration is set up for Grafana Cloud, but you can direct it to your self-managed monitoring stack by modifying the destinations in `values.yaml`: |
| 45 | + |
| 46 | +```yaml |
| 47 | +destinations: |
| 48 | + - name: prometheus |
| 49 | + type: prometheus |
| 50 | + url: https://<PROMETHEUS-ENDPOINT>/api/prom/push |
| 51 | + # Configure authentication as needed |
| 52 | + |
| 53 | + - name: loki |
| 54 | + type: loki |
| 55 | + url: https://<LOKI-ENDPOINT>/loki/api/v1/push |
| 56 | + # Configure authentication as needed |
| 57 | +``` |
| 58 | + |
| 59 | +Note: Authentication is based on a pre-configured secret. The Helm chart does support more advanced authentication methods. Examples are provided in the [k8s-monitoring documentation](https://github.com/grafana/k8s-monitoring-helm/tree/main/charts/k8s-monitoring/docs/examples/auth) |
| 60 | + |
| 61 | +## Key Features |
| 62 | + |
| 63 | +- **Cluster Event Collection**: Captures Kubernetes events as logs |
| 64 | +- **Metrics Collection**: Uses cadvisor, kubelet, and kube-state-metrics |
| 65 | +- **Pod Log Collection**: Collects logs from Loki pods |
| 66 | +- **Integrated Dashboards**: Works with pre-compiled Loki mixin dashboards |
| 67 | +- **Alert Rules**: Pre-configured alerting rules for Loki components |
| 68 | + |
| 69 | +## Loki Mixin Compiled Files |
| 70 | + |
| 71 | +This chart is designed to work with the Loki mixins found in the `loki-mixin-compiled` directory, which contains: |
| 72 | + |
| 73 | +### Files Overview |
| 74 | + |
| 75 | +- **dashboards/**: Pre-compiled Grafana dashboards for visualizing Loki performance and health |
| 76 | +- **alerts.yaml**: Pre-configured alerting rules for Loki components |
| 77 | +- **rules.yaml**: Recording rules that create metrics used by dashboards and alerts |
| 78 | + |
| 79 | +### Using the Dashboards |
| 80 | + |
| 81 | +The `dashboards/` directory contains JSON files that can be imported directly into Grafana: |
| 82 | + |
| 83 | +1. From your Grafana UI, go to **Dashboards → Import**. |
| 84 | +1. Upload the JSON file or paste its contents. |
| 85 | +1. Configure the data source (should match your Prometheus). |
| 86 | +1. Click **Import**. |
| 87 | + |
| 88 | +Alternatively, use the Grafana API to programmatically import dashboards: |
| 89 | + |
| 90 | +```bash |
| 91 | +# Example using curl to import a dashboard |
| 92 | +curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_KEY" \ |
| 93 | + -d @path/to/dashboard.json \ |
| 94 | + https://your-grafana-instance/api/dashboards/db |
| 95 | +``` |
| 96 | + |
| 97 | +### Loading Alert and Recording Rules |
| 98 | + |
| 99 | +For Grafana Cloud Prometheus or Grafana Mimir, use `[mimirtool](https://grafana.com/docs/mimir/latest/manage/tools/mimirtool/#installation)` to load the rules: |
| 100 | + |
| 101 | +```bash |
| 102 | +# Install mimirtool |
| 103 | +go install github.com/grafana/mimir/pkg/mimirtool@latest |
| 104 | + |
| 105 | +# Load alert rules |
| 106 | +mimirtool rules load alerts.yaml \ |
| 107 | + --address=https://prometheus-prod-xxx.grafana.net/api/prom \ |
| 108 | + --id=<Your-Stack-ID> \ |
| 109 | + --key=<Your-API-Key> |
| 110 | + |
| 111 | +# Load recording rules |
| 112 | +mimirtool rules load rules.yaml \ |
| 113 | + --address=https://prometheus-prod-xxx.grafana.net/api/prom \ |
| 114 | + --id=<Your-Stack-ID> \ |
| 115 | + --key=<Your-API-Key> |
| 116 | +``` |
| 117 | + |
| 118 | +For self-managed Prometheus: |
| 119 | + |
| 120 | +```bash |
| 121 | +# For Prometheus |
| 122 | +cp rules.yaml alerts.yaml /etc/prometheus/rules/ |
| 123 | +# Then reload Prometheus configuration |
| 124 | +curl -X POST http://prometheus:9090/-/reload |
| 125 | +``` |
| 126 | + |
| 127 | +## Components Monitored |
| 128 | + |
| 129 | +The meta-monitoring chart monitors: |
| 130 | + |
| 131 | +- Loki components via label selection (`app.kubernetes.io/name: loki`) |
| 132 | +- Alloy collectors in the `meta` namespace |
| 133 | +- Kubernetes resources in the `loki` and `meta` namespaces |
| 134 | + |
| 135 | +## Advanced Configuration |
| 136 | + |
| 137 | +See the [k8s-monitoring documentation](https://github.com/grafana/k8s-monitoring-helm/tree/main/charts/k8s-monitoring/docs) for additional configuration options for: |
| 138 | + |
| 139 | +- Authentication methods |
| 140 | +- Collection tuning |
| 141 | +- Metric processing |
| 142 | +- Log processing |
| 143 | + |
| 144 | +## References |
| 145 | + |
| 146 | +- [Grafana Kubernetes Monitoring](https://github.com/grafana/k8s-monitoring-helm/tree/main) |
| 147 | +- [Alloy integration](https://github.com/grafana/k8s-monitoring-helm/blob/main/charts/k8s-monitoring/charts/feature-integrations/docs/integrations/alloy.md) |
| 148 | +- [Loki integration](https://github.com/grafana/k8s-monitoring-helm/blob/main/charts/k8s-monitoring/charts/feature-integrations/docs/integrations/loki.md) |
| 149 | +- [Mimirtool documentation](https://grafana.com/docs/mimir/latest/manage/tools/mimirtool/) |
0 commit comments