Convert overview dashboard to grafonnet

In addition this updates Grafonnet to include bar gauges.

Change-Id: I538bd965d52f841b24c9607fc97d5ac748b9d68b
This commit is contained in:
Thomas Draebing 2020-09-14 15:22:58 +02:00
parent 7e3e4b76c5
commit f839c376af
17 changed files with 543 additions and 1314 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,115 @@
local grafana = import '../../../vendor/grafonnet/grafana.libsonnet';
local dashboard = grafana.dashboard;
local template = grafana.template;
local row = grafana.row;
local graphPanel = grafana.graphPanel;
local prometheus = grafana.prometheus;
local defaults = import '../../globals/defaults.libsonnet';
local gridPos = import '../../globals/grid_pos.libsonnet';
local publishVariables = import '../../globals/publish.libsonnet';
local variables = import '../globals/variables.libsonnet';
local availability_panel = import './panels/availability.libsonnet';
local availability_time_panel = import './panels/availability-time.libsonnet';
local cpu_usage_panel = import './panels/cpu-usage.libsonnet';
local events_panel = import './panels/events.libsonnet';
local git_panel = import './panels/git-fetch-clone.libsonnet';
local heap_usage_panel = import './panels/heap-usage.libsonnet';
local http_responses_panel = import './panels/http-responses.libsonnet';
local request_errors_panel = import './panels/request-errors.libsonnet';
local rest_latency_panel = import './panels/rest-latency.libsonnet';
local threads_panel = import './panels/threads.libsonnet';
local version_table_panel = import './panels/version-table.libsonnet';
dashboard.new(
'Gerrit - Overview',
tags=['gerrit'],
schemaVersion=defaults.dashboards.schemaVersion,
editable=defaults.dashboards.editable,
time_from=defaults.dashboards.timeFrom,
time_to=defaults.dashboards.timeTo,
refresh=defaults.dashboards.refresh,
graphTooltip='shared_tooltip',
)
.addTemplate(variables.instance)
.addTemplate(variables.replica)
.addPanel(
version_table_panel,
gridPos={
w: 24,
h: 3,
x: 0,
y: 0,
},
)
.addPanel(
cpu_usage_panel,
gridPos=gridPos.new(1,0,3,height=6),
)
.addPanel(
heap_usage_panel,
gridPos=gridPos.new(1,1,3,height=6),
)
.addPanel(
threads_panel,
gridPos=gridPos.new(1,2,3,height=6),
)
.addPanel(
rest_latency_panel,
gridPos=gridPos.new(2,0,3,height=6),
)
.addPanel(
request_errors_panel,
gridPos=gridPos.new(2,1,3,height=6),
)
.addPanel(
row.new(title=''),
gridPos={
w: 24,
h: 1,
x: 0,
y: 15,
},
)
.addPanel(
availability_time_panel,
gridPos={
w: 18,
h: 11,
x: 0,
y: 15,
},
)
.addPanel(
availability_panel,
gridPos={
w: 6,
h: 11,
x: 18,
y: 15,
},
)
.addPanel(
events_panel,
gridPos={
w: 18,
h: 11,
x: 0,
y: 30,
},
)
.addPanel(
git_panel,
gridPos={
w: 6,
h: 11,
x: 18,
y: 30,
},
)
.addPanel(
http_responses_panel,
gridPos=gridPos.new(4,0,1, height=22),
)
+ if std.extVar('publish') then publishVariables else {}

View file

@ -0,0 +1,19 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local lineGraph = import '../../../globals/line-graph.libsonnet';
local yAxis = import '../../../globals/yaxis.libsonnet';
lineGraph.new(
title='Gerrit Availability',
yAxis1=yAxis.new(label='Count'),
legend=false,
min=0,
max=1,
)
.addTarget(
prometheus.target(
'up{instance="$instance",replica="$replica"}',
legendFormat='{{instance}}',
)
)

View file

@ -0,0 +1,24 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local stat = grafana.singlestat;
stat.new(
title='Gerrit Availability [last 24h]',
datasource='Prometheus',
colorBackground=true,
colors=[
"red",
"orange",
"darkgreen",
],
format='percent',
thresholds='98, 99',
valueFontSize='150%',
valueName='current',
)
.addTarget(
prometheus.target(
'avg_over_time(up{instance="$instance",replica="$replica"}[1d])*100',
legendFormat='{{instance}}',
)
)

View file

@ -0,0 +1,30 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local gauge = grafana.gaugePanel;
gauge.new(
title='CPU Usage',
datasource='Prometheus',
)
.addTarget(
target=prometheus.target(
'(rate(proc_cpu_usage{instance="$instance",replica="$replica"}[2m])/proc_cpu_num_cores{instance="$instance",replica="$replica"})*100',
legendFormat=' ',
intervalFactor=1,
instant=true,
),
)
.addThresholds([
{
color: 'green',
value: null
},
{
color: 'orange',
value: 60
},
{
color: 'red',
value: 90
}
])

View file

@ -0,0 +1,37 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local barGraph = import '../../../globals/bar-graph.libsonnet';
local yAxis = import '../../../globals/yaxis.libsonnet';
local events = [
'assignee_changed',
'change_abandoned',
'change_merged',
'comment_added',
'patchset_created',
'change_abandoned',
'ref_replicated',
'ref_updated',
'reviewer_added',
'reviewer_deleted',
'topic_changed',
'vote_deleted',
'wip_state_changed',
];
barGraph.new(
title='Gerrit Events (last 5 min)',
yAxis1=yAxis.new(label='Count [5 min]'),
x_axis_mode='series',
x_axis_values='current',
legend=false,
)
.addTargets([
prometheus.target(
std.format('increase(events_%s_total{instance="$instance",replica="$replica"}[5m])', event),
legendFormat=std.strReplace(event, '_', ' '),
intervalFactor=1,
instant=true,
) for event in events
])

View file

@ -0,0 +1,26 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local barGraph = import '../../../globals/bar-graph.libsonnet';
local yAxis = import '../../../globals/yaxis.libsonnet';
local actions = [
'FETCH',
'CLONE'
];
barGraph.new(
title='Git Fetch/Clone upload-pack requests (last 5 min)',
yAxis1=yAxis.new(label='Count [5 min]'),
x_axis_mode='series',
x_axis_values='current',
legend=false,
)
.addTargets([
prometheus.target(
std.format('increase(git_upload_pack_request_count_%s_total{instance="$instance",replica="$replica"}[5m])', action),
legendFormat=action,
intervalFactor=1,
instant=true,
) for action in actions
])

View file

@ -0,0 +1,30 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local gauge = grafana.gaugePanel;
gauge.new(
title='Heap Memory Usage',
datasource='Prometheus',
)
.addTarget(
target=prometheus.target(
'(proc_jvm_memory_heap_used{instance="$instance",replica="$replica"}/proc_jvm_memory_heap_committed{instance="$instance",replica="$replica"})*100',
legendFormat=' ',
intervalFactor=1,
instant=true,
),
)
.addThresholds([
{
color: 'green',
value: null
},
{
color: 'orange',
value: 60
},
{
color: 'red',
value: 90
}
])

View file

@ -0,0 +1,92 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local barGraph = import '../../../globals/bar-graph.libsonnet';
local yAxis = import '../../../globals/yaxis.libsonnet';
local responses = {
success: [200, 201, 204, 301, 304],
err: [400, 401, 403, 404, 405, 409, 412, 422, 500, 501, 503],
};
barGraph.new(
title='HTTP response status',
yAxis1=yAxis.new(label='Count'),
stack=true,
)
.addTargets([
prometheus.target(
std.format('(increase(http_server_success_count_%d_total{instance="$instance",replica="$replica"}[2m]))/2', response),
legendFormat=std.format('%d', response),
intervalFactor=1,
) for response in responses.success
])
.addTargets([
prometheus.target(
std.format('(increase(http_server_error_count_%d_total{instance="$instance",replica="$replica"}[2m]))/2', response),
legendFormat=std.format('%d', response),
intervalFactor=1,
) for response in responses.err
])
.addSeriesOverride({
alias: '200',
color: '#37872D'
})
.addSeriesOverride({
alias: '201',
color: '#56A64B'
})
.addSeriesOverride({
alias: '204',
color: '#73BF69'
})
.addSeriesOverride({
alias: '301',
color: 'rgb(110, 210, 110)'
})
.addSeriesOverride({
alias: '304',
color: 'rgb(150, 225, 150)'
})
.addSeriesOverride({
alias: '400',
color: '#FA6400'
})
.addSeriesOverride({
alias: '401',
color: '#FF780A',
hiddenSeries: true
})
.addSeriesOverride({
alias: '403',
color: '#FF9830'
})
.addSeriesOverride({
alias: '404',
color: '#FFB357',
hiddenSeries: true
})
.addSeriesOverride({
alias: '409',
color: '#FFCB7D'
})
.addSeriesOverride({
alias: '412',
color: '#E0B400'
})
.addSeriesOverride({
alias: '422',
color: '#F2CC0C'
})
.addSeriesOverride({
alias: '500',
color: '#C4162A'
})
.addSeriesOverride({
alias: '501',
color: '#E02F44'
})
.addSeriesOverride({
alias: '503',
color: '#F2495C'
})

View file

@ -0,0 +1,33 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local gauge = grafana.gaugePanel;
gauge.new(
title='HTTP Request Error Rate (last 5 min)',
datasource='Prometheus',
description='Excludes 404 and 401, since these error codes are caused by client behaviour and are overrepresented in the data.',
min=0,
max=100,
)
.addTarget(
target=prometheus.target(
'(increase(http_server_error_count_total_total{instance="$instance",replica="$replica"}[5m]) - increase(http_server_error_count_404_total{instance=\"$instance\",replica=\"$replica\"}[5m]) - increase(http_server_error_count_401_total{instance=\"$instance\",replica=\"$replica\"}[5m])) / (increase(http_server_success_count_total_total{instance=\"$instance\",replica=\"$replica\"}[5m]) + increase(http_server_error_count_total_total{instance=\"$instance\",replica=\"$replica\"}[5m]) - increase(http_server_error_count_404_total{instance=\"$instance\",replica=\"$replica\"}[5m]) - increase(http_server_error_count_401_total{instance="$instance",replica="$replica"}[5m]))*100',
legendFormat=' ',
intervalFactor=1,
instant=true,
),
)
.addThresholds([
{
color: 'green',
value: null
},
{
color: 'orange',
value: 5
},
{
color: 'red',
value: 10
}
])

View file

@ -0,0 +1,29 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local gauge = grafana.gaugePanel;
gauge.new(
title='REST API latency (0.99 quantile)',
datasource='Prometheus',
unit='ms',
min=0,
max=50,
)
.addTarget(
target=prometheus.target(
'http_server_rest_api_server_latency_total{quantile="0.99", instance="$instance",replica="$replica"}',
legendFormat=' ',
intervalFactor=1,
instant=true,
),
)
.addThresholds([
{
color: 'green',
value: null
},
{
color: 'red',
value: 30
}
])

View file

@ -0,0 +1,36 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local gauge = grafana.barGaugePanel;
gauge.new(
title='Live Threads',
datasource='Prometheus',
thresholds=[{
color: 'green',
value: null,
}],
)
.addTarget(
target=prometheus.target(
'proc_jvm_thread_num_daemon_live{instance="$instance",replica="$replica"}',
legendFormat='current (daemon)',
intervalFactor=1,
instant=true,
),
)
.addTarget(
target=prometheus.target(
'proc_jvm_thread_num_live{instance="$instance",replica="$replica"}',
legendFormat='current (total)',
intervalFactor=1,
instant=true,
),
)
.addTarget(
target=prometheus.target(
'proc_jvm_thread_num_peak_live{instance="$instance",replica="$replica"}',
legendFormat='peak',
intervalFactor=1,
instant=true,
),
)

View file

@ -0,0 +1,59 @@
local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
local prometheus = grafana.prometheus;
local table = grafana.tablePanel;
table.new(
title='Gerrit Version',
datasource='Prometheus',
transform='table',
transparent=false,
)
.addTarget(
prometheus.target(
'max(gerrit_build_info{instance="$instance",replica="$replica"}) by (instance, version, revision, javaversion)',
instant=true,
format='table',
)
)
.addColumn(
field='instance',
style={
alias: 'Gerrit instance',
pattern: 'instance',
type: 'string',
link: true,
linkTargetBlank: true,
linkUrl: 'https://${__cell:raw}',
linkTooltip: 'Link to the Gerrit instance',
},
)
.addColumn(
field='version',
style={
alias: 'Gerrit version',
pattern: 'version',
type: 'string',
},
)
.addColumn(
field='revision',
style={
alias: 'Gerrit revision',
pattern: 'revision',
type: 'string',
link: true,
linkTargetBlank: true,
linkUrl: 'https://gerrit.googlesource.com/gerrit/+/${__cell:raw}',
linkTooltip: 'Browse Gerrit repository at revision',
},
)
.addColumn(
field='javaversion',
style={
alias: 'Java version',
pattern: 'javaversion',
type: 'string',
},
)
.hideColumn('Time')
.hideColumn('Value')

View file

@ -9,6 +9,9 @@ local yAxis = import './yaxis.libsonnet';
title,
yAxis1,
yAxis2=yAxis.new(),
x_axis_mode='time',
x_axis_values='total',
legend=true,
min=null,
max=null,
stack=false,
@ -20,11 +23,14 @@ local yAxis = import './yaxis.libsonnet';
labelY2=yAxis2.label,
formatY2=yAxis2.format,
logBase2Y=yAxis2.logBase,
x_axis_mode=x_axis_mode,
x_axis_values=x_axis_values,
min=min,
max=max,
stack=stack,
datasource=defaults.datasource,
fill=1,
legend_show=legend,
legend_alignAsTable=true,
legend_avg=true,
legend_current=true,

View file

@ -8,12 +8,13 @@ local DEFAULT_HEIGHT = 11;
row,
column,
total_columns=2,
height=DEFAULT_HEIGHT
):: {
local width = TOTAL_WIDTH / total_columns,
x: column * width,
y: row * DEFAULT_HEIGHT,
y: row * height,
w: width,
h: DEFAULT_HEIGHT,
h: height,
},
}

View file

@ -9,6 +9,7 @@ local yAxis = import './yaxis.libsonnet';
title,
yAxis1,
yAxis2=yAxis.new(),
legend=true,
min=null,
max=null,
stack=false,
@ -26,6 +27,7 @@ local yAxis = import './yaxis.libsonnet';
stack=stack,
datasource=defaults.datasource,
fill=fill,
legend_show=legend,
legend_alignAsTable=true,
legend_avg=true,
legend_current=true,

View file

@ -8,8 +8,8 @@
"subdir": "grafonnet"
}
},
"version": "3336c69715f8f7a4d637582504c9fabd9d9ca081",
"sum": "w6zS28Rjs9EzRN/WoLLIdi028BvumxDTyLefYVoql2k="
"version": "cc1626a1b4dee45c99b78ddd9714dfd5f5d7816e",
"sum": "nkgrtMYPCq/YB4r3mKyToepaLhicwWnxDdGIodPpzz0="
}
],
"legacyImports": false