From f331b308f36012d6c00d00914ce2165c996ed321 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Sat, 6 Jul 2019 21:09:17 +0200 Subject: [PATCH] Use promgrafonnet as a vendored library from its source The only deviation that happened so far is to use format="percentunit" in a Grafana gauge. This change wasn't even properly used in this repo so far, so I opted to stick with "upstream" for now. If changes are really needed, we can try to change upstream first. Another change was done in parallal here and upstream, but it was "more correct" in upstream. (Change datasource to $datasource variable, only partially applied here.) Which is another point for using the upstream and not copy it here. Signed-off-by: beorn7 --- docs/node-mixin/dashboards/node.libsonnet | 2 +- docs/node-mixin/jsonnetfile.json | 10 ++++ .../lib/promgrafonnet/gauge.libsonnet | 60 ------------------- .../promgrafonnet/numbersinglestat.libsonnet | 48 --------------- .../lib/promgrafonnet/promgrafonnet.libsonnet | 5 -- 5 files changed, 11 insertions(+), 114 deletions(-) delete mode 100644 docs/node-mixin/lib/promgrafonnet/gauge.libsonnet delete mode 100644 docs/node-mixin/lib/promgrafonnet/numbersinglestat.libsonnet delete mode 100644 docs/node-mixin/lib/promgrafonnet/promgrafonnet.libsonnet diff --git a/docs/node-mixin/dashboards/node.libsonnet b/docs/node-mixin/dashboards/node.libsonnet index 4594e3ed..80e2fa92 100644 --- a/docs/node-mixin/dashboards/node.libsonnet +++ b/docs/node-mixin/dashboards/node.libsonnet @@ -4,7 +4,7 @@ local row = grafana.row; local prometheus = grafana.prometheus; local template = grafana.template; local graphPanel = grafana.graphPanel; -local promgrafonnet = import '../lib/promgrafonnet/promgrafonnet.libsonnet'; +local promgrafonnet = import 'promgrafonnet/promgrafonnet.libsonnet'; local gauge = promgrafonnet.gauge; { diff --git a/docs/node-mixin/jsonnetfile.json b/docs/node-mixin/jsonnetfile.json index fc5aeee0..dc92880d 100644 --- a/docs/node-mixin/jsonnetfile.json +++ b/docs/node-mixin/jsonnetfile.json @@ -19,6 +19,16 @@ } }, "version": "master" + }, + { + "name": "promgrafonnet", + "source": { + "git": { + "remote": "https://github.com/kubernetes-monitoring/kubernetes-mixin", + "subdir": "lib/promgrafonnet" + } + }, + "version": "master" } ] } diff --git a/docs/node-mixin/lib/promgrafonnet/gauge.libsonnet b/docs/node-mixin/lib/promgrafonnet/gauge.libsonnet deleted file mode 100644 index 43640b6d..00000000 --- a/docs/node-mixin/lib/promgrafonnet/gauge.libsonnet +++ /dev/null @@ -1,60 +0,0 @@ -local grafana = import 'grafonnet/grafana.libsonnet'; -local singlestat = grafana.singlestat; -local prometheus = grafana.prometheus; - -{ - new(title, query):: - singlestat.new( - title, - datasource='$datasource', - span=3, - format='percentunit', - valueName='current', - colors=[ - 'rgba(245, 54, 54, 0.9)', - 'rgba(237, 129, 40, 0.89)', - 'rgba(50, 172, 45, 0.97)', - ], - thresholds='50, 80', - valueMaps=[ - { - op: '=', - text: 'N/A', - value: 'null', - }, - ], - ) - .addTarget( - prometheus.target( - query - ) - ) + { - gauge: { - maxValue: 100, - minValue: 0, - show: true, - thresholdLabels: false, - thresholdMarkers: true, - }, - withTextNullValue(text):: self { - valueMaps: [ - { - op: '=', - text: text, - value: 'null', - }, - ], - }, - withSpanSize(size):: self { - span: size, - }, - withLowerBeingBetter():: self { - colors: [ - 'rgba(50, 172, 45, 0.97)', - 'rgba(237, 129, 40, 0.89)', - 'rgba(245, 54, 54, 0.9)', - ], - thresholds: '80, 90', - }, - }, -} diff --git a/docs/node-mixin/lib/promgrafonnet/numbersinglestat.libsonnet b/docs/node-mixin/lib/promgrafonnet/numbersinglestat.libsonnet deleted file mode 100644 index bc1d6f6f..00000000 --- a/docs/node-mixin/lib/promgrafonnet/numbersinglestat.libsonnet +++ /dev/null @@ -1,48 +0,0 @@ -local grafana = import 'grafonnet/grafana.libsonnet'; -local singlestat = grafana.singlestat; -local prometheus = grafana.prometheus; - -{ - new(title, query):: - singlestat.new( - title, - datasource='prometheus', - span=3, - valueName='current', - valueMaps=[ - { - op: '=', - text: '0', - value: 'null', - }, - ], - ) - .addTarget( - prometheus.target( - query - ) - ) + { - withTextNullValue(text):: self { - valueMaps: [ - { - op: '=', - text: text, - value: 'null', - }, - ], - }, - withSpanSize(size):: self { - span: size, - }, - withPostfix(postfix):: self { - postfix: postfix, - }, - withSparkline():: self { - sparkline: { - show: true, - lineColor: 'rgb(31, 120, 193)', - fillColor: 'rgba(31, 118, 189, 0.18)', - }, - }, - }, -} diff --git a/docs/node-mixin/lib/promgrafonnet/promgrafonnet.libsonnet b/docs/node-mixin/lib/promgrafonnet/promgrafonnet.libsonnet deleted file mode 100644 index 013ff42b..00000000 --- a/docs/node-mixin/lib/promgrafonnet/promgrafonnet.libsonnet +++ /dev/null @@ -1,5 +0,0 @@ -{ - numbersinglestat:: import 'numbersinglestat.libsonnet', - gauge:: import 'gauge.libsonnet', - percentlinegraph:: import 'percentlinegraph.libsonnet', -}