First, we have to add the official Grafana Helm chart repository.
helm repo add grafana https://grafana.github.io/helm-charts
Now replace your Helm repo listing to ensure you get the most recent charts.
helm repo replace
Let’s seek for the Loki chart and output its default configuration to a file.
helm search repo loki
This command helps verify the chart exists.
Now we get the default values for loki
chart and save to a file
helm present values grafana/loki > values.yaml
This provides you a full listing of customizable values.
Subsequent, open the values.yaml
file in your favourite code editor and make the next modifications:
- Set
grafana enabled
totrue
. - Set
grafana picture tag
tonewest
to get the most recent model of Grafana.
Now set up Loki utilizing the customized values.yaml
:
helm set up --values values.yaml loki grafana/loki
To substantiate every little thing is operating appropriately:
kubectl get pods
This exhibits you all of the operating pods, together with Grafana and Loki.
You can even run:
kubectl get all
This command shows all sources within the default namespace like companies, deployments, and many others.
To open the Grafana UI in your browser, ahead the port:
kubectl port-forward pod/ 3000:3000
Exchange
together with your precise Grafana pod title, for instance:
kubectl port-forward pod/loki-grafana-6c9b985484-q26gb 3000:3000
This lets you entry Grafana at http://localhost:3000
Grafana units a default admin password as a Kubernetes secret. To retrieve it:
kubectl get secret
kubectl describe secret loki-grafana
kubectl get secret loki-grafana -o jsonpath="{.information.admin-password}" | base64 --decode
Use this password to log in to Grafana username is normally admin
.
When you log into Grafana, go to the Knowledge Sources part. You’ll see that Loki is already added (because of the values we set in values.yaml
). You don’t want so as to add it manually.
To see how logs is perhaps collected and proven in Grafana sooner or later, let’s deploy a primary NGINX app.
apiVersion: apps/v1
form: Deployment
metadata:
title: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- title: nginx-container
picture: nginx:newest
ports:
- containerPort: 80
Apply it utilizing:
kubectl apply -f nginx-deployment.yaml
Open the Grafana dashboard. Navigate to Discover, choose Loki as the information supply. You’ll be able to set this as much as question logs as soon as a log collector like Fluent Bit or one other agent is built-in with Loki.