Connecting to Grafana Deployed to Kubernetes via Prometheus Operator in Marketplace

This is the process I used to connect to the Grafana web server that gets deployed when adding the Prometheus Operator from the Civo Kubernetes Marketplace. If you want to dive straight in, you can use the quick start below, or see the steps to get to that point by following along with the guide.

Quick Start

If you already have a Kubernetes cluster running Prometheus Operator, the command to access it at http://localhost:8080 will be:

PowerShell: kubectl port-forward $(kubectl get pods -n monitoring -o name | sls grafana) 8080:3000 -n monitoring

Bash kubectl port-forward $(kubectl get pods -n monitoring -o name | grep grafana) 8080:3000 -n monitoring

Prerequisites

  1. Have kubectl command line tool installed
  2. Deploy a kubernetes cluster with the Prometheus Operator app selected.
  3. Have the config file for your cluster downloaded. You can either do this through the web UI: Kubeconfig download from the Civo UI

Or, alternatively, you can use the Civo CLI tool and run civo k8s config <your-cluster-name> --save and skip the next step.

Add the configuration file to your shell:

PowerShell: Set the path to $Env:KUBECONFIG='<path to config file downloaded in previous step>')

Bash: export KUBECONFIG=<path to config file downloaded in previous step>

Make sure your resources are healthy: kubectl get pods -A

Everything should be in "Running" State. Mine looked like this: Healthy pods

Steps

  1. Get the Grafana pod name. In Powershell use kubectl get pods -n monitoring -o name | select-string grafana and in bash terminals use kubectl get pods -n monitoring -o name | grep grafana
  2. Create a port forward session to the Grafana pod which is exposed on port 3000: kubectl port-forward --namespace monitoring <pod name> <local port>:3000
  3. Access the Grafana web application in a browser at: http://localhost:<local port>

Here are the steps from my testing in action:
Getting to the correct pod

  1. In the browser you should see the Grafana log in screen, something like the below: Grafana Login

  2. Log in with default credentials: username: admin, password: prom-operator

    Obviously these are insecure and the kubernetes default should not be used for anything other than testing

  3. Once you're logged in there is a plethora of available dashboards out of the box to explore. You can also create your own!

Grafana Dashboard

clicking the "Home" button at the top gies you a list:
Dashboards list

Wrap-Up

You probably want to kill your proxy so it's not running, you can always use the same steps to turn it back on. Simply Ctrl-C in the terminal with the port forward running to stop it.