Skip to content

Commit d2dd46e

Browse files
committed
fix(monitoring): return array from /version endpoint for Grafana Infinity
Grafana Infinity datasource expects JSON array format for table queries. Changed response from single object to array with one object.
1 parent 0e1df0b commit d2dd46e

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

monitoring_flask_backend/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ 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+
return jsonify([{
5858
"version": APP_VERSION,
5959
"build_ts": APP_BUILD_TS
60-
})
60+
}])
6161

6262

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

monitoring_flask_backend/test_app.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,24 @@ 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]
3744

3845

3946
class TestReadVersionFile:

0 commit comments

Comments
 (0)