Skip to content

Commit

Permalink
Merge branch 'master' into pgbench
Browse files Browse the repository at this point in the history
  • Loading branch information
smanda99 authored Feb 13, 2024
2 parents c84f140 + 45abdfd commit 439d3cc
Show file tree
Hide file tree
Showing 36 changed files with 3,268 additions and 11 deletions.
63 changes: 63 additions & 0 deletions assets/api-performance-overview/panels.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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('prometheus')
+ 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')
+ options.tooltip.withSort('desc')
+ timeSeries.queryOptions.withTimeFrom(null)
+ timeSeries.queryOptions.withTimeShift(null)
+ options.legend.withSortDesc(true),

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

legendBottomPlacement(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.legendRightPlacement(title, unit, targets, gridPos)
+ options.legend.withCalcs([
'mean',
'max',
'lastNotNull'
])
}
}
189 changes: 189 additions & 0 deletions assets/api-performance-overview/queries.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
local variables = import './variables.libsonnet';
local prometheus = g.query.prometheus;

{
request_duration_99th_quantile: {
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')
}
}
74 changes: 74 additions & 0 deletions assets/api-performance-overview/variables.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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

0 comments on commit 439d3cc

Please sign in to comment.