- Install InfluxDB - Here's the link for how to install influxdb on AWS EKS - https://devopsautomationblogs.blogspot.com/2020/04/install-influxdb-on-aws-eks-using-helm.html
-
Configure InfluxDB for jenkins build metrics collection
Go inside the influxdb pod and Run below 2 commands
kubectl exec -it -n influxdb influxdbPodName /bin/bash influx # open influx database CREATE DATABASE jenkins_db # create jenkins database CREATE USER jenkins WITH PASSWORD 'admin' WITH ALL PRIVILEGES # create jenkins username
- Install Grafana - Here's the link for how to install influxdb on AWS EKS - https://devopsautomationblogs.blogspot.com/2020/04/install-grafana-on-aws-eks-using-helm.html
-
Configure Grafana
-
Add influxDB datasource
Click on Settings (left side) > Data Sources > Add data source > Search & Select "InfluxDB" >
Name: InfluxDB
HTTP > URL: InfluxDB URL - How to getkubectl get svc -n influxdb
InfluxDB Details >
Database: jenkins_db
User: jenkins
Password: admin
HTTP Method: Get
Save & Test - This will test the connection and save the datasource. -
Import already available jenkins grafana dashboard
Click on + sign (create) > Import > write id "10557" in "Grafana.com Dashboard" > it'll
automatically load the dashboard:
Name: Choose or keep the name as is
Folder: Default will be created in General folder, however for our configuration create new named Jenkins
InfluxDB: Select the datasource added in previous step
Import -
As per this dashboard's plugin usage, we need to install 2 plugins in grafana
Go inside the Grafana pod, Run below 2 commands and Delete the pod to Restart the Grafana service. Data will be persisted because we've used AWS EBS in Grafana installation process.
kubectl exec -it -n grafana grafanaPodName /bin/bash grafana-cli plugins install grafana-piechart-panel grafana-cli plugins install btplc-trend-box-panel exit kubectly delete po -n grafana grafanaPodName
-
In order to get the data from influxdb, we need to change the Query in dashboard configurations,
For this
Home > Select the dashboard created in 2nd step > Click on "Dashboard Settings"(Top right side) > Variables > Delete any one variable from out of 2 there > In remaining one variable > Change the query to "select project_path from jenkins_data" > Save > Save Dashboard - We need to change the query for all metrics panel on the dashboard, which I've already done. Copy entire json from https://github.com/JaydeepUniverse/automation/blob/master/grafanaJenkinsJSON.json and paste it in Home > Select the dashboard created in 2nd step > Click on "Dashboard Settings"(Top right side) > JSON Model > Save Dashboard
-
Add influxDB datasource
Click on Settings (left side) > Data Sources > Add data source > Search & Select "InfluxDB" >
- Configure Jenkins
- Install Plugin - InfluxDB and Restart Jenkins
-
Manage Jenkins > Configure System > Search for InfluxDB > Add Target >
Description: influxdb-monitoring - This name we will going to use to send the build metrics to
InfluxDB
URL: InfluxDB URL - How to getkubectl get svc -n influxdb
Username: jenkins
Password: admin
Database: jenkins_db
Apply & Save the configurations - Configure job to use this configuration
-
FreeStyle Job > Cofigure > Add Post-Build action > select "Publish build data to
InfluxDB" > there provide Description name configured in previous step - "influxdb-monitoring" >
save the configuration
Next time when job will run it will send the data to influxdb -
Declarative Pipeline Job - Add below syntax in Jenkinsfile
post{ always{ script{ try { if (currentBuild.result == null) { currentBuild.result = 'SUCCESS' } } catch (err) { if (currentBuild.result == null) { currentBuild.result = 'FAILURE' } throw err } finally { influxDbPublisher selectedTarget: 'influxdb-monitoring' } } } }
- Voila!! Go to Grafana UI, Check for the metrics and Dashboard visualization. This dashboard is really eye catchy!!
Below are screenshot taken from Grafana dashboard.
Comments
Post a Comment