Warning
This content has been generated by machine translation. The translations are automated and have not undergone human review or validation.
4.3.1 Installing Prometheus&Grafana
Install Prometheus
Create a namespace for installation.
kubectl create ns monitoring
Register the repository for installation via Helm Chart. This example uses the Bitnami Helm Chart repository.
helm repo add bitnami https://charts.bitnami.com/bitnami
Setting value definition
When installing Helm Chart, refer to the list of configurable parameters and input the value you want to change.
- https://github.com/bitnami/charts/tree/master/bitnami/kube-prometheus#parameters
- The example below is an example of using the nginx ingress controller installed in the previous chapter with the prometheus and alertmanager access URLs.
cat <<EOF > values.yaml prometheus: ingress: enabled: true hostname: prometheus.ingress.thekoguryo.ml path: / annotations: kubernetes.io/ingress.class: nginx cert-manager.io/cluster-issuer: letsencrypt-staging tls: true alertmanager: ingress: enabled: true hostname: alertmanager.ingress.thekoguryo.ml path: / annotations: kubernetes.io/ingress.class: nginx cert-manager.io/cluster-issuer: letsencrypt-staging tls: true EOF
Install prometheus helm chart
helm install prometheus -n monitoring -f values.yaml bitnami/kube-prometheus
Installation result
Prometheus’ internal DNS information will be used later when linking with Grafana.
oke_admin@cloudshell:~ (ap-seoul-1)$ helm install prometheus -n monitoring -f values.yaml bitnami/kube-prometheus NAME: prometheus ... Prometheus can be accessed via port "9090" on the following DNS name from within your cluster: prometheus-kube-prometheus-prometheus.monitoring.svc.cluster.local ...
Install Grafana
Setting value definition
When installing Helm Chart, refer to the list of configurable parameters and input the value you want to change.
- https://github.com/bitnami/charts/tree/master/bitnami/grafana#parameters
- This is an example of using the nginx ingress controller installed in the previous chapter with the grafana access URL.
cat <<EOF > values.yaml admin: password: "higrafana" ingress: enabled: true hostname: grafana.ingress.thekoguryo.ml path: / annotations: kubernetes.io/ingress.class: nginx cert-manager.io/cluster-issuer: letsencrypt-staging tls: true EOF
Install grafana helm chart
helm install grafana -n monitoring -f values.yaml bitnami/grafana
Installation result
It is installed as follows, and it takes some time for the actual container to start.
oke_admin@cloudshell:~ (ap-seoul-1)$ helm install grafana -n monitoring -f values.yaml bitnami/grafana NAME: grafana ... 2. Get the admin credentials: echo "User: admin" echo "Password: $(kubectl get secret grafana-admin --namespace monitoring -o jsonpath="{.data.GF_SECURITY_ADMIN_PASSWORD}" | base64 --decode)" oke_admin@cloudshell:grafana (ap-seoul-1)$ echo "Password: $(kubectl get secret grafana-admin --namespace monitoring -o jsonpath="{.data.GF_SECURITY_ADMIN_PASSWORD}" | base64 --decode)"
Grafana settings
Access the Grafana web UI.
URL: ingress.hostname set in values.yaml
Administrator account
User: admin
Password: admin.password set in values.yaml or if not entered, check with the following command
echo "Password: $(kubectl get secret grafana-admin --namespace monitoring -o jsonpath="{.data.GF_SECURITY_ADMIN_PASSWORD}" | base64 --decode)"
Select Configuration > Data sources from the left menu for Prometheus registration
Click Add data source
Select Prometheus
Enter Prometheus connection information
Enter the Prometheus internal connection information that you checked in the Prometheus installation log earlier.
http://prometheus-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090
Click Save & test at the bottom
Add Grafana Dashboard
You can use the published Grafana Dashboard for Kubernetes monitoring.
Select the desired dashboard among the dashboards found on the above site.
Confirm the ID on the dashboard detail page.
Select Dashboards > Manage from the left menu for Dashboard registration
Click Import
Enter the dashboard ID to import (eg 7249) and click Load
Select Prometheus registered data source and click Import
Monitoring OKE cluster via imported dashboard
You can monitor the Kubernetes cluster by using the dashboard published as above, or by creating a dashboard of your choice and using the metric information collected from Prometheus.
As an individual, this article was written with my personal time. There may be errors in the content of the article, and the opinions in the article are personal opinions.