From b9b8fda268e4cc21cdf3a082a87017d80afda76f Mon Sep 17 00:00:00 2001 From: Samir Sharan Date: Wed, 23 Sep 2020 18:21:01 -0400 Subject: [PATCH 1/4] Add number of decimal places to set for bar_gauge_panel --- grafonnet/bar_gauge_panel.libsonnet | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grafonnet/bar_gauge_panel.libsonnet b/grafonnet/bar_gauge_panel.libsonnet index 313e5a03..7dd0ede5 100644 --- a/grafonnet/bar_gauge_panel.libsonnet +++ b/grafonnet/bar_gauge_panel.libsonnet @@ -9,6 +9,7 @@ * @param datasource (optional) Panel datasource. * @param unit (optional) The unit of the data. * @param thresholds (optional) An array of threashold values. + * @param decimals (optional) Number of decimal places to show. * * @method addTarget(target) Adds a target object. * @method addTargets(targets) Adds an array of targets. @@ -19,6 +20,7 @@ datasource=null, unit=null, thresholds=[], + decimals=null, ):: { type: 'bargauge', title: title, @@ -28,6 +30,7 @@ ], fieldConfig: { defaults: { + [if decimals != null then 'decimals']: decimals, unit: unit, thresholds: { mode: 'absolute', From 955b9bbe9043a926f8c951a81e5178c01f72554d Mon Sep 17 00:00:00 2001 From: Samir Sharan Date: Wed, 23 Sep 2020 18:46:45 -0400 Subject: [PATCH 2/4] jsonnet format --- grafonnet/bar_gauge_panel.libsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grafonnet/bar_gauge_panel.libsonnet b/grafonnet/bar_gauge_panel.libsonnet index 7dd0ede5..0cfcb224 100644 --- a/grafonnet/bar_gauge_panel.libsonnet +++ b/grafonnet/bar_gauge_panel.libsonnet @@ -30,7 +30,7 @@ ], fieldConfig: { defaults: { - [if decimals != null then 'decimals']: decimals, + [if decimals != null then 'decimals']: decimals, unit: unit, thresholds: { mode: 'absolute', From a030d35476dd6d2e97d5b2edf6c70b5dbfb232c7 Mon Sep 17 00:00:00 2001 From: Samir Sharan Date: Thu, 24 Sep 2020 14:22:59 -0400 Subject: [PATCH 3/4] Adding various other missing params to configure for pie_chart_panel.libsonnet --- grafonnet/pie_chart_panel.libsonnet | 37 ++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/grafonnet/pie_chart_panel.libsonnet b/grafonnet/pie_chart_panel.libsonnet index 11719e10..aa8519e8 100644 --- a/grafonnet/pie_chart_panel.libsonnet +++ b/grafonnet/pie_chart_panel.libsonnet @@ -9,6 +9,17 @@ * @param title The title of the pie chart panel. * @param description (default `''`) Description of the panel * @param span (optional) Width of the panel + * @param breakPoint (optional) breakPoint + * @param cacheTimeout (optional) cacheTimeout + * @param combine_label (default `'Others'`) + * @param combine_threshold (default `0`) + * @param decimals (default `null`) Number of decimal places to show + * @param timeFrom (default `null`) + * @param timeShift (default `null`) + * @param legend_header (optional) legend header + * @param legend_sort (default `'avg'`) + * @param legend_sortDesc (default `true`) sort descending + * @param format (default `'short'`) unit * @param min_span (optional) Min span * @param datasource (optional) Datasource * @param aliasColors (optional) Define color mappings @@ -28,6 +39,17 @@ title, description='', span=null, + breakPoint=null, + cacheTimeout=null, + combine_label='Others', + combine_threshold=0, + decimals=null, + timeFrom=null, + timeShift=null, + legend_header='', + legend_sort='avg', + legend_sortDesc=true, + format='short', min_span=null, datasource=null, height=null, @@ -45,6 +67,16 @@ [if description != null then 'description']: description, pieType: pieType, title: title, + breakPoint: breakPoint, + cacheTimeout: cacheTimeout, + decimals: decimals, + format: format, + combine: { + label: combine_label, + threshold: combine_threshold, + }, + timeFrom: timeFrom, + timeShift: timeShift, aliasColors: aliasColors, [if span != null then 'span']: span, [if min_span != null then 'minSpan']: min_span, @@ -55,9 +87,12 @@ valueName: valueName, datasource: datasource, legend: { + [if legend_header != null then 'header']: legend_header, + sort: legend_sort, + sortDesc: legend_sortDesc, show: showLegend, values: true, - percentage: showLegendPercentage, + [if showLegendPercentage != null then 'percentage']: showLegendPercentage, }, legendType: legendType, targets: [ From c48627ab5823ef29064fc969bcb5d3a9d8373cf2 Mon Sep 17 00:00:00 2001 From: Samir Sharan Date: Thu, 24 Sep 2020 15:35:56 -0400 Subject: [PATCH 4/4] updating the pie_chart_panel/test_compiled.json for the new params added , inorder to succeed the build --- grafonnet/bar_gauge_panel.libsonnet | 3 -- tests/pie_chart_panel/test_compiled.json | 39 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/grafonnet/bar_gauge_panel.libsonnet b/grafonnet/bar_gauge_panel.libsonnet index 0cfcb224..313e5a03 100644 --- a/grafonnet/bar_gauge_panel.libsonnet +++ b/grafonnet/bar_gauge_panel.libsonnet @@ -9,7 +9,6 @@ * @param datasource (optional) Panel datasource. * @param unit (optional) The unit of the data. * @param thresholds (optional) An array of threashold values. - * @param decimals (optional) Number of decimal places to show. * * @method addTarget(target) Adds a target object. * @method addTargets(targets) Adds an array of targets. @@ -20,7 +19,6 @@ datasource=null, unit=null, thresholds=[], - decimals=null, ):: { type: 'bargauge', title: title, @@ -30,7 +28,6 @@ ], fieldConfig: { defaults: { - [if decimals != null then 'decimals']: decimals, unit: unit, thresholds: { mode: 'absolute', diff --git a/tests/pie_chart_panel/test_compiled.json b/tests/pie_chart_panel/test_compiled.json index ca0be8dc..6f8ba0aa 100644 --- a/tests/pie_chart_panel/test_compiled.json +++ b/tests/pie_chart_panel/test_compiled.json @@ -5,11 +5,22 @@ "4xx": "#F2C96D", "5xx": "#BF1B00" }, + "breakPoint": null, + "cacheTimeout": null, + "combine": { + "label": "Others", + "threshold": 0 + }, "datasource": "$PROMETHEUS", + "decimals": null, "description": "description", + "format": "short", "legend": { + "header": "", "percentage": true, "show": true, + "sort": "avg", + "sortDesc": true, "values": true }, "legendType": "Right side", @@ -19,34 +30,60 @@ "repeatDirection": "h", "span": 12, "targets": [ ], + "timeFrom": null, + "timeShift": null, "title": "test", "type": "grafana-piechart-panel", "valueName": "current" }, "basic": { "aliasColors": { }, + "breakPoint": null, + "cacheTimeout": null, + "combine": { + "label": "Others", + "threshold": 0 + }, "datasource": null, + "decimals": null, "description": "", + "format": "short", "legend": { + "header": "", "percentage": true, "show": true, + "sort": "avg", + "sortDesc": true, "values": true }, "legendType": "Right side", "pieType": "pie", "span": 12, "targets": [ ], + "timeFrom": null, + "timeShift": null, "title": "test", "type": "grafana-piechart-panel", "valueName": "current" }, "targets": { "aliasColors": { }, + "breakPoint": null, + "cacheTimeout": null, + "combine": { + "label": "Others", + "threshold": 0 + }, "datasource": null, + "decimals": null, "description": "", + "format": "short", "legend": { + "header": "", "percentage": true, "show": true, + "sort": "avg", + "sortDesc": true, "values": true }, "legendType": "Right side", @@ -62,6 +99,8 @@ "refId": "B" } ], + "timeFrom": null, + "timeShift": null, "title": "with targets", "type": "grafana-piechart-panel", "valueName": "current"