Add handling multiple Jenkins instances

In dashboard added dropdown for selecting
instance - fixes multiple series error.

Change-Id: I959ffb94374b6b73a6571b9a5a2e15ea4b031150
Related-bug: PROD-26023 (PROD:26023)
diff --git a/grafana/files/dashboards/jenkins/jenkins_prometheus.json b/grafana/files/dashboards/jenkins/jenkins_prometheus.json
index 84b3484..e7a1f4a 100644
--- a/grafana/files/dashboards/jenkins/jenkins_prometheus.json
+++ b/grafana/files/dashboards/jenkins/jenkins_prometheus.json
@@ -97,7 +97,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "jenkins_health_check_score{environment=\"$environment\"}",
+          "expr": "jenkins_health_check_score{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -187,7 +187,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "jenkins_node_online_value{environment=\"$environment\"}",
+          "expr": "jenkins_node_online_value{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 2,
           "refId": "B"
@@ -264,7 +264,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "jenkins_node_count_value{environment=\"$environment\"}",
+          "expr": "jenkins_node_count_value{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 2,
           "refId": "B"
@@ -341,7 +341,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "jenkins_plugins_failed{environment=\"$environment\"}",
+          "expr": "jenkins_plugins_failed{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -420,7 +420,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "jenkins_queue_size_value{environment=\"$environment\"}",
+          "expr": "jenkins_queue_size_value{environment=\"$environment\",host=~\"$host\"}",
           "step": 120,
           "textEditor": false
         }
@@ -502,7 +502,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "(vm_memory_total_max{environment=\"$environment\", job=\"jenkins\"} - vm_memory_total_used{environment=\"$environment\", job=\"jenkins\"}) / vm_memory_total_max{environment=\"$environment\", job=\"jenkins\"} * 100.0",
+          "expr": "(vm_memory_total_max{environment=\"$environment\", job=\"jenkins\", host=~\"$host\"} - vm_memory_total_used{environment=\"$environment\", job=\"jenkins\", host=~\"$host\"}) / vm_memory_total_max{environment=\"$environment\", job=\"jenkins\", host=~\"$host\"} * 100.0",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -587,7 +587,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "vm_uptime_milliseconds{environment=\"$environment\", job=\"jenkins\"}",
+          "expr": "vm_uptime_milliseconds{environment=\"$environment\", job=\"jenkins\", host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -685,7 +685,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "jenkins_executor_free_value{environment=\"$environment\"}",
+          "expr": "jenkins_executor_free_value{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -769,7 +769,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "jenkins_executor_in_use_value{environment=\"$environment\"}",
+          "expr": "jenkins_executor_in_use_value{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -833,7 +833,7 @@
       "steppedLine": false,
       "targets": [
         {
-          "expr": "jenkins_job_buildable_duration_count{environment=\"$environment\"}",
+          "expr": "jenkins_job_buildable_duration_count{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 2,
           "legendFormat": "buildable",
@@ -841,28 +841,28 @@
           "step": 10
         },
         {
-          "expr": "jenkins_job_building_duration_count{environment=\"$environment\"}",
+          "expr": "jenkins_job_building_duration_count{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "legendFormat": "building",
           "refId": "B"
         },
         {
-          "expr": "jenkins_job_scheduled_total{environment=\"$environment\"}",
+          "expr": "jenkins_job_scheduled_total{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "legendFormat": "scheduled",
           "refId": "C"
         },
         {
-          "expr": "jenkins_job_waiting_duration_count{environment=\"$environment\"}",
+          "expr": "jenkins_job_waiting_duration_count{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "legendFormat": "waiting",
           "refId": "D"
         },
         {
-          "expr": "jenkins_job_blocked_duration_count{environment=\"$environment\"}",
+          "expr": "jenkins_job_blocked_duration_count{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 1,
           "legendFormat": "blocked",
@@ -987,7 +987,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "rate(jenkins_job_building_duration_count{environment=\"$environment\"}[1m])",
+          "expr": "rate(jenkins_job_building_duration_count{environment=\"$environment\",host=~\"$host\"}[1m])",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -1070,7 +1070,7 @@
       "tableColumn": "",
       "targets": [
         {
-          "expr": "rate(jenkins_job_queuing_duration_count{environment=\"$environment\"}[1m])",
+          "expr": "rate(jenkins_job_queuing_duration_count{environment=\"$environment\",host=~\"$host\"}[1m])",
           "format": "time_series",
           "intervalFactor": 1,
           "refId": "A",
@@ -1132,7 +1132,7 @@
       "steppedLine": false,
       "targets": [
         {
-          "expr": "jenkins_job_queuing_duration{environment=\"$environment\"}",
+          "expr": "jenkins_job_queuing_duration{environment=\"$environment\",host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 2,
           "legendFormat": "{{ quantile }}",
@@ -1236,10 +1236,10 @@
       "steppedLine": false,
       "targets": [
         {
-          "expr": "vm_cpu_load{environment=\"$environment\", job=\"jenkins\"}",
+          "expr": "vm_cpu_load{environment=\"$environment\", job=\"jenkins\", host=~\"$host\"}",
           "format": "time_series",
           "intervalFactor": 2,
-          "legendFormat": "{{ instance }}",
+          "legendFormat": "{{ host }}",
           "refId": "A",
           "step": 5
         }
@@ -1311,6 +1311,26 @@
         "tagsQuery": "",
         "type": "query",
         "useTags": false
+      },
+      {
+        "allValue": null,
+        "current": {},
+        "datasource": null,
+        "hide": 0,
+        "includeAll": true,
+        "label": null,
+        "multi": false,
+        "name": "host",
+        "options": [],
+        "query": "label_values(jenkins_health_check_score{environment=\"$environment\"},host)",
+        "refresh": 1,
+        "regex": "",
+        "sort": 1,
+        "tagValuesQuery": "",
+        "tags": [],
+        "tagsQuery": "",
+        "type": "query",
+        "useTags": false
       }
     ]
   },
@@ -1346,6 +1366,6 @@
   "timezone": "browser",
   "title": "Jenkins",
   "uid": null,
-  "version": 1
+  "version": 2
 }
 {%- endraw %}