Skip to content

Commit

Permalink
Merge pull request #108 from Manda-supraja26/Vegeta
Browse files Browse the repository at this point in the history
Adding vegeta-wrapper dashboard to grafonnet
  • Loading branch information
vishnuchalla authored Feb 9, 2024
2 parents 4c1656b + ebbea59 commit 1ab1846
Show file tree
Hide file tree
Showing 4 changed files with 404 additions and 0 deletions.
198 changes: 198 additions & 0 deletions assets/vegeta-wrapper/panels.libsonnet
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]),
}
}
137 changes: 137 additions & 0 deletions assets/vegeta-wrapper/queries.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
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'),

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("p99_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')
}
}
38 changes: 38 additions & 0 deletions assets/vegeta-wrapper/variables.libsonnet
Original file line number Diff line number Diff line change
@@ -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),
}
Loading

0 comments on commit 1ab1846

Please sign in to comment.