Change host:port to instance and replace apache up/down panel to state timeline

Due to possible relabelling rules instances may not contain port at all. Keeping it as single value instance makes it more universal.
This commit is contained in:
Vitaly Zhuravlev 2022-05-11 15:25:46 +04:00
parent 321e3f3df4
commit 6df0b6aafd

View file

@ -37,13 +37,12 @@ local graphPanel = grafana.graphPanel;
datasource: '${datasource}', datasource: '${datasource}',
hide: 0, hide: 0,
includeAll: false, includeAll: false,
label: 'host', label: 'instance',
multi: false, multi: false,
name: 'host', name: 'instance',
options: [], options: [],
query: 'label_values(apache_up, instance)', query: 'label_values(apache_up, instance)',
refresh: 2, refresh: 2,
regex: '/([^:]+):.*/',
sort: 1, sort: 1,
tagValuesQuery: '', tagValuesQuery: '',
tags: [], tags: [],
@ -51,26 +50,6 @@ local graphPanel = grafana.graphPanel;
type: 'query', type: 'query',
useTags: false, useTags: false,
}, },
{
allValue: null,
current: {},
datasource: '${datasource}',
hide: 2,
includeAll: false,
label: null,
multi: false,
name: 'port',
options: [],
query: 'label_values(apache_up, instance)',
refresh: 1,
regex: '/[^:]+:(.*)/',
sort: 0,
tagValuesQuery: '',
tags: [],
tagsQuery: '',
type: 'query',
useTags: false,
},
] ]
) )
.addPanels([ .addPanels([
@ -138,7 +117,7 @@ local graphPanel = grafana.graphPanel;
pluginVersion: '8.4.5', pluginVersion: '8.4.5',
targets: [ targets: [
{ {
expr: 'apache_uptime_seconds_total{instance=~"$host:$port"}', expr: 'apache_uptime_seconds_total{instance=~"$instance"}',
format: 'time_series', format: 'time_series',
intervalFactor: 1, intervalFactor: 1,
refId: 'A', refId: 'A',
@ -149,108 +128,92 @@ local graphPanel = grafana.graphPanel;
type: 'stat', type: 'stat',
}, },
{ {
aliasColors: {}, id: 5,
bars: false,
dashLength: 10,
dashes: false,
datasource: {
uid: '${datasource}',
},
decimals: 0,
fill: 7,
fillGradient: 0,
gridPos: { gridPos: {
h: 3, h: 3,
w: 20, w: 20,
x: 4, x: 4,
y: 0, y: 0,
}, },
hiddenSeries: false, type: 'state-timeline',
id: 5, title: 'Apache Up / Down',
legend: { datasource: {
alignAsTable: true, uid: '${datasource}',
avg: true, type: 'prometheus',
current: true,
max: true,
min: true,
rightSide: true,
show: true,
total: false,
values: true,
}, },
lines: true,
linewidth: 3,
links: [],
nullPointMode: 'null',
options: {
alertThreshold: true,
},
percentage: false,
pluginVersion: '8.4.5', pluginVersion: '8.4.5',
pointradius: 5, links: [],
points: false, options: {
renderer: 'flot', mergeValues: false,
seriesOverrides: [ showValue: 'never',
{ alignValue: 'left',
alias: 'Apache Down', rowHeight: 0.9,
color: '#BF1B00', legend: {
displayMode: 'list',
placement: 'right',
},
tooltip: {
mode: 'single',
sort: 'none',
}, },
{
alias: 'Apache Down',
transform: 'negative-Y',
}, },
],
spaceLength: 10,
stack: false,
steppedLine: false,
targets: [ targets: [
{ {
expr: 'count(apache_up{instance=~"$host:$port"} == 1)', expr: 'apache_up{instance=~"$instance"}',
legendFormat: 'Apache up',
interval: '',
exemplar: true,
format: 'time_series', format: 'time_series',
intervalFactor: 1, intervalFactor: 1,
legendFormat: 'Apache Up',
refId: 'A', refId: 'A',
step: 240, step: 240,
datasource: {
type: 'prometheus',
uid: 'grafanacloud-prom',
}, },
{
expr: 'scalar(count(apache_up{instance=~"$host:$port"} == 0))',
format: 'time_series',
intervalFactor: 1,
legendFormat: 'Apache Down',
refId: 'B',
step: 240,
}, },
], ],
thresholds: [], fieldConfig: {
timeRegions: [], defaults: {
title: 'Apache Up / Down', custom: {
tooltip: { lineWidth: 0,
shared: true, fillOpacity: 70,
sort: 0, spanNulls: false,
value_type: 'individual',
}, },
type: 'graph', color: {
xaxis: { mode: 'continuous-GrYlRd',
mode: 'time',
show: true,
values: [],
}, },
yaxes: [ mappings: [
{ {
format: 'short', type: 'value',
logBase: 1, options: {
max: '1', '0': {
show: true, text: 'Down',
color: 'red',
index: 1,
},
'1': {
text: 'Up',
color: 'green',
index: 0,
},
}, },
{
format: 'short',
logBase: 1,
show: false,
}, },
], ],
yaxis: { thresholds: {
align: false, mode: 'absolute',
steps: [
{
color: 'green',
value: null,
}, },
],
},
},
overrides: [],
},
timeFrom: null,
timeShift: null,
}, },
{ {
aliasColors: {}, aliasColors: {},
@ -299,7 +262,7 @@ local graphPanel = grafana.graphPanel;
steppedLine: false, steppedLine: false,
targets: [ targets: [
{ {
expr: 'rate(apache_sent_kilobytes_total{instance=~"$host:$port"}[5m])', expr: 'rate(apache_sent_kilobytes_total{instance=~"$instance"}[5m])',
format: 'time_series', format: 'time_series',
intervalFactor: 1, intervalFactor: 1,
legendFormat: 'Kilobytes Sent', legendFormat: 'Kilobytes Sent',
@ -384,7 +347,7 @@ local graphPanel = grafana.graphPanel;
steppedLine: false, steppedLine: false,
targets: [ targets: [
{ {
expr: 'rate(apache_accesses_total{instance=~"$host:$port"}[5m])', expr: 'rate(apache_accesses_total{instance=~"$instance"}[5m])',
format: 'time_series', format: 'time_series',
intervalFactor: 1, intervalFactor: 1,
legendFormat: 'Accesses', legendFormat: 'Accesses',
@ -470,7 +433,7 @@ local graphPanel = grafana.graphPanel;
steppedLine: false, steppedLine: false,
targets: [ targets: [
{ {
expr: 'apache_scoreboard{instance=~"$host:$port"}', expr: 'apache_scoreboard{instance=~"$instance"}',
format: 'time_series', format: 'time_series',
intervalFactor: 1, intervalFactor: 1,
legendFormat: '{{ state }}', legendFormat: '{{ state }}',
@ -555,7 +518,7 @@ local graphPanel = grafana.graphPanel;
steppedLine: false, steppedLine: false,
targets: [ targets: [
{ {
expr: 'apache_workers{instance=~"$host:$port"}\n', expr: 'apache_workers{instance=~"$instance"}\n',
format: 'time_series', format: 'time_series',
intervalFactor: 1, intervalFactor: 1,
legendFormat: '{{ state }}', legendFormat: '{{ state }}',
@ -640,7 +603,7 @@ local graphPanel = grafana.graphPanel;
steppedLine: false, steppedLine: false,
targets: [ targets: [
{ {
expr: 'apache_cpuload{instance=~"$host:$port"}', expr: 'apache_cpuload{instance=~"$instance"}',
format: 'time_series', format: 'time_series',
intervalFactor: 1, intervalFactor: 1,
legendFormat: 'Load', legendFormat: 'Load',