From 686d4f8eb36fbe030e62bc507381c105552ad6cd Mon Sep 17 00:00:00 2001 From: Manda-supraja26 Date: Wed, 31 Jan 2024 18:41:46 +0530 Subject: [PATCH] Adding vegeta-wrapper dashboard to grafonnet --- assets/vegeta-wrapper/panels.libsonnet | 198 ++++++++++++++++++++ assets/vegeta-wrapper/queries.libsonnet | 116 ++++++++++++ assets/vegeta-wrapper/variables.libsonnet | 38 ++++ templates/General/vegeta-wrapper-v2.jsonnet | 31 +++ 4 files changed, 383 insertions(+) create mode 100644 assets/vegeta-wrapper/panels.libsonnet create mode 100644 assets/vegeta-wrapper/queries.libsonnet create mode 100644 assets/vegeta-wrapper/variables.libsonnet create mode 100644 templates/General/vegeta-wrapper-v2.jsonnet diff --git a/assets/vegeta-wrapper/panels.libsonnet b/assets/vegeta-wrapper/panels.libsonnet new file mode 100644 index 0000000..3abfa63 --- /dev/null +++ b/assets/vegeta-wrapper/panels.libsonnet @@ -0,0 +1,198 @@ +local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'; + +{ + timeSeries: { + local timeSeries = g.panel.timeSeries, + local custom = timeSeries.fieldConfig.defaults.custom, + local options = timeSeries.options, + + base(title, unit, targets, gridPos): + timeSeries.new(title) + + timeSeries.queryOptions.withTargets(targets) + + timeSeries.datasource.withType('elasticsearch') + + timeSeries.datasource.withUid('$Datasource') + + timeSeries.standardOptions.withUnit(unit) + + timeSeries.gridPos.withX(gridPos.x) + + timeSeries.gridPos.withY(gridPos.y) + + timeSeries.gridPos.withH(gridPos.h) + + timeSeries.gridPos.withW(gridPos.w) + + custom.withSpanNulls(false) + + options.tooltip.withMode('multi') + + options.tooltip.withSort('none') + + options.legend.withShowLegend(true) + + timeSeries.queryOptions.withTimeFrom(null) + + timeSeries.queryOptions.withTimeShift(null) + + timeSeries.panelOptions.withTransparent(true), + + legendDisplayModeTable(title,unit, targets, gridPos): + self.base(title, unit, targets, gridPos) + + options.legend.withCalcs([ + 'mean', + 'max', + ]) + + options.legend.withShowLegend(true) + + options.legend.withDisplayMode('table') + + options.legend.withPlacement('bottom') + + custom.withLineWidth(1) + + custom.withFillOpacity(20) + + custom.withPointSize(5) + + custom.withSpanNulls(true) + + custom.withShowPoints('never'), + }, + + table: { + local table = g.panel.table, + local custom = table.fieldConfig.defaults.custom, + local options = table.options, + + base(title, targets, gridPos): + table.new(title) + + table.queryOptions.withTargets(targets) + + table.datasource.withType('elasticsearch') + + table.datasource.withUid('$Datasource') + + table.gridPos.withX(gridPos.x) + + table.gridPos.withY(gridPos.y) + + table.gridPos.withH(gridPos.h) + + table.gridPos.withW(gridPos.w) + + options.withShowHeader(true) + + options.footer.TableFooterOptions.withShow(false) + + options.footer.TableFooterOptions.withReducer('sum') + + options.footer.TableFooterOptions.withCountRows(false) + + custom.withAlign('auto') + + custom.withInspect(false) + + table.panelOptions.withTransparent(true) + + table.queryOptions.withTimeFrom(null) + + table.queryOptions.withTimeShift(null) + + table.standardOptions.color.withMode('thresholds') + + table.queryOptions.withTransformations([ + { + "id": "seriesToColumns", + "options": { + "reducers": [] + } + } + ]) + + table.standardOptions.withOverrides([ + { + "matcher": { + "id": "byName", + "options": "Average rps" + }, + "properties": [ + { + "id": "unit", + "value": "reqps" + }, + { + "id": "decimals", + "value": "2" + }, + { + "id": "custom.align", + "value": null + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Average throughput" + }, + "properties": [ + { + "id": "unit", + "value": "reqps" + }, + { + "id": "decimals", + "value": "2" + }, + { + "id": "custom.align", + "value": null + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Average p99_latency" + }, + "properties": [ + { + "id": "unit", + "value": "µs" + }, + { + "id": "decimals", + "value": "2" + }, + { + "id": "custom.align", + "value": null + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Average req_latency" + }, + "properties": [ + { + "id": "unit", + "value": "µs" + }, + { + "id": "decimals", + "value": "2" + }, + { + "id": "custom.align", + "value": null + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Average bytes_in" + }, + "properties": [ + { + "id": "unit", + "value": "bps" + }, + { + "id": "decimals", + "value": "2" + }, + { + "id": "custom.align", + "value": null + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Average bytes_out" + }, + "properties": [ + { + "id": "unit", + "value": "bps" + }, + { + "id": "decimals", + "value": "2" + }, + { + "id": "custom.align", + "value": null + } + ] + } + ]), + } +} diff --git a/assets/vegeta-wrapper/queries.libsonnet b/assets/vegeta-wrapper/queries.libsonnet new file mode 100644 index 0000000..2355a76 --- /dev/null +++ b/assets/vegeta-wrapper/queries.libsonnet @@ -0,0 +1,116 @@ +local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'; +local variables = import './variables.libsonnet'; +local elasticsearch = g.query.elasticsearch; + +{ + rps: { + query(): + elasticsearch.withAlias(null) + + elasticsearch.withBucketAggs([ + elasticsearch.bucketAggs.DateHistogram.withField("timestamp") + + elasticsearch.bucketAggs.DateHistogram.withId("2") + + elasticsearch.bucketAggs.DateHistogram.withType('date_histogram') + + elasticsearch.bucketAggs.DateHistogram.settings.withInterval('auto') + + elasticsearch.bucketAggs.DateHistogram.settings.withMinDocCount(0) + + elasticsearch.bucketAggs.DateHistogram.settings.withTimeZone("utc") + + elasticsearch.bucketAggs.DateHistogram.settings.withTrimEdges(null), + ]) + + elasticsearch.withMetrics([ + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("rps") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("1") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg') + ]) + + elasticsearch.withQuery('uuid: $uuid AND hostname: $hostname AND iteration: $iteration AND targets: "$targets"') + + elasticsearch.withTimeField('timestamp') + }, + + throughput: { + query(): + elasticsearch.withAlias(null) + + elasticsearch.withBucketAggs([ + elasticsearch.bucketAggs.DateHistogram.withField("timestamp") + + elasticsearch.bucketAggs.DateHistogram.withId("2") + + elasticsearch.bucketAggs.DateHistogram.withType('date_histogram') + + elasticsearch.bucketAggs.DateHistogram.settings.withInterval('auto') + + elasticsearch.bucketAggs.DateHistogram.settings.withMinDocCount(0) + + elasticsearch.bucketAggs.DateHistogram.settings.withTimeZone("utc") + + elasticsearch.bucketAggs.DateHistogram.settings.withTrimEdges(null), + ]) + + elasticsearch.withMetrics([ + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("throughput") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("1") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg') + ]) + + elasticsearch.withQuery('uuid: $uuid AND hostname: $hostname AND iteration: $iteration AND targets: "$targets"') + + elasticsearch.withTimeField('timestamp') + }, + + latency: { + query(): + elasticsearch.withAlias(null) + + elasticsearch.withBucketAggs([ + elasticsearch.bucketAggs.DateHistogram.withField("timestamp") + + elasticsearch.bucketAggs.DateHistogram.withId("2") + + elasticsearch.bucketAggs.DateHistogram.withType('date_histogram') + + elasticsearch.bucketAggs.DateHistogram.settings.withInterval('auto') + + elasticsearch.bucketAggs.DateHistogram.settings.withMinDocCount(0) + + elasticsearch.bucketAggs.DateHistogram.settings.withTimeZone("utc") + + elasticsearch.bucketAggs.DateHistogram.settings.withTrimEdges(null), + ]) + + elasticsearch.withMetrics([ + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("req_latency") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("1") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg') + ]) + + elasticsearch.withQuery('uuid: $uuid AND hostname: $hostname AND iteration: $iteration AND targets: "$targets"') + + elasticsearch.withTimeField('timestamp') + }, + + results: { + query(): + elasticsearch.withAlias(null) + + elasticsearch.withBucketAggs([ + elasticsearch.bucketAggs.Terms.withField("uuid.keyword") + + elasticsearch.bucketAggs.Terms.withId("2") + + elasticsearch.bucketAggs.Terms.withType('terms') + + elasticsearch.bucketAggs.Terms.settings.withOrder('desc') + + elasticsearch.bucketAggs.Terms.settings.withOrderBy('_term') + + elasticsearch.bucketAggs.Terms.settings.withMinDocCount(1) + + elasticsearch.bucketAggs.Terms.settings.withSize("10"), + elasticsearch.bucketAggs.Terms.withField("targets.keyword") + + elasticsearch.bucketAggs.Terms.withId("1") + + elasticsearch.bucketAggs.Terms.withType('terms') + + elasticsearch.bucketAggs.Terms.settings.withOrder('desc') + + elasticsearch.bucketAggs.Terms.settings.withOrderBy('_term') + + elasticsearch.bucketAggs.Terms.settings.withMinDocCount(1) + + elasticsearch.bucketAggs.Terms.settings.withSize("10") + ]) + + elasticsearch.withMetrics([ + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("rps") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("3") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg'), + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("throughput") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("4") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg'), + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("p99_latency") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("5") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg'), + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("req_latency") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("6") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg'), + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("bytes_in") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("7") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg'), + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withField("bytes_out") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withId("8") + + elasticsearch.metrics.MetricAggregationWithSettings.Average.withType('avg') + ]) + + elasticsearch.withQuery('uuid: $uuid AND hostname: $hostname AND iteration: $iteration AND targets: "$targets"') + + elasticsearch.withTimeField('timestamp') + } +} \ No newline at end of file diff --git a/assets/vegeta-wrapper/variables.libsonnet b/assets/vegeta-wrapper/variables.libsonnet new file mode 100644 index 0000000..91e824d --- /dev/null +++ b/assets/vegeta-wrapper/variables.libsonnet @@ -0,0 +1,38 @@ +local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'; +local var = g.dashboard.variable; + +{ + Datasource: + var.datasource.new('Datasource','elasticsearch') + + var.datasource.withRegex('/(.*vegeta.*)/') + + var.query.generalOptions.withLabel('vegeta-results datasource'), + + uuid: + var.query.new('uuid','{"find": "terms", "field": "uuid.keyword"}') + + var.query.withDatasourceFromVariable(self.Datasource) + + var.query.withRefresh(2) + + var.query.selectionOptions.withMulti(false) + + var.query.selectionOptions.withIncludeAll(true) + + var.query.generalOptions.withLabel('UUID'), + + hostname: + var.query.new('hostname','{"find": "terms", "field": "hostname.keyword"}') + + var.query.withDatasourceFromVariable(self.Datasource) + + var.query.withRefresh(2) + + var.query.selectionOptions.withMulti(false) + + var.query.selectionOptions.withIncludeAll(true), + + targets: + var.query.new('targets','{"find": "terms", "field": "targets.keyword"}') + + var.query.withDatasourceFromVariable(self.Datasource) + + var.query.withRefresh(2) + + var.query.selectionOptions.withMulti(false) + + var.query.selectionOptions.withIncludeAll(true), + + iteration: + var.query.new('iteration','{"find": "terms", "field": "iteration"}') + + var.query.withDatasourceFromVariable(self.Datasource) + + var.query.withRefresh(2) + + var.query.selectionOptions.withMulti(false) + + var.query.selectionOptions.withIncludeAll(true), +} \ No newline at end of file diff --git a/templates/General/vegeta-wrapper-v2.jsonnet b/templates/General/vegeta-wrapper-v2.jsonnet new file mode 100644 index 0000000..b0c5385 --- /dev/null +++ b/templates/General/vegeta-wrapper-v2.jsonnet @@ -0,0 +1,31 @@ +local panels = import '../../assets/vegeta-wrapper/panels.libsonnet'; +local queries = import '../../assets/vegeta-wrapper/queries.libsonnet'; +local variables = import '../../assets/vegeta-wrapper/variables.libsonnet'; +local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'; + +g.dashboard.new('Vegeta Results') ++ g.dashboard.withDescription(||| + Dashboard for Ingress Performance +|||) ++ g.dashboard.withTags('') ++ g.dashboard.time.withFrom('now-24h') ++ g.dashboard.time.withTo('now') ++ g.dashboard.withTimezone('utc') ++ g.dashboard.timepicker.withRefreshIntervals(['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d']) ++ g.dashboard.timepicker.withTimeOptions(['5m', '15m', '1h', '6h', '12h', '24h', '2d', '7d', '30d']) ++ g.dashboard.withRefresh('') ++ g.dashboard.withEditable(false) ++ g.dashboard.graphTooltip.withSharedCrosshair() ++ g.dashboard.withVariables([ + variables.Datasource, + variables.uuid, + variables.hostname, + variables.targets, + variables.iteration, +]) ++ g.dashboard.withPanels([ + panels.timeSeries.legendDisplayModeTable('RPS (rate of sent requests per second)', 'reqps', queries.rps.query(), { x: 0, y: 0, w: 12, h: 9 }), + panels.timeSeries.legendDisplayModeTable('Throughput (rate of successful requests per second)', 'reqps', queries.throughput.query(), { x: 12, y: 0, w: 12, h: 9 }), + panels.timeSeries.legendDisplayModeTable('Request Latency (observed over given interval)', 'µs', queries.latency.query(), { x: 0, y: 12, w: 12, h: 9 }), + panels.table.base('Vegeta Result Summary', queries.results.query(), { x: 0, y: 24, w: 24, h: 9 }), +])