Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding API-performance dashboard to grafonnet #96

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions assets/api-performance-overview/panels.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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.withDrawStyle("line")
+ custom.withLineInterpolation("linear")
+ custom.withBarAlignment(0)
+ custom.withLineWidth(1)
+ custom.withFillOpacity(10)
+ custom.withGradientMode("none")
+ custom.withSpanNulls(false)
+ custom.withPointSize(5)
+ custom.withSpanNulls(false)
+ custom.stacking.withGroup("A")
+ custom.stacking.withMode("none")
+ custom.withShowPoints('never'),

withCommonAggregations(title, unit, targets, gridPos):
self.base(title, unit, targets, gridPos)
+ options.legend.withCalcs([
'lastNotNull'
])
+ options.legend.withShowLegend(true)
+ options.legend.withDisplayMode('table')
+ options.legend.withPlacement('right')
+ options.tooltip.withMode('multi'),

withReadWriteSettings(title, unit, targets, gridPos):
self.base(title, unit, targets, gridPos)
+ options.tooltip.withMode('multi')
+ options.legend.withShowLegend(true)
+ options.legend.withDisplayMode('list')
+ options.legend.withPlacement('bottom')
+ options.tooltip.withMode('multi'),

withRequestWaitDurationAggregations(title, unit, targets, gridPos):
self.withCommonAggregations(title, unit, targets, gridPos)
+ options.legend.withCalcs([
'mean',
'max',
'lastNotNull'
])



}
}
190 changes: 190 additions & 0 deletions assets/api-performance-overview/queries.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
local variables = import './variables.libsonnet';
local prometheus = g.query.prometheus;

{
requestDuration99thQuantile: {
query():
prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_request_duration_seconds_bucket{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",subresource!=\"log\",verb!~\"WATCH|WATCHLIST|PROXY\"}[$interval])) by(verb,le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{verb}}')
+ prometheus.withDatasource('$Datasource')
},

requestRateByInstance: {
query():
prometheus.withExpr('sum(rate(apiserver_request_total{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",code=~\"$code\",verb=~\"$verb\"}[$interval])) by(instance)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{instance}}')
+ prometheus.withDatasource('$Datasource')
},

requestDuarationByResource: {
query():
prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_request_duration_seconds_bucket{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",subresource!=\"log\",verb!~\"WATCH|WATCHLIST|PROXY\"}[$interval])) by(resource,le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{resource}}')
+ prometheus.withDatasource('$Datasource')
},

requestDurationBy99Quatile: {
query():
prometheus.withExpr('sum(rate(apiserver_request_total{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",code=~\"$code\",verb=~\"$verb\"}[$interval])) by(resource)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{resource}}')
+ prometheus.withDatasource('$Datasource')
},

requestDurationReadWrite: {
query():
[ prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_request_duration_seconds_bucket{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",verb=~\"LIST|GET\"}[$interval])) by(le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('read')
+ prometheus.withDatasource('$Datasource'),

prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_request_duration_seconds_bucket{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",verb=~\"POST|PUT|PATCH|UPDATE|DELETE\"}[$interval])) by(le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('write')
+ prometheus.withDatasource('$Datasource')]
},

requestRateReadWrite: {
query():
[prometheus.withExpr('sum(rate(apiserver_request_total{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",verb=~\"LIST|GET\"}[$interval]))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('read')
+ prometheus.withDatasource('$Datasource'),

prometheus.withExpr('sum(rate(apiserver_request_total{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",verb=~\"POST|PUT|PATCH|UPDATE|DELETE\"}[$interval]))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('write')
+ prometheus.withDatasource('$Datasource')
]
},

requestRateDropped: {
query():
prometheus.withExpr('sum(rate(apiserver_dropped_requests_total{instance=~\"$instance\"}[$interval])) by (requestKind)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('')
+ prometheus.withDatasource('$Datasource')
},

requestRateTerminated: {
query():
prometheus.withExpr('sum(rate(apiserver_request_terminations_total{instance=~\"$instance\",resource=~\"$resource\",code=~\"$code\"}[$interval])) by(component)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('')
+ prometheus.withDatasource('$Datasource')
},

requestRateStatus: {
query():
prometheus.withExpr('sum(rate(apiserver_request_total{apiserver=~\"$apiserver\",instance=~\"$instance\",resource=~\"$resource\",verb=~\"$verb\",code=~\"$code\"}[$interval])) by(code)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{code}}')
+ prometheus.withDatasource('$Datasource')
},

requestsLongRunning: {
query():
prometheus.withExpr('sum(apiserver_longrunning_gauge{instance=~\"$instance\",resource=~\"$resource\",verb=~\"$verb\"}) by(instance)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{instance}}')
+ prometheus.withDatasource('$Datasource')
},

requestInFlight: {
query():
prometheus.withExpr('sum(apiserver_current_inflight_requests{instance=~\"$instance\"}) by (instance,requestKind)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{requestKind}}-{{instance}}')
+ prometheus.withDatasource('$Datasource')
},

requestRejectPandF: {
query():
prometheus.withExpr('sum(rate(apiserver_flowcontrol_rejected_requests_total{instance=~\"$instance\",flowSchema=~\"$flowSchema\",priorityLevel=~\"$priorityLevel\"}[$interval])) by (reason)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('')
+ prometheus.withDatasource('$Datasource')
},

responseSize99Quatile: {
query():
prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_response_sizes_bucket{instance=~\"$instance\",resource=~\"$resource\",verb=~\"$verb\"}[$interval])) by(instance,le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{instance}}')
+ prometheus.withDatasource('$Datasource')
},

requestQueueLengthPandF: {
query():
prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_flowcontrol_request_queue_length_after_enqueue_bucket{instance=~\"$instance\",flowSchema=~\"$flowSchema\",priorityLevel=~\"$priorityLevel\"}[$interval])) by(flowSchema, priorityLevel, le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{flowSchema}}:{{priorityLevel}}')
+ prometheus.withDatasource('$Datasource')
},

requestWaitDuration99QuatilePandF: {
query():
prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_flowcontrol_request_wait_duration_seconds_bucket{instance=~\"$instance\"}[5m])) by(flow_schema, priority_level, le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('')
+ prometheus.withDatasource('$Datasource')
},

requestDispatchRatePandF: {
query():
prometheus.withExpr('sum(rate(apiserver_flowcontrol_dispatched_requests_total{instance=~\"$instance\",flowSchema=~\"$flowSchema\",priorityLevel=~\"$priorityLevel\"}[$interval])) by(flowSchema,priorityLevel)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{flowSchema}}:{{priorityLevel}}')
+ prometheus.withDatasource('$Datasource')
},

requestExecutionDurationPandF: {
query():
prometheus.withExpr('histogram_quantile(0.99, sum(rate(apiserver_flowcontrol_request_execution_seconds_bucket{instance=~\"$instance\",flowSchema=~\"$flowSchema\",priorityLevel=~\"$priorityLevel\"}[$interval])) by(flowSchema, priorityLevel, le))')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{flowSchema}}:{{priorityLevel}}')
+ prometheus.withDatasource('$Datasource')
},

PendingInQueuePandF: {
query():
prometheus.withExpr('sum(apiserver_flowcontrol_current_inqueue_requests{instance=~\"$instance\",flowSchema=~\"$flowSchema\",priorityLevel=~\"$priorityLevel\"}) by (flowSchema,priorityLevel)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('{{flowSchema}}:{{priorityLevel}}')
+ prometheus.withDatasource('$Datasource')
},

ConcurrencyLimitByKubeapiserverPandF: {
query():
prometheus.withExpr('sum(apiserver_flowcontrol_request_concurrency_limit{instance=~\".*:6443\",priorityLevel=~\"$priorityLevel\"}) by (instance,priorityLevel)')
+ prometheus.withFormat('time_series')
+ prometheus.withIntervalFactor(2)
+ prometheus.withLegendFormat('')
+ prometheus.withDatasource('$Datasource')
}

}
75 changes: 75 additions & 0 deletions assets/api-performance-overview/variables.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
local var = g.dashboard.variable;

{
Datasource:
var.datasource.new('Datasource','prometheus')
+ var.datasource.withRegex("")
+ var.query.generalOptions.withLabel('Datasource')
+ var.query.withRefresh(1),
apiserver:
var.query.new('apiserver','label_values(apiserver_request_duration_seconds_bucket, apiserver)')
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)
+ var.query.generalOptions.withLabel('apisever')
+ var.query.withRefresh(2),

instance:
var.query.new('instance','label_values(apiserver_request_total, instance)')
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)
+ var.query.generalOptions.withLabel('instance')
+ var.query.withRefresh(2),

resource:
var.query.new('resource','label_values(apiserver_request_duration_seconds_bucket, resource)')
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)
+ var.query.generalOptions.withLabel('resource')
+ var.query.withRefresh(2),

code:
var.query.new('code','label_values(code)')
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)
+ var.query.generalOptions.withLabel('code')
+ var.query.withRefresh(2),

verb:
var.query.new('verb','label_values(verb)')
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)
+ var.query.generalOptions.withLabel('verb')
+ var.query.withRefresh(2),

flowSchema:
var.query.new('flowSchema','label_values(flowSchema)')
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)
+ var.query.generalOptions.withLabel('flow-schema')
+ var.query.withRefresh(2),

priorityLevel:
var.query.new('priorityLevel','label_values(priorityLevel)')
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)
+ var.query.generalOptions.withLabel('priority-level')
+ var.query.withRefresh(2),

interval:
var.interval.new('interval',['1m','5m'])
+ var.query.withDatasourceFromVariable(self.Datasource)
+ var.interval.generalOptions.withLabel('interval')
+ var.interval.withAutoOption(count=30, minInterval='10s')
+ var.query.withRefresh(2)
+ var.query.selectionOptions.withMulti(false)
+ var.query.selectionOptions.withIncludeAll(true)

}
Loading