10. Enabling of Metrics and Monitoring
Notes#
We need to enable some metrics for our Cluster
This draft how to install Grafana + Prometheus for Microk8S
Prerequisites#
- The product platform instructions v2 steps 1–3 have been reviewed and working.
- You only really need to have the step 1 of the V2 guide done so the grafana and prometheus stack can be installed with the microk8s addon
- Before enabling the addon, disable the cockpit.socket service. It uses the port 9090 and is not really usable by us anyway at this moment
To check if the service is enabled run the following command:
To disable the service do the following:
1. Installing Prometheus + grafana stack using Helm#
I found a good guide: https://www.ibm.com/docs/en/txseries/11.1.0?topic=grafana-installing-prometheus-in-kubernetes-cluster
This should be quite easy, but there are some steps..
- We need to install kube-prom-stack for our microk8s setup
You should then see something like this in the terminal
microk8s enable observability
Infer repository core for addon observability
Addon core/dns is already enabled
Addon core/helm3 is already enabled
Addon core/hostpath-storage is already enabled
Enabling observability
Release "kube-prom-stack" does not exist. Installing it now.
NAME: kube-prom-stack
LAST DEPLOYED: Mon Dec 8 11:48:46 2025
NAMESPACE: observability
STATUS: deployed
REVISION: 1
NOTES:
kube-prometheus-stack has been installed. Check its status by running:
kubectl --namespace observability get pods -l "release=kube-prom-stack"
Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
Release "loki" does not exist. Installing it now.
NAME: loki
LAST DEPLOYED: Mon Dec 8 11:49:20 2025
NAMESPACE: observability
STATUS: deployed
REVISION: 1
NOTES:
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.
Release "tempo" does not exist. Installing it now.
NAME: tempo
LAST DEPLOYED: Mon Dec 8 11:49:24 2025
NAMESPACE: observability
STATUS: deployed
REVISION: 1
TEST SUITE: None
Note: the observability stack is setup to monitor only the current nodes of the MicroK8s cluster.
For any nodes joining the cluster at a later stage this addon will need to be set up again.
Observability has been enabled (user/pass: admin/prom-operator)
You can now check if observability services are online with the command:
You should notice these two pods running or if they are not running, wait a while and try to run the command again
kube-prom-stack-grafana-c5b5bf7d-txhqm 3/3 Running 0 81m
prometheus-kube-prom-stack-kube-prome-prometheus-0 2/2 Running 0 81m
Then check the services with the command:
Notice these two services running, you will need these later and again wait a while if they are not running
kube-prom-stack-grafana ClusterIP 10.152.183.84 <none> 80/TCP
kube-prom-stack-kube-prome-prometheus ClusterIP 10.152.183.225 <none> 9090/TCP
2. Giving access to the services from outside the VM#
NOTE: This is only for testing the functionality of the stack and not meant for production, simply because the nip.io is a free DNS service and therefore we cannot manage it at all but it allows us to do subdomains easily
To be able to get access from outside the VM, we will need to use ingress to do so
Make a file called monitoring.yaml or observability.yaml. The filename doesn't really matter.
Put these contents in it and save the file
To get the floating ip of the VM use the following command
Use that ip address inside the yaml file you just madeapiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: observability-ingress
namespace: observability # VERY IMPORTANT (this needs to be the same namespace as to what the addon creates)
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
ingressClassName: nginx
tls:
- hosts:
- grafana.<your floating ip>.nip.io
- prometheus.<your floating ip>.nip.io
secretName: observability-tls
rules:
- host: grafana.<your floating ip>.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kube-prom-stack-grafana # This is the grafana service (do not change this)
port:
number: 80
- host: prometheus.<your floating ip>.nip.io
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kube-prom-stack-kube-prome-prometheus # This is the prometheus service (do not change this)
port:
number: 9090
Now run the file with the following command
After that you will be able to access the Grafana and the Prometheus in the sub-domains we definedThe credentials for the Grafana are as follows:
Why use nip.io? Simply because at the moment we cannot do sub-domains with the fip domain name and the Grafana and Prometheus requires the path to be the root path eg "/" so we cannot rewrite the path either, at least not easily
3. Below are old content needs reviewing or deletion?#
Next step is under development until we get a yaml file defined correctly
You can publish you prometheus server in server host address by using port forwarding:
microk8s kubectl port-forward -n observability service/prometheus-operated --address 0.0.0.0 9090:9090
microk8s kubectl port-forward -n observability service/kube-prom-stack-grafana --address 0.0.0.0 3000:80
We have noticed some issues with visibility of Graphana/prometheus because firewall is preventing ports 3000 or 9090. You should check if ports are open and accessable externally.
you can use eg curl http//192.168.8.103:3000 to check can you access your Microk8s server and graphana service
If you cannot access you should check if service ie accessable locally first.
4. Opening Grafana service to internet#
This YAML file is under work and when working it can replace command line port forwarding
I modified service visibility on subdomain /graphanaxi for hosts public host name fip-86-50-252-136.kaj.poutavm.fi
I created a yaml file grafana-update.yaml
NOT WORKING YET!!
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: prometheus-stack-grafana
namespace: monitoring
annotations:
spec:
ingressClassName: nginx
rules:
- host: fip-86-50-252-136.kaj.poutavm.fi
http:
paths:
- path: /graphanaxi
pathType: Prefix
backend:
service:
name: prometheus-stack-grafana
port:
number: 80
- microk8s helm3 upgrade prometheus-stack prometheus-community/kube-prometheus-stack --namespace monitoring -f grafana-update.yaml