Extract yAxis object

Change-Id: I98c0708e521c0122beb53869242a3a1df8db3f3d
diff --git a/dashboards/gerrit/caches/panels/account_cache_misses.libsonnet b/dashboards/gerrit/caches/panels/account_cache_misses.libsonnet
index a5dbd4c..bb7047d 100644
--- a/dashboards/gerrit/caches/panels/account_cache_misses.libsonnet
+++ b/dashboards/gerrit/caches/panels/account_cache_misses.libsonnet
@@ -1,10 +1,10 @@
 local target = import './cache_target.libsonnet';
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='ACCOUNT cache misses',
-  labelY1='Cache Misses',
-  formatY1='percent',
+  yAxis1=yAxis.cache_misses,
   fill=0,
 )
 .addTarget(target.new('accounts'))
diff --git a/dashboards/gerrit/caches/panels/change_cache_misses.libsonnet b/dashboards/gerrit/caches/panels/change_cache_misses.libsonnet
index 4e116a8..3c6b42c 100644
--- a/dashboards/gerrit/caches/panels/change_cache_misses.libsonnet
+++ b/dashboards/gerrit/caches/panels/change_cache_misses.libsonnet
@@ -1,10 +1,10 @@
 local target = import './cache_target.libsonnet';
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='CHANGE cache misses',
-  labelY1='Cache Misses',
-  formatY1='percent',
+  yAxis1=yAxis.cache_misses,
   fill=0,
 )
 .addTarget(target.new('change_kind'))
diff --git a/dashboards/gerrit/caches/panels/conflict_cache_misses.libsonnet b/dashboards/gerrit/caches/panels/conflict_cache_misses.libsonnet
index 3958e14..768f1b6 100644
--- a/dashboards/gerrit/caches/panels/conflict_cache_misses.libsonnet
+++ b/dashboards/gerrit/caches/panels/conflict_cache_misses.libsonnet
@@ -1,10 +1,10 @@
 local target = import './cache_target.libsonnet';
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='CONFLICT cache misses',
-  labelY1='Cache Misses',
-  formatY1='percent',
+  yAxis1=yAxis.cache_misses,
   fill=0,
 )
 .addTarget(target.new('conflicts'))
diff --git a/dashboards/gerrit/caches/panels/diff_cache_misses.libsonnet b/dashboards/gerrit/caches/panels/diff_cache_misses.libsonnet
index a6a27ce..349b71e 100644
--- a/dashboards/gerrit/caches/panels/diff_cache_misses.libsonnet
+++ b/dashboards/gerrit/caches/panels/diff_cache_misses.libsonnet
@@ -1,10 +1,10 @@
 local target = import './cache_target.libsonnet';
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='DIFF cache misses',
-  labelY1='Cache Misses',
-  formatY1='percent',
+  yAxis1=yAxis.cache_misses,
   fill=0,
 )
 .addTarget(target.new('diff'))
diff --git a/dashboards/gerrit/caches/panels/misc_cache_misses.libsonnet b/dashboards/gerrit/caches/panels/misc_cache_misses.libsonnet
index 607e513..5ad89d6 100644
--- a/dashboards/gerrit/caches/panels/misc_cache_misses.libsonnet
+++ b/dashboards/gerrit/caches/panels/misc_cache_misses.libsonnet
@@ -1,10 +1,10 @@
 local target = import './cache_target.libsonnet';
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='MISC cache misses',
-  labelY1='Cache Misses',
-  formatY1='percent',
+  yAxis1=yAxis.cache_misses,
   fill=0,
 )
 .addTarget(target.new('web_sessions'))
diff --git a/dashboards/gerrit/caches/panels/project_cache_misses.libsonnet b/dashboards/gerrit/caches/panels/project_cache_misses.libsonnet
index 1b5e5dc..90e0893 100644
--- a/dashboards/gerrit/caches/panels/project_cache_misses.libsonnet
+++ b/dashboards/gerrit/caches/panels/project_cache_misses.libsonnet
@@ -1,10 +1,10 @@
 local target = import './cache_target.libsonnet';
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='PROJECT cache misses',
-  labelY1='Cache Misses',
-  formatY1='percent',
+  yAxis1=yAxis.cache_misses,
   fill=0,
 )
 .addTarget(target.new('project_list'))
diff --git a/dashboards/gerrit/process/panels/cpu.libsonnet b/dashboards/gerrit/process/panels/cpu.libsonnet
index 37cb8aa..0042af1 100644
--- a/dashboards/gerrit/process/panels/cpu.libsonnet
+++ b/dashboards/gerrit/process/panels/cpu.libsonnet
@@ -2,10 +2,11 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='CPU',
-  labelY1='CPU cores',
+  yAxis1=yAxis.new(label='CPU cores'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/process/panels/file-descriptors.libsonnet b/dashboards/gerrit/process/panels/file-descriptors.libsonnet
index e222f44..38d9fd1 100644
--- a/dashboards/gerrit/process/panels/file-descriptors.libsonnet
+++ b/dashboards/gerrit/process/panels/file-descriptors.libsonnet
@@ -3,10 +3,11 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='Java open file descriptors',
-  labelY1='Open File Descriptors',
+  yAxis1=yAxis.new(label='Open File Descriptors'),
   stack=true,
 )
 .addTarget(
diff --git a/dashboards/gerrit/process/panels/gc-time.libsonnet b/dashboards/gerrit/process/panels/gc-time.libsonnet
index bac395e..16a11ac 100644
--- a/dashboards/gerrit/process/panels/gc-time.libsonnet
+++ b/dashboards/gerrit/process/panels/gc-time.libsonnet
@@ -2,11 +2,14 @@
 local prometheus = grafana.prometheus;
 
 local barGraph = import '../../../globals/bar-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 barGraph.new(
   title='Java - % of time spent in GC',
-  formatY1='percentunit',
-  labelY1='GC Time',
+  yAxis1=yAxis.new(
+    label='Open File Descriptors',
+    format='percentunit',
+  ),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/process/panels/jgit-block-cache.libsonnet b/dashboards/gerrit/process/panels/jgit-block-cache.libsonnet
index 41e2aec..8bcecc2 100644
--- a/dashboards/gerrit/process/panels/jgit-block-cache.libsonnet
+++ b/dashboards/gerrit/process/panels/jgit-block-cache.libsonnet
@@ -3,13 +3,18 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='JGit block cache',
-  formatY1='percentunit',
-  labelY1='miss ratio',
-  formatY2='percentunit',
-  labelY2='eviction ratio',
+  yAxis1=yAxis.new(
+    label='miss ratio',
+    format='percentunit',
+  ),
+  yAxis2=yAxis.new(
+    label='eviction ratio',
+    format='percentunit',
+  ),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/process/panels/memory.libsonnet b/dashboards/gerrit/process/panels/memory.libsonnet
index 2b38c3e..685535e 100644
--- a/dashboards/gerrit/process/panels/memory.libsonnet
+++ b/dashboards/gerrit/process/panels/memory.libsonnet
@@ -3,11 +3,14 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='Memory',
-  formatY1='decbytes',
-  labelY1='Memory Consumption',
+  yAxis1=yAxis.new(
+    label='Memory Consumption',
+    format='decbytes',
+  ),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/process/panels/system-load.libsonnet b/dashboards/gerrit/process/panels/system-load.libsonnet
index 1ba4389..a16f3c4 100644
--- a/dashboards/gerrit/process/panels/system-load.libsonnet
+++ b/dashboards/gerrit/process/panels/system-load.libsonnet
@@ -3,10 +3,11 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='System load',
-  labelY1='System load',
+  yAxis1=yAxis.new(label='System load'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/process/panels/threads.libsonnet b/dashboards/gerrit/process/panels/threads.libsonnet
index 4792a86..3bc0f3d 100644
--- a/dashboards/gerrit/process/panels/threads.libsonnet
+++ b/dashboards/gerrit/process/panels/threads.libsonnet
@@ -3,10 +3,11 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='Threads',
-  labelY1='Live Threads',
+  yAxis1=yAxis.new(label='Live Threads'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/http_queue.libsonnet b/dashboards/gerrit/queues/panels/http_queue.libsonnet
index 26ec00d..44b1545 100644
--- a/dashboards/gerrit/queues/panels/http_queue.libsonnet
+++ b/dashboards/gerrit/queues/panels/http_queue.libsonnet
@@ -2,12 +2,13 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local HTTP_TARGET = 'http';
 
 lineGraph.new(
   title='HTTP queue',
-  labelY1='Tasks',
+  yAxis1=yAxis.new(label='Tasks'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/http_threads.libsonnet b/dashboards/gerrit/queues/panels/http_threads.libsonnet
index 8698928..d75de0b 100644
--- a/dashboards/gerrit/queues/panels/http_threads.libsonnet
+++ b/dashboards/gerrit/queues/panels/http_threads.libsonnet
@@ -2,6 +2,7 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local ACTIVE_THREADS_TARGET = 'active threads';
 local RESERVED_THREADS_TARGET = 'reserved threads';
@@ -10,7 +11,7 @@
 
 lineGraph.new(
   title='HTTP threads',
-  labelY1='Threads',
+  yAxis1=yAxis.new(label='Threads'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/index_queue.libsonnet b/dashboards/gerrit/queues/panels/index_queue.libsonnet
index a110580..6543ff8 100644
--- a/dashboards/gerrit/queues/panels/index_queue.libsonnet
+++ b/dashboards/gerrit/queues/panels/index_queue.libsonnet
@@ -2,13 +2,14 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local BATCH_TARGET = 'batch';
 local INTERACTIVE_TARGET = 'interactive';
 
 lineGraph.new(
   title='INDEX queue',
-  labelY1='Tasks',
+  yAxis1=yAxis.new(label='Tasks'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/index_threads.libsonnet b/dashboards/gerrit/queues/panels/index_threads.libsonnet
index 89b7faf..fb9d2c8 100644
--- a/dashboards/gerrit/queues/panels/index_threads.libsonnet
+++ b/dashboards/gerrit/queues/panels/index_threads.libsonnet
@@ -2,6 +2,7 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local BATCH_THREADS_TARGET = 'batch threads';
 local BATCH_POOL_SIZE_TARGET = 'batch pool size';
@@ -10,7 +11,7 @@
 
 lineGraph.new(
   title='INDEX threads',
-  labelY1='Threads',
+  yAxis1=yAxis.new(label='Threads'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/misc_queue.libsonnet b/dashboards/gerrit/queues/panels/misc_queue.libsonnet
index a3b389e..a04339d 100644
--- a/dashboards/gerrit/queues/panels/misc_queue.libsonnet
+++ b/dashboards/gerrit/queues/panels/misc_queue.libsonnet
@@ -2,6 +2,7 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local STREAM_TARGET = 'stream threads';
 local EMAIL_TARGET = 'email threads';
@@ -9,7 +10,7 @@
 
 lineGraph.new(
   title='MISC queues',
-  labelY1='Tasks',
+  yAxis1=yAxis.new(label='Tasks'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/misc_threads.libsonnet b/dashboards/gerrit/queues/panels/misc_threads.libsonnet
index a9ff614..c3fab58 100644
--- a/dashboards/gerrit/queues/panels/misc_threads.libsonnet
+++ b/dashboards/gerrit/queues/panels/misc_threads.libsonnet
@@ -2,6 +2,7 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local STREAM_TARGET = 'stream threads';
 local STREAM_POOL_SIZE_TARGET = 'stream pool size';
@@ -12,7 +13,7 @@
 
 lineGraph.new(
   title='MISC threads',
-  labelY1='Threads',
+  yAxis1=yAxis.new(label='Threads'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/rest-api-request-rate.libsonnet b/dashboards/gerrit/queues/panels/rest-api-request-rate.libsonnet
index 25a44c9..b94ad68 100644
--- a/dashboards/gerrit/queues/panels/rest-api-request-rate.libsonnet
+++ b/dashboards/gerrit/queues/panels/rest-api-request-rate.libsonnet
@@ -2,11 +2,14 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 lineGraph.new(
   title='REST API request rate',
-  labelY1='Requests/Second',
-  formatY1='reqps',
+  yAxis1=yAxis.new(
+    label='Threads',
+    format='reqps',
+  ),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/ssh_queue.libsonnet b/dashboards/gerrit/queues/panels/ssh_queue.libsonnet
index 78d7e55..91fd69c 100644
--- a/dashboards/gerrit/queues/panels/ssh_queue.libsonnet
+++ b/dashboards/gerrit/queues/panels/ssh_queue.libsonnet
@@ -2,13 +2,14 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local BATCH_TARGET = 'batch';
 local INTERACTIVE_TARGET = 'interactive';
 
 lineGraph.new(
   title='SSH queue',
-  labelY1='Tasks',
+  yAxis1=yAxis.new(label='Tasks'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/gerrit/queues/panels/ssh_threads.libsonnet b/dashboards/gerrit/queues/panels/ssh_threads.libsonnet
index e050d74..d01bad9 100644
--- a/dashboards/gerrit/queues/panels/ssh_threads.libsonnet
+++ b/dashboards/gerrit/queues/panels/ssh_threads.libsonnet
@@ -2,6 +2,7 @@
 local prometheus = grafana.prometheus;
 
 local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
 
 local BATCH_THREADS_TARGET = 'batch threads';
 local BATCH_POOL_SIZE_TARGET = 'batch pool size';
@@ -10,7 +11,7 @@
 
 lineGraph.new(
   title='SSH threads',
-  labelY1='Threads',
+  yAxis1=yAxis.new(label='Threads'),
 )
 .addTarget(
   prometheus.target(
diff --git a/dashboards/globals/bar-graph.libsonnet b/dashboards/globals/bar-graph.libsonnet
index 125d21f..4cd7b65 100644
--- a/dashboards/globals/bar-graph.libsonnet
+++ b/dashboards/globals/bar-graph.libsonnet
@@ -2,21 +2,26 @@
 local graphPanel = grafana.graphPanel;
 
 local defaults = import './defaults.libsonnet';
+local yAxis = import './yaxis.libsonnet';
 
 {
   new(
     title,
-    labelY1,
-    labelY2='',
-    formatY1='short',
-    formatY2='short',
+    yAxis1,
+    yAxis2=yAxis.new(),
+    min=null,
+    max=null,
     stack=false,
   ):: graphPanel.new(
     title=title,
-    labelY1=labelY1,
-    labelY2=labelY2,
-    formatY1=formatY1,
-    formatY2=formatY2,
+    labelY1=yAxis1.label,
+    formatY1=yAxis1.format,
+    logBase1Y=yAxis1.logBase,
+    labelY2=yAxis2.label,
+    formatY2=yAxis2.format,
+    logBase2Y=yAxis2.logBase,
+    min=min,
+    max=max,
     stack=stack,
     datasource=defaults.datasource,
     fill=1,
diff --git a/dashboards/globals/line-graph.libsonnet b/dashboards/globals/line-graph.libsonnet
index 4c73943..eb531f3 100644
--- a/dashboards/globals/line-graph.libsonnet
+++ b/dashboards/globals/line-graph.libsonnet
@@ -2,22 +2,27 @@
 local graphPanel = grafana.graphPanel;
 
 local defaults = import './defaults.libsonnet';
+local yAxis = import './yaxis.libsonnet';
 
 {
   new(
     title,
-    labelY1,
-    labelY2='',
-    formatY1='short',
-    formatY2='short',
+    yAxis1,
+    yAxis2=yAxis.new(),
+    min=null,
+    max=null,
     stack=false,
     fill=1,
   ):: graphPanel.new(
     title=title,
-    labelY1=labelY1,
-    labelY2=labelY2,
-    formatY1=formatY1,
-    formatY2=formatY2,
+    labelY1=yAxis1.label,
+    formatY1=yAxis1.format,
+    logBase1Y=yAxis1.logBase,
+    labelY2=yAxis2.label,
+    formatY2=yAxis2.format,
+    logBase2Y=yAxis2.logBase,
+    min=min,
+    max=max,
     stack=stack,
     datasource=defaults.datasource,
     fill=fill,
diff --git a/dashboards/globals/yaxis.libsonnet b/dashboards/globals/yaxis.libsonnet
new file mode 100644
index 0000000..3e01a52
--- /dev/null
+++ b/dashboards/globals/yaxis.libsonnet
@@ -0,0 +1,18 @@
+{
+  new(show=true,
+      format='short',
+      label='',
+      logBase=1,):: {
+        format: format,
+        label: label,
+        logBase: logBase,
+  },
+  latency: self.new(
+    label='Latency',
+    format='s',
+  ),
+  cache_misses: self.new(
+    label='Cache Misses',
+    format='percent',
+  ),
+}