Step 2 :Install Helm,The package manager for Kubernetes
Helm makes it extremely easy to make sure you use up to date versions of Prometheus & Grafana & also makes it a-lot easier to deploy and delete.
Helm now has an installer script that will automatically grab the latest version of Helm and install it locally.
You can fetch that script, and then execute it locally. It’s well documented so that you can read through it and understand what it is doing before you run it.
it’s always good idea to keep related things together, We will create separate namespace in Kubernetes for monitoring and will deploy all monitoring related application under that namespace.
Create monitoring namespace with following command
$ kubectl create namespace monitoring
Step 4: Deploy Prometheus using Helm Chart
With the help of Helm, We can deploy prometheus using single command.
This will deploy Prometheus into your cluster in the monitoring namespace and mark the release with the name prometheus.
let’s check if prometheus is running or not using following command :
$ kubectl get pods -n monitoring
Step 5: Deploy Grafana using Helm Chart
When deploying grafana, we need to configure it to read metrics from the right data sources.
There are two ways of achieving this.
Deploy Grafana & add the data source afterwards through the UI.
Add the data source as yaml configs & deploy Grafana. Grafana will use these to automatically configure the data sources when it is provisioned. We are going to take this path as we want everything to be replicate-able without too much manual intervention.
When the Grafana Helm chart gets deployed, it will search for any config maps that contain a grafana_datasource label. So we will add one in our config. That is as follow
When Grafana gets deployed and the provisioner runs, the data source provisioner is deactivated. We need to activate it so it searches for our config maps.
We need to create our own values.yml file to override the datasources search value, so when Grafana is deployed it will search our datasource.yml definition and inject it.
Create a file called values.yml with the following contents:
Here you will find many many dashboards to use. We will use this one as it is quite comprehensive in everything it tracks.
In the left hand menu, choose Dashboards > Manage > + Import
In the Grafana.com dashboard input, add the dashboard ID we want to use: 4701 and click Load
Now as i mention in step 5 if the value.yml is added with deployment you can see datasource here
Here we need to add Proetheus datasource manually
In the left hand menu, Choose Configuration > Data Source > Add Data Source
And Select Time Series Database Prometheus
Configure Prometheus server URL with the kubernetes service endpoint
In HTTP URL Block insert this URL : http://prometheus-server:80
Now Click on Save and Test button at bottom :
The list of metrics is extensive. Go over them and see what is useful, copy their structures and panels and create your own dashboards for the big screens in the office !