Skip to content

Commit 46460a9

Browse files
Fix MongoDB service state overview
Show the number of pods for each "group" (configsvr, mongos, shard-X) Issue: ZENKO-5098
1 parent dcb9280 commit 46460a9

File tree

2 files changed

+17
-33
lines changed

2 files changed

+17
-33
lines changed

monitoring/mongodb/dashboard.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@
111111
"maxDataPoints": 100,
112112
"targets": [
113113
{
114-
"expr": "sum(mongodb_up{namespace=\"${namespace}\", job=~\"${namespace}/${jobs}\"}) by (cluster_role)",
115-
"query": "sum(mongodb_up{namespace=\"${namespace}\", job=~\"${namespace}/${jobs}\"}) by (cluster_role)",
114+
"expr": "sum(label_replace(mongodb_up{namespace=\"${namespace}\", job=~\"${namespace}/${jobs}\"}, 'statefulset', '$1', 'pod', '${job}-(.*)-[0-9]+')) by (statefulset)",
115+
"query": "sum(label_replace(mongodb_up{namespace=\"${namespace}\", job=~\"${namespace}/${jobs}\"}, 'statefulset', '$1', 'pod', '${job}-(.*)-[0-9]+')) by (statefulset)",
116116
"target": "",
117117
"format": "time_series",
118118
"hide": false,
119119
"interval": "",
120120
"intervalFactor": 1,
121-
"legendFormat": "{{cluster_role}}",
121+
"legendFormat": "{{statefulset}}",
122122
"metric": "",
123123
"refId": "",
124124
"step": 10,
@@ -137,7 +137,7 @@
137137
"orientation": "horizontal",
138138
"reduceOptions": {
139139
"calcs": [
140-
"mean"
140+
"last"
141141
],
142142
"fields": "",
143143
"values": false
@@ -568,18 +568,10 @@
568568
{
569569
"op": "gt",
570570
"yaxis": "left",
571-
"color": "green",
571+
"color": "dark-purple",
572572
"line": true,
573573
"index": 0,
574574
"value": "null"
575-
},
576-
{
577-
"op": "gt",
578-
"yaxis": "left",
579-
"color": "red",
580-
"line": true,
581-
"index": 1,
582-
"value": 80.0
583575
}
584576
]
585577
},
@@ -744,18 +736,10 @@
744736
{
745737
"op": "gt",
746738
"yaxis": "left",
747-
"color": "green",
739+
"color": "dark-purple",
748740
"line": true,
749741
"index": 0,
750742
"value": "null"
751-
},
752-
{
753-
"op": "gt",
754-
"yaxis": "left",
755-
"color": "red",
756-
"line": true,
757-
"index": 1,
758-
"value": 80.0
759743
}
760744
]
761745
},
@@ -6365,6 +6349,6 @@
63656349
"hidden": false
63666350
},
63676351
"timezone": "browser",
6368-
"version": 24,
6352+
"version": 25,
63696353
"uid": null
63706354
}

monitoring/mongodb/dashboard.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
from grafanalib.core import (
22
ConstantInput,
33
DataSourceInput,
4-
GridPos,
5-
Heatmap,
6-
HeatmapColor,
7-
Repeat,
84
RowPanel,
95
Template,
106
Templating,
117
Threshold,
128
BarChart,
13-
YAxis,
149
)
1510
from grafanalib import core
1611
from grafanalib import formatunits as UNITS
1712
from scalgrafanalib import (
1813
layout,
1914
metrics,
2015
Dashboard,
21-
GaugePanel,
2216
PieChart,
2317
Stat,
2418
Target,
2519
TimeSeries,
26-
Tooltip,
2720
StateTimeline,
2821
)
2922

@@ -525,10 +518,15 @@ def mongodb_state_timeline(title, expr, description="", mappings=None, **kwargs)
525518
mongodb_services_state = mongodb_stat(
526519
"MongoDB services state",
527520
orientation="horizontal",
521+
reduceCalc="last",
528522
targets=[
529523
Target(
530-
expr="sum(" + Metrics.UP() + ") by (cluster_role)",
531-
legendFormat="{{cluster_role}}",
524+
expr=(
525+
"sum(label_replace("
526+
+ Metrics.UP()
527+
+ ", 'statefulset', '$1', 'pod', '${job}-(.*)-[0-9]+')) by (statefulset)"
528+
),
529+
legendFormat="{{statefulset}}",
532530
)
533531
],
534532
)
@@ -591,6 +589,7 @@ def mongodb_state_timeline(title, expr, description="", mappings=None, **kwargs)
591589
format=UNITS.BYTES,
592590
decimals=1,
593591
description="Average size of documents in the database",
592+
thresholds=[Threshold("dark-purple", 0, 0.0)],
594593
)
595594

596595
num_docs_per_shard = mongodb_stat(
@@ -614,6 +613,7 @@ def mongodb_state_timeline(title, expr, description="", mappings=None, **kwargs)
614613
legendFormat="{{collection}}",
615614
)
616615
],
616+
thresholds=[Threshold("dark-purple", 0, 0.0)],
617617
)
618618

619619
index_size = mongodb_stat(
@@ -1466,7 +1466,7 @@ def mongodb_state_timeline(title, expr, description="", mappings=None, **kwargs)
14661466
name="jobs",
14671467
label="MongoDB instance type",
14681468
query='label_values(mongodb_up{namespace="${namespace}", job=~"${namespace}/${job}.*"}, job)',
1469-
regex="/^${namespace}\/(.*)$/",
1469+
regex="/^${namespace}\\/(.*)$/",
14701470
includeAll=True,
14711471
multi=True,
14721472
refresh=1,

0 commit comments

Comments
 (0)