Adding a Grafana dashboard to monitor applications

Grafana is used to visualize the metrics stored on Prometheus. It offers dynamic and reusable dashboards with template variables. In this recipe, we will learn how to add a new dashboard from the library of pre-built dashboards to monitor an application deployed on Kubernetes:

  1. Every application has different metrics that are relevant to the continuity of the application. First of all, an application needs to expose the metrics to Prometheus (additional info on Writing Prometheus exporters is available in the See also section), and Prometheus must be added as a data source to Grafana. For this recipe, we will use the Jenkins we deployed in Chapter 3Building CI/CD Pipelinesin the Setting up a CI/CD pipeline in Jenkins X recipe. 
  2. Click on the Home button in the top-left corner of the dashboard and click on Find dashboards on Grafana.com:

  1. In the search field, type Jenkins. You will see a couple of Jenkins-specific dashboards:

  1. Click on Jenkins: Performance and health overview and copy the ID to the clipboard. At this point, dashboard ID 306 is all you need to add this pre-built dashboard to your Grafana instance:

  1. If the Dashboard is not enabled, follow the instructions in the Overview section. 
  2. In the Grafana interface, click on Import dashboard. Paste the dashboard ID 306 into the Grafana.com Dashboard field. Grafana will automatically detect the dashboard and display the details:

  1. Select Prometheus as the data source name and click on Import:

  1. Click on the Home button to list the dashboards again, and you will find your new dashboard in the most recent dashboards list:

Similarly, you can find a pre-built dashboard on Grafana for the applications we have used in previous chapters such as cloud provider service monitoring (AWS, GCP, Azure, Alibaba), GitLab CI, Minio, OpenEBS, and many additional Kubernetes cluster metrics.