This guide demonstrates deploying Grafana Loki using Helm in a Kubernetes cluster with configuration customization and installation steps.
In this guide, we demonstrate how to deploy Grafana Loki using Helm in a Kubernetes cluster. We cover adding and updating the Grafana Helm repository, searching for the appropriate Loki chart, customizing the default configuration values, and finally installing the Loki stack (which includes Loki, Promtail, and Grafana) with minimal manual configuration.
You should receive output confirming that the repository has been added:
Copy
Ask AI
Documents\scratch\loki-demo> helm repo add grafana https://grafana.github.io/helm-charts"grafana" has been added to your repositories
Next, update your Helm repositories with:
Copy
Ask AI
helm repo update
The terminal output will indicate a successful update:
Copy
Ask AI
Documents\scratch\loki-demo> helm repo updateHang tight while we grab the latest from your chart repositories......Successfully got an update from the "grafana" chart repository...Successfully got an update from the "prometheus-community" chart repositoryUpdate Complete. ⚓ Happy Helming! ⚓
Ensure that your Helm version is up-to-date to prevent compatibility issues with newer charts.
Grafana offers several Loki-related charts. To search for these charts within the Grafana repository, run:
Copy
Ask AI
helm search repo loki
You will see output similar to this:
Copy
Ask AI
NAME CHART VERSION APP VERSION DESCRIPTIONgrafana/loki 5.10.0 2.8.3 Helm chart for Grafana Loki in simple, scalable...grafana/loki-canary 0.13.0 2.8.3 Helm chart for Grafana Loki Canarygrafana/loki-distributed 0.71.1 2.8.3 Helm chart for Grafana Loki in microservices modegrafana/loki-simple-scalable 1.8.11 2.6.1 Helm chart for Grafana Loki in simple, scalable...grafana/loki-stack 2.6.1 2.8.3 Loki: like Prometheus, but for logs.grafana/fluent-bit 2.6.0 v2.1.0 Uses fluent-bit Loki go plugin for gathering logs...grafana/promtail 6.14.1 2.8.3 Promtail is an agent which ships the contents of log files.
For this deployment, we will use the loki-stack chart, which packages Loki, Promtail, and Grafana for a complete logging solution.
Before installing the chart, it is best practice to review and customize its default configuration. Export the default values to a file named values.yaml:
Copy
Ask AI
helm show values grafana/loki-stack > values.yaml
Open values.yaml in your favorite editor to review the configuration. The file includes sections for Loki, Promtail, Fluent Bit, and Grafana. For instance, the Promtail configuration section may look like this:
This configuration ensures that Promtail is enabled and connected to the Loki server. Note that Fluent Bit is disabled and Grafana is disabled by default. Since Grafana is needed for dashboards, update the configurations as follows:
The installation process will output information similar to the following:
Copy
Ask AI
Documents\scratch\loki-demo> helm install --values values.yaml loki grafana/loki-stackW0806 19:03:54.310850 34388 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+W0806 19:03:54.312802 34388 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+W0806 19:03:54.381651 34388 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+W0806 19:03:54.382713 34388 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+NAME: lokiLAST DEPLOYED: Sun Aug 6 19:03:53 2023NAMESPACE: defaultSTATUS: deployedREVISION: 1NOTES:The Loki stack has been deployed to your cluster. Loki can now be added as a datasource in Grafana.See http://docs.grafana.org/features/datasources/loki/ for more detail.Documents\scratch\loki-demo took 2s
This output verifies that your Loki stack has been successfully deployed. You can now add Loki as a data source in Grafana.
This output confirms the deployment of key components:
A StatefulSet for Loki
A Deployment (and ReplicaSet) for Grafana
A DaemonSet for Promtail, ensuring an instance runs on every node
For multi-node clusters, Promtail will automatically run on every node, ensuring comprehensive log collection.
Once deployed, log in to Grafana to verify that Loki has been automatically added as a data source, simplifying your log monitoring workflow.By following these steps, you have successfully deployed the Loki stack to your Kubernetes cluster using Helm. This complete logging solution integrates efficient log aggregation with Grafana dashboards for powerful monitoring and troubleshooting.For further reading and additional resources: