Skip to content

Commit 90bc31c

Browse files
committed
feat(monitoring): add version and build timestamp display to Grafana
- Add /version endpoint to Flask backend that reads VERSION and BUILD_TS files - Add version banner panel to Self-monitoring dashboard using Infinity datasource - Display format: "PostgresAI v<version> (built: <build_ts>)"
1 parent 7b4891f commit 90bc31c

2 files changed

Lines changed: 132 additions & 31 deletions

File tree

config/grafana/dashboards/Self_Monitoring_Dashboard.json

Lines changed: 109 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,84 @@
3434
"title": "Overview",
3535
"type": "row"
3636
},
37+
{
38+
"datasource": {
39+
"type": "yesoreyeram-infinity-datasource",
40+
"uid": "aerffb0z8rjlsc"
41+
},
42+
"fieldConfig": {
43+
"defaults": {
44+
"color": {
45+
"mode": "thresholds"
46+
},
47+
"mappings": [],
48+
"thresholds": {
49+
"mode": "absolute",
50+
"steps": [
51+
{
52+
"color": "blue"
53+
}
54+
]
55+
}
56+
},
57+
"overrides": []
58+
},
59+
"gridPos": {
60+
"h": 2,
61+
"w": 24,
62+
"x": 0,
63+
"y": 1
64+
},
65+
"id": 200,
66+
"options": {
67+
"colorMode": "background",
68+
"graphMode": "none",
69+
"justifyMode": "center",
70+
"orientation": "horizontal",
71+
"percentChangeColorMode": "standard",
72+
"reduceOptions": {
73+
"calcs": [
74+
"lastNotNull"
75+
],
76+
"fields": "/^display$/",
77+
"values": false
78+
},
79+
"showPercentChange": false,
80+
"textMode": "value",
81+
"wideLayout": true
82+
},
83+
"pluginVersion": "12.0.2",
84+
"targets": [
85+
{
86+
"columns": [],
87+
"datasource": {
88+
"type": "yesoreyeram-infinity-datasource",
89+
"uid": "aerffb0z8rjlsc"
90+
},
91+
"filters": [],
92+
"format": "table",
93+
"global_query_id": "",
94+
"parser": "backend",
95+
"refId": "A",
96+
"root_selector": "",
97+
"source": "url",
98+
"type": "json",
99+
"url": "http://monitoring-flask-backend:5000/version",
100+
"url_options": {
101+
"method": "GET"
102+
},
103+
"computed_columns": [
104+
{
105+
"selector": "concat('PostgresAI v', version, ' (built: ', build_ts, ')')",
106+
"text": "display"
107+
}
108+
]
109+
}
110+
],
111+
"title": "",
112+
"transparent": true,
113+
"type": "stat"
114+
},
37115
{
38116
"datasource": {
39117
"type": "prometheus",
@@ -65,7 +143,7 @@
65143
"h": 4,
66144
"w": 4,
67145
"x": 0,
68-
"y": 1
146+
"y": 3
69147
},
70148
"id": 1,
71149
"options": {
@@ -134,7 +212,7 @@
134212
"h": 4,
135213
"w": 4,
136214
"x": 4,
137-
"y": 1
215+
"y": 3
138216
},
139217
"id": 2,
140218
"options": {
@@ -203,7 +281,7 @@
203281
"h": 4,
204282
"w": 4,
205283
"x": 8,
206-
"y": 1
284+
"y": 3
207285
},
208286
"id": 3,
209287
"options": {
@@ -272,7 +350,7 @@
272350
"h": 4,
273351
"w": 4,
274352
"x": 12,
275-
"y": 1
353+
"y": 3
276354
},
277355
"id": 4,
278356
"options": {
@@ -337,7 +415,7 @@
337415
"h": 4,
338416
"w": 4,
339417
"x": 16,
340-
"y": 1
418+
"y": 3
341419
},
342420
"id": 5,
343421
"options": {
@@ -398,7 +476,7 @@
398476
"h": 4,
399477
"w": 4,
400478
"x": 20,
401-
"y": 1
479+
"y": 3
402480
},
403481
"id": 6,
404482
"options": {
@@ -438,7 +516,7 @@
438516
"h": 1,
439517
"w": 24,
440518
"x": 0,
441-
"y": 5
519+
"y": 7
442520
},
443521
"id": 104,
444522
"panels": [],
@@ -611,7 +689,7 @@
611689
"h": 8,
612690
"w": 12,
613691
"x": 0,
614-
"y": 6
692+
"y": 8
615693
},
616694
"id": 40,
617695
"options": {
@@ -819,7 +897,7 @@
819897
"h": 8,
820898
"w": 12,
821899
"x": 12,
822-
"y": 6
900+
"y": 8
823901
},
824902
"id": 41,
825903
"options": {
@@ -952,7 +1030,7 @@
9521030
"h": 8,
9531031
"w": 12,
9541032
"x": 0,
955-
"y": 14
1033+
"y": 16
9561034
},
9571035
"id": 42,
9581036
"options": {
@@ -1052,7 +1130,7 @@
10521130
"h": 8,
10531131
"w": 12,
10541132
"x": 12,
1055-
"y": 14
1133+
"y": 16
10561134
},
10571135
"id": 43,
10581136
"options": {
@@ -1089,7 +1167,7 @@
10891167
"h": 1,
10901168
"w": 24,
10911169
"x": 0,
1092-
"y": 22
1170+
"y": 24
10931171
},
10941172
"id": 105,
10951173
"panels": [],
@@ -1169,7 +1247,7 @@
11691247
"h": 8,
11701248
"w": 12,
11711249
"x": 0,
1172-
"y": 23
1250+
"y": 25
11731251
},
11741252
"id": 50,
11751253
"options": {
@@ -1285,7 +1363,7 @@
12851363
"h": 8,
12861364
"w": 12,
12871365
"x": 12,
1288-
"y": 23
1366+
"y": 25
12891367
},
12901368
"id": 51,
12911369
"options": {
@@ -1398,7 +1476,7 @@
13981476
"h": 8,
13991477
"w": 12,
14001478
"x": 0,
1401-
"y": 31
1479+
"y": 33
14021480
},
14031481
"id": 52,
14041482
"options": {
@@ -1492,7 +1570,7 @@
14921570
"h": 8,
14931571
"w": 12,
14941572
"x": 12,
1495-
"y": 31
1573+
"y": 33
14961574
},
14971575
"id": 53,
14981576
"options": {
@@ -1541,7 +1619,7 @@
15411619
"h": 1,
15421620
"w": 24,
15431621
"x": 0,
1544-
"y": 39
1622+
"y": 41
15451623
},
15461624
"id": 101,
15471625
"panels": [],
@@ -1608,7 +1686,7 @@
16081686
"h": 8,
16091687
"w": 12,
16101688
"x": 0,
1611-
"y": 40
1689+
"y": 42
16121690
},
16131691
"id": 10,
16141692
"options": {
@@ -1699,7 +1777,7 @@
16991777
"h": 8,
17001778
"w": 12,
17011779
"x": 12,
1702-
"y": 40
1780+
"y": 42
17031781
},
17041782
"id": 11,
17051783
"options": {
@@ -1803,7 +1881,7 @@
18031881
"h": 8,
18041882
"w": 12,
18051883
"x": 0,
1806-
"y": 48
1884+
"y": 50
18071885
},
18081886
"id": 12,
18091887
"options": {
@@ -1916,7 +1994,7 @@
19161994
"h": 8,
19171995
"w": 12,
19181996
"x": 12,
1919-
"y": 48
1997+
"y": 50
19201998
},
19211999
"id": 13,
19222000
"options": {
@@ -1962,7 +2040,7 @@
19622040
"h": 1,
19632041
"w": 24,
19642042
"x": 0,
1965-
"y": 56
2043+
"y": 58
19662044
},
19672045
"id": 102,
19682046
"panels": [],
@@ -2029,7 +2107,7 @@
20292107
"h": 8,
20302108
"w": 12,
20312109
"x": 0,
2032-
"y": 57
2110+
"y": 59
20332111
},
20342112
"id": 20,
20352113
"options": {
@@ -2120,7 +2198,7 @@
21202198
"h": 8,
21212199
"w": 12,
21222200
"x": 12,
2123-
"y": 57
2201+
"y": 59
21242202
},
21252203
"id": 21,
21262204
"options": {
@@ -2212,7 +2290,7 @@
22122290
"h": 8,
22132291
"w": 12,
22142292
"x": 0,
2215-
"y": 65
2293+
"y": 67
22162294
},
22172295
"id": 22,
22182296
"options": {
@@ -2312,7 +2390,7 @@
23122390
"h": 8,
23132391
"w": 12,
23142392
"x": 12,
2315-
"y": 65
2393+
"y": 67
23162394
},
23172395
"id": 23,
23182396
"options": {
@@ -2358,7 +2436,7 @@
23582436
"h": 1,
23592437
"w": 24,
23602438
"x": 0,
2361-
"y": 73
2439+
"y": 75
23622440
},
23632441
"id": 103,
23642442
"panels": [],
@@ -2425,7 +2503,7 @@
24252503
"h": 8,
24262504
"w": 12,
24272505
"x": 0,
2428-
"y": 74
2506+
"y": 76
24292507
},
24302508
"id": 30,
24312509
"options": {
@@ -2525,7 +2603,7 @@
25252603
"h": 8,
25262604
"w": 12,
25272605
"x": 12,
2528-
"y": 74
2606+
"y": 76
25292607
},
25302608
"id": 31,
25312609
"options": {
@@ -2625,7 +2703,7 @@
26252703
"h": 8,
26262704
"w": 12,
26272705
"x": 0,
2628-
"y": 82
2706+
"y": 84
26292707
},
26302708
"id": 32,
26312709
"options": {
@@ -2716,7 +2794,7 @@
27162794
"h": 8,
27172795
"w": 12,
27182796
"x": 12,
2719-
"y": 82
2797+
"y": 84
27202798
},
27212799
"id": 33,
27222800
"options": {

monitoring_flask_backend/app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ def get_prometheus_client():
3737
logger.error(f"Failed to connect to Prometheus: {e}")
3838
raise
3939

40+
def read_version_file(filepath, default='unknown'):
41+
"""Read version information from file"""
42+
try:
43+
with open(filepath, 'r') as f:
44+
return f.read().strip()
45+
except FileNotFoundError:
46+
return default
47+
48+
49+
# Read version info at startup
50+
APP_VERSION = read_version_file('/VERSION')
51+
APP_BUILD_TS = read_version_file('/BUILD_TS')
52+
53+
54+
@app.route('/version', methods=['GET'])
55+
def version():
56+
"""Return application version and build timestamp"""
57+
return jsonify({
58+
"version": APP_VERSION,
59+
"build_ts": APP_BUILD_TS
60+
})
61+
62+
4063
@app.route('/health', methods=['GET'])
4164
def health():
4265
"""Health check endpoint"""

0 commit comments

Comments
 (0)