3.7 KiB
Prometheus and Grafana
-
What if we want metrics retention, view graphs, trends?
-
A very popular combo is Prometheus+Grafana:
-
Prometheus as the "metrics engine"
-
Grafana to display comprehensive dashboards
-
-
Prometheus also has an alert-manager component to trigger alerts
(we won't talk about that one)
Installing Prometheus and Grafana
-
A complete metrics stack needs at least:
-
the Prometheus server (collects metrics and stores them efficiently)
-
a collection of exporters (exposing metrics to Prometheus)
-
Grafana
-
a collection of Grafana dashboards (building them from scratch is tedious)
-
-
The Helm chart
kube-prometheus-stackcombines all these elements -
... So we're going to use it to deploy our metrics stack!
Installing kube-prometheus-stack
-
Let's install that stack directly from its repo
(without doing
helm repo addfirst) -
Let's use the same name for the release, the namespace...:
helm upgrade --install kube-prometheus-stack kube-prometheus-stack \ --namespace kube-prometheus-stack --create-namespace \ --repo https://prometheus-community.github.io/helm-charts -
This will take a minute...
-
Then check what was installed:
kubectl get all --namespace kube-prometheus-stack
Exposing Grafana
-
Let's do this only if we have an ingress controller and a domain name!
(we can also skip this and come back to it later)
-
Create an Ingress for Grafana:
kubectl create ingress --namespace kube-prometheus-stack grafana \ --rule=grafana.`cloudnative.party`/*=kube-prometheus-stack-grafana:80(make sure to use your domain name above)
-
Connect to Grafana
Exposing Grafana without Ingress
-
What if we don't have an ingress controller?
-
We can use a
NodePortservice instead -
Option 1:
kubectl editorkubectl patchthe service(it's
kube-prometheus-stack-grafana) -
Option 2: pass the correct value to
helm upgrade --install(check the [chart values][kps-values] to find the right one!)
-
We can also use
kubectl port-forward, or aLoadBalacnerservice!
Grafana credentials
-
What could the login and password be?
-
Let's look at the Secrets available in the namespace:
kubectl get secrets --namespace kube-prometheus-stack -
There is a
kube-prometheus-stack-grafanathat looks promising! -
Decode the Secret:
kubectl get secret --namespace kube-prometheus-stack \ kube-prometheus-stack-grafana -o json | jq '.data | map_values(@base64d)' -
If you don't have the
jqtool mentioned above, don't worry...
--
- The login/password is hardcoded to
admin/prom-operator😬
Grafana dashboards
-
Once logged in, click on the "Dashboards" icon on the left
(it's the one that looks like four squares)
-
Then click on the "Manage" entry
-
Then click on "Kubernetes / Compute Resources / Cluster"
-
This gives us a breakdown of resource usage by Namespace
-
Feel free to explore the other dashboards!
-
There won't be much data right now, but there will be more later
???
:EN:- Installing Prometheus and Grafana :FR:- Installer Prometheus et Grafana
:T: Observing our cluster with Prometheus and Grafana
:Q: What's the relationship between Prometheus and Grafana? :A: Prometheus collects and graphs metrics; Grafana sends alerts :A: ✔️Prometheus collects metrics; Grafana displays them on dashboards :A: Prometheus collects and graphs metrics; Grafana is its configuration interface :A: Grafana collects and graphs metrics; Prometheus sends alerts