I want to display the GUI of prometheus and grafana on kubernetes


Kubernetes Setup for Prometheus and Grafana

The following comment was executed referring to

kubectl apply \
  --filename https://raw.githubusercontent.com/giantswarm/kubernetes-prometheus/master/manifests-all.yaml
[root@instance-1 ~]# kubectl get pods --namespace=monitoring
NAME                                  READY   STATUS      RESTARTS   AGE
alertmanager-78cbf8f796-crk8k         1/1     Running     0          42m
grafana-core-7f65444f84-2rg6q         1/1     Running     0          42m
grafana-import-dashboards-h4bp5       0/1     Completed   0          42m
kube-state-metrics-5f4c7f9d47-s2ndv   1/1     Running     0          42m
node-directory-size-metrics-57lm5     2/2     Running     0          42m
node-directory-size-metrics-5ncxd     2/2     Running     0          42m
prometheus-core-5c96ddd598-srk4l      1/1     Running     0          42m
prometheus-node-exporter-b8wfz        1/1     Running     0          42m
prometheus-node-exporter-rbfkh        1/1     Running     0          42m
[root@instance-1 ~]# kubectl get svc --namespace=monitoring
NAME                       TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
alertmanager               NodePort   <none>        9093:30576/TCP   44m
grafana                    NodePort   <none>        3000:31362/TCP   44m
kube-state-metrics         ClusterIP   <none>        8080/TCP         44m
prometheus                 NodePort   <none>        9090:30472/TCP   44m
prometheus-node-exporter   ClusterIP   None            <none>        9100/TCP         44m

I did, but I can not see the GUI of prometheus and grafana.
You will not be able to access this site.
Please tell me how to use GUI.

If the necessary part is not enough, add it.
Thank you.

Cluster setting method
[root@instance-1 ~]curl https://sdk.cloud.google.com | bash
[root@instance-1 ~]gcloud init
[root@instance-1 ~]sudo yum update kubectl
[root@instance-1 ~]cat <<EOF > /etc/yum.repos.d/kubernetes.repo
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
yum install -y kubectl
[root@instance-1 ~]gcloud container clusters create cluster-1 \
    --num-nodes 1 \
    --machine-type n1-standard-2
after that
[root@instance-1 ~]kubectl apply \
  --filename https://raw.githubusercontent.com/giantswarm/kubernetes-prometheus/master/manifests-all.yaml
[root@instance-1 ~]# kubectl get pods --namespace=monitoring
[root@instance-1 ~]# kubectl get svc --namespace=monitoring
[root@instance-1 ~]#kubectl port-forward svc/prometheus 9090:9090 -n monitoring
[root@instance-1 ~]# kubectl get svc --namespace=monitoring← I tried setting without using this command, but it was useless.

Browser screen

I can not access this site Connection denied on localhost.
Please try the following

Check connection
Check proxy and firewall


Welcome on StackExchange @GABAKU GIK

Use following commands to access them respectively:

  1. Prometheus dashboard:

kubectl port-forward svc/prometheus 9090:9090 -n monitoring

  1. Grafana dashboard:

kubectl --namespace monitoring port-forward svc/grafana 3000

Promethues console:

Once you run successfully first kubectl command you should see in your terminal similar output:

Forwarding from -> 9090
Forwarding from [::1]:9090 -> 9090

then open the URL: ‘http://localhost:9090

enter image description here


First general remark for using ‘kubectl port-forward’ command’.
By default you can access/preview the application’s GUI only on the same host where the kubectl port-forward command was issued (this is why ‘localhost’ is seen in the URL of Promethues console)

for fresh GCP users:

I can see you have a Managed Kubernetes version (GKE).
In that case the easiest way for you to access Prometheus console is with help of Cloud Shell.

  1. How to start a new Cloud Shell session is described here
  2. Once your shell session is initialized, issue the following command to configure your ‘kubectl’ command line tool, to be able to talk to your k8s cluster:
    gcloud container clusters get-credentials [CLUSTER_NAME]

  3. On the same shell session, start port-forwarding to Prometheus dashboard:
    kubectl port-forward svc/prometheus 9090:9090 -n monitoring

  4. Preview the application using Web Preview option.
    Before you Click the Web Preview button as explained here,
    first change the default listening port from 8080 => 9090 (forwarded port)

Source : Link , Question Author : GABAKU GIK , Answer Author : Nepomucen

Leave a Comment