Forum Navigation
You need to log in to create posts and topics.

Access Prometheus metrics page in Kubernetes cluster

Problem

User working with Prometheus installed in kubernetes in a cluster environment cannot see the metrics / alerts /graphs / status management page.

Solution

Need to Change the type of the service from ClusterIP to NodePort in order to expose the service on the cluster IP

List all your Kubernetes services in monitoring namespace

kubectl get service -n monitoring

edit the service

kubectl edit service prom-operator-prom-prometheus -n monitoring

Under Spec section in the YAML structure change the value for

type: ClusterIP
to
type: NodePort

Example

spec:
clusterIP: 10.233.8.194
externalTrafficPolicy: Cluster
ports:
– name: web
nodePort: 31531
port: 9090
protocol: TCP
targetPort: 9090
selector:
app: prometheus
prometheus:prom-operator-prom-prometheus
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}

Check the assigned nodePort value and in your browser type

http://<CLUSTER IP ADDRESS>:31531

Or patch the service as a Load Balancer instead of ClusterIP

kubectl patch svc kube-prometheus-stack-grafana -p ‘{“spec”: {“type”: “LoadBalancer”, “externalIPs”:[“10.2.43.30”]}}’

Uploaded files: