You are looking at the documentation of a prior release. To read the documentation of the latest release, please visit here.

Use Grafana Dashboard

Grafana provides an elegant graphical user interface to visualize data. You can create beautiful dashboard easily with a meaningful representation of your Prometheus metrics.

Before You Begin

  • At first, you need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using kind.

  • You must have a Stash instant running with monitoring enabled. You can enable monitoring by following the guides for builtin Prometheus scraper or CoreOS Prometheus Operator. For this tutorial, we have enabled Prometheus monitoring using Prometheus operator.

  • If you already do not have a grafana instance running, deploy one following tutorial from here.

Add Prometheus Data Source

We have to add our Prometheus server prometheus-prometheus-0 as data source of grafana. We are going to use a ClusterIP service to connect Prometheus server with grafana. Let’s create a service to select Prometheus server prometheus-prometheus-0,

$ kubectl apply -f https://github.com/stashed/docs/raw/v2021.11.24/docs/examples/monitoring/coreos/prometheus-service.yaml
service/prometheus created

Below the YAML for the service we have created above,

apiVersion: v1
kind: Service
metadata:
  name: prometheus
  namespace: monitoring
spec:
  type: ClusterIP
  ports:
  - name: web
    port: 9090
    protocol: TCP
    targetPort: 9090
  selector:
    app: prometheus

Now, follow these steps to add the Prometheus server as data source of Grafana UI.

  1. From Grafana UI, go to Configuration option from sidebar and click on Data Sources.

      Grafana: Data Sources

  2. Then, click on Add data source.

      Grafana: Add data source

  3. Now, configure Name, Type and URL fields as specified below and keep rest of the configuration to their default value then click Save&Test button.

      Grafana: Configure data source

Once you have added Prometheus data source successfully, you are ready to create a dashboard to visualize the metrics.

Import Stash Dashboard

Stash has a preconfigured dashboard created by Alexander Trost. You can import the dashboard using dashboard id 4198 or you can download json configuration of the dashboard from here.

Follow these steps to import the preconfigured stash dashboard,

  1. From Grafana UI, go to Create option from sidebar and click on import.

      Grafana: Import dashboard

  2. Then, insert the dashboard id 4198 in Grafana.com Dashboard field and press Load button. You can also upload json configuration file of the dashboard using Upload .json File button.

      Grafana: Provide dashboard ID

  3. Now on prometheus-infra field, select the data source name that we have given to our Prometheus data source earlier. Then click on Import button.

      Grafana: Select data source

Once you have imported the dashboard successfully, you will be greeted with Stash dashboard.

  Grafana: Stash dashboard

Cleanup

To cleanup the Kubernetes resources created by this tutorial, run:

kubectl delete -n monitoring service prometheus

Next Steps

  • Learn how monitoring in Stash works from here.
  • Learn how to monitor Stash using builtin Prometheus from here.
  • Learn how to monitor Stash using CoreOS Prometheus Operator from here.