Closed
Description
This issue tracks the backend implementation of the API to support insights for Coder admins
The API will include two endpoints, as described in: #8109 (reply in thread)
For progress on tracking template app usage (e.g. code-server
), see: #8658
GET /api/v2/insights/templates?start_time=01-07-2023&end_time=08-07-2023&interval=day&templates=name1,name2
{
"report": {
"start_time": "2023-07-01T00:00:00.000000Z",
"end_time": "2023-07-08T00:00:00.000000Z",
"template_ids": ["uuid1", "uuid2"],
"active_users": 22,
"usage_apps": [
{
"template_ids": ["uuid1", "uuid2"],
"type": "builtin",
"display_name": "Visual Studio Code",
"slug": "vscode",
"icon": "/icon/vscode.svg",
"seconds": 54000,
},
{
"template_ids": ["uuid1", "uuid2"],
"type": "builtin",
"display_name": "JetBrains",
"slug": "jetbrains",
"icon": "/icon/jetbrains.svg",
"seconds": 900,
},
{
"template_ids": ["uuid1", "uuid2"],
"type": "builtin",
"display_name": "Web Terminal",
"slug": "web-terminal",
"icon": "/icon/terminal.svg",
"seconds": 5400,
},
{
"template_ids": ["uuid1", "uuid2"],
"type": "builtin",
"display_name": "SSH",
"slug": "ssh",
"icon": "/icon/ssh.svg",
"seconds": 10800,
},
{
"template_ids": ["uuid1", "uuid2"],
"type": "app",
"display_name": "code-server",
"slug": "code-server",
"icon": "/icon/code.svg",
"seconds": 10800,
}
],
"usage_parameters": [
{
"template_ids": ["uuid1", "uuid2"],
"display_name": "Coder Repository Directory",
"name": "coder_repository_directory",
"values": [
{
"value": "~/coder",
"icon": "",
"count": 10
},
{
"value": "~/coder.com",
"icon": "",
"count": 2
}
]
},
{
"template_ids": ["uuid2"],
"display_name": "Dotfiles URL",
"name": "dotfiles_url",
"values": [
{
"value": "~/usr/.file",
"icon": "",
"count": 10
},
{
"value": null,
"icon": "",
"count": 2
}
]
},
{
"template_ids": ["uuid1"],
"display_name": "Region",
"name": "region",
"values": [
{
"value": "Pittsburgh",
"icon": "/icon/flag1.svg",
"count": 8
},
{
"value": "Helsinki",
"icon": "/icon/flag1.svg",
"count": 2
},
{
"value": "Sydney",
"icon": "/icon/flag3.svg",
"count": 1
},
{
"value": "Sao Paulo",
"icon": "/icon/flag4.svg",
"count": 1
}
]
}
]
},
"interval_reports": [
{
"start_time": "2023-07-01T00:00:00.000000Z",
"end_time": "2023-07-02T00:00:00.000000Z",
"template_ids": ["uuid1", "uuid2"],
"interval": "day",
"active_users": 19
},
{
"start_time": "2023-07-02T00:00:00.000000Z",
"end_time": "2023-07-03T00:00:00.000000Z",
...
},
{ ... },
{ ... },
{ ... },
{ ... },
{ ... }
]
}
GET /api/v2/insights/user-latency?start_time=01-07-2023&end_time=08-07-2023&templates=name1,name2&order_by=P50&order=asc
{
"report": {
"start_time": "2023-07-01T00:00:00.000000Z",
"end_time": "2023-07-08T00:00:00.000000Z",
"template_ids": ["uuid1", "uuid2"],
"latency": [
{
"template_ids": ["uuid1"],
"user_id": "fcb9f5c7-ad6d-4515-b12e-496bc04ca116",
"name": "John Doe",
"connection_latency_ms": {
"P50": 5.601,
"P95": 16.352049999999984
}
},
{
"template_ids": ["uuid2"],
"user_id": "aee4bef9-479f-488e-abb4-b2bce2bf9e0d",
"name": "Jane Doe",
"connection_latency_ms": {
"P50": 31.312,
"P95": 119.832
}
}
],
}
}