feat: add connection statistics for workspace agents (#6469)

* fix: don't make session counts cumulative

This made for some weird tracking... we want the point-in-time
number of counts!

* Add databasefake query for getting agent stats

* Add deployment stats endpoint

* The query... works?!?

* Fix aggregation query

* Select from multiple tables instead

* Fix continuous stats

* Increase period of stat refreshes

* Add workspace counts to deployment stats

* fmt

* Add a slight bit of responsiveness

* Fix template version editor overflow

* Add refresh button

* Fix font family on button

* Fix latest stat being reported

* Revert agent conn stats

* Fix linting error

* Fix tests

* Fix gen

* Fix migrations

* Block on sending stat updates

* Add test fixtures

* Fix response structure

* make gen
This commit is contained in:
Kyle Carberry
2023-03-08 21:05:45 -06:00
committed by GitHub
parent 9d40d2ffdc
commit 5304b4e483
43 changed files with 1790 additions and 174 deletions

158
coderd/apidoc/docs.go generated
View File

@ -304,31 +304,6 @@ const docTemplate = `{
}
}
},
"/config/deployment": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"General"
],
"summary": "Get deployment config",
"operationId": "get-deployment-config",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.DeploymentConfig"
}
}
}
}
},
"/csp/reports": {
"post": {
"security": [
@ -384,6 +359,56 @@ const docTemplate = `{
}
}
},
"/deployment/config": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"General"
],
"summary": "Get deployment config",
"operationId": "get-deployment-config",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.DeploymentConfig"
}
}
}
}
},
"/deployment/stats": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"General"
],
"summary": "Get deployment stats",
"operationId": "get-deployment-stats",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.DeploymentStats"
}
}
}
}
},
"/entitlements": {
"get": {
"security": [
@ -6454,6 +6479,32 @@ const docTemplate = `{
}
}
},
"codersdk.DeploymentStats": {
"type": "object",
"properties": {
"aggregated_from": {
"description": "AggregatedFrom is the time in which stats are aggregated from.\nThis might be back in time a specific duration or interval.",
"type": "string",
"format": "date-time"
},
"collected_at": {
"description": "CollectedAt is the time in which stats are collected at.",
"type": "string",
"format": "date-time"
},
"next_update_at": {
"description": "NextUpdateAt is the time when the next batch of stats will\nbe updated.",
"type": "string",
"format": "date-time"
},
"session_count": {
"$ref": "#/definitions/codersdk.SessionCountDeploymentStats"
},
"workspaces": {
"$ref": "#/definitions/codersdk.WorkspaceDeploymentStats"
}
}
},
"codersdk.DeploymentValues": {
"type": "object",
"properties": {
@ -7614,6 +7665,23 @@ const docTemplate = `{
}
}
},
"codersdk.SessionCountDeploymentStats": {
"type": "object",
"properties": {
"jetbrains": {
"type": "integer"
},
"reconnecting_pty": {
"type": "integer"
},
"ssh": {
"type": "integer"
},
"vscode": {
"type": "integer"
}
}
},
"codersdk.SupportConfig": {
"type": "object",
"properties": {
@ -8751,6 +8819,46 @@ const docTemplate = `{
}
}
},
"codersdk.WorkspaceConnectionLatencyMS": {
"type": "object",
"properties": {
"p50": {
"type": "number"
},
"p95": {
"type": "number"
}
}
},
"codersdk.WorkspaceDeploymentStats": {
"type": "object",
"properties": {
"building": {
"type": "integer"
},
"connection_latency_ms": {
"$ref": "#/definitions/codersdk.WorkspaceConnectionLatencyMS"
},
"failed": {
"type": "integer"
},
"pending": {
"type": "integer"
},
"running": {
"type": "integer"
},
"rx_bytes": {
"type": "integer"
},
"stopped": {
"type": "integer"
},
"tx_bytes": {
"type": "integer"
}
}
},
"codersdk.WorkspaceQuota": {
"type": "object",
"properties": {