Skip to content

Commit 24ff43e

Browse files
committed
analytics: Add /analytics endpoint
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent ea6272f commit 24ff43e

5 files changed

Lines changed: 778 additions & 2 deletions

File tree

api/main.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,6 @@ async def get_telemetry_stats(request: Request):
11241124
})
11251125
pipeline.append({'$sort': {'total': -1}})
11261126

1127-
results = await db.aggregate(TelemetryEvent, pipeline)
1128-
11291127
results = await db.aggregate(TelemetryEvent, pipeline)
11301128
return JSONResponse(content=jsonable_encoder([
11311129
{
@@ -1842,6 +1840,22 @@ async def manage():
18421840
return PlainTextResponse(file.read(), headers=hdr)
18431841

18441842

1843+
@app.get('/analytics')
1844+
async def analytics_page():
1845+
"""Serve pipeline analytics dashboard with telemetry data"""
1846+
metrics.add('http_requests_total', 1)
1847+
root_dir = os.path.dirname(os.path.abspath(__file__))
1848+
analytics_path = os.path.join(root_dir, 'templates', 'analytics.html')
1849+
with open(analytics_path, 'r', encoding='utf-8') as file:
1850+
hdr = {
1851+
'Content-Type': 'text/html',
1852+
'Cache-Control': 'no-cache, no-store, must-revalidate',
1853+
'Pragma': 'no-cache',
1854+
'Expires': '0'
1855+
}
1856+
return PlainTextResponse(file.read(), headers=hdr)
1857+
1858+
18451859
@app.get('/stats')
18461860
async def stats_page():
18471861
"""Serve simple HTML page to view infrastructure statistics"""

api/static/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
#
3+
# Copyright (C) 2026 Collabora Limited
4+
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
5+
6+
"""Static files package for KernelCI API viewer"""

api/static/css/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
#
3+
# Copyright (C) 2026 Collabora Limited
4+
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
5+
6+
"""CSS files for KernelCI API viewer"""

api/static/js/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
#
3+
# Copyright (C) 2026 Collabora Limited
4+
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
5+
6+
"""JavaScript files for KernelCI API viewer"""

0 commit comments

Comments
 (0)