Skip to content

Commit a8da319

Browse files
committed
fix(monitoring): pre-format display string in Flask instead of Infinity
Infinity datasource doesn't support concat() function in JSONata. Move string formatting to Flask backend and return pre-formatted 'display' field. Remove computed_columns from dashboard panel.
1 parent d2dd46e commit a8da319

3 files changed

Lines changed: 11 additions & 7 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": "",

monitoring_flask_backend/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ def read_version_file(filepath, default='unknown'):
5454
@app.route('/version', methods=['GET'])
5555
def version():
5656
"""Return application version and build timestamp as array for Grafana Infinity datasource"""
57+
display = f"PostgresAI v{APP_VERSION} (built: {APP_BUILD_TS})"
5758
return jsonify([{
5859
"version": APP_VERSION,
59-
"build_ts": APP_BUILD_TS
60+
"build_ts": APP_BUILD_TS,
61+
"display": display
6062
}])
6163

6264

monitoring_flask_backend/test_app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def test_version_endpoint_contains_build_ts_field(self, client):
4242
data = json.loads(response.data)
4343
assert 'build_ts' in data[0]
4444

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']
51+
4552

4653
class TestReadVersionFile:
4754
"""Tests for the read_version_file function."""

0 commit comments

Comments
 (0)