Skip to content

Commit b727eb6

Browse files
committed
Merge branch 'claude/grafana-version-display-V60eA' into 'main'
fix(monitoring): correct Flask backend URL in version panel See merge request postgres-ai/postgres_ai!152
2 parents 8917644 + 6998eb3 commit b727eb6

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

config/grafana/dashboards/Self_Monitoring_Dashboard.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@
100100
"url_options": {
101101
"method": "GET"
102102
},
103-
"computed_columns": [
104-
{
105-
"selector": "concat('PostgresAI v', version, ' (built: ', build_ts, ')')",
106-
"text": "display"
107-
}
108-
]
103+
"computed_columns": []
109104
}
110105
],
111106
"title": "",

docker-compose.local.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ services:
33
monitoring_flask_backend:
44
build:
55
context: ./monitoring_flask_backend
6+
args:
7+
VERSION: local-dev
8+
BUILD_TS: "${BUILD_TS:-local}"
69
image: postgresai/monitoring_flask_backend:local
710

811

monitoring_flask_backend/app.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ def read_version_file(filepath, default='unknown'):
5353

5454
@app.route('/version', methods=['GET'])
5555
def version():
56-
"""Return application version and build timestamp"""
57-
return jsonify({
56+
"""Return application version and build timestamp as array for Grafana Infinity datasource"""
57+
display = f"PostgresAI v{APP_VERSION} (built: {APP_BUILD_TS})"
58+
return jsonify([{
5859
"version": APP_VERSION,
59-
"build_ts": APP_BUILD_TS
60-
})
60+
"build_ts": APP_BUILD_TS,
61+
"display": display
62+
}])
6163

6264

6365
@app.route('/health', methods=['GET'])

monitoring_flask_backend/test_app.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,31 @@ def test_version_endpoint_returns_json(self, client):
2323
assert response.status_code == 200
2424
assert response.content_type == 'application/json'
2525

26+
def test_version_endpoint_returns_array(self, client):
27+
"""Test that /version returns array for Grafana Infinity datasource."""
28+
response = client.get('/version')
29+
data = json.loads(response.data)
30+
assert isinstance(data, list)
31+
assert len(data) == 1
32+
2633
def test_version_endpoint_contains_version_field(self, client):
2734
"""Test that /version response contains version field."""
2835
response = client.get('/version')
2936
data = json.loads(response.data)
30-
assert 'version' in data
37+
assert 'version' in data[0]
3138

3239
def test_version_endpoint_contains_build_ts_field(self, client):
3340
"""Test that /version response contains build_ts field."""
3441
response = client.get('/version')
3542
data = json.loads(response.data)
36-
assert 'build_ts' in data
43+
assert 'build_ts' in data[0]
44+
45+
def test_version_endpoint_contains_display_field(self, client):
46+
"""Test that /version response contains pre-formatted display field."""
47+
response = client.get('/version')
48+
data = json.loads(response.data)
49+
assert 'display' in data[0]
50+
assert 'PostgresAI v' in data[0]['display']
3751

3852

3953
class TestReadVersionFile:

0 commit comments

Comments
 (0)