mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
Addresses https://github.com/coder/nexus/issues/195. Specifically, just the "tracking templates" requirement: > ## Tracking in templates > To enable resource alerts, a user must add the resource_monitoring block to a template's coder_agent resource. We'd like to track if customers have any resource monitoring enabled on a per-deployment basis. Even better, we could identify which templates are using resource monitoring.
79 lines
1.4 KiB
SQL
79 lines
1.4 KiB
SQL
-- name: FetchVolumesResourceMonitorsUpdatedAfter :many
|
|
SELECT
|
|
*
|
|
FROM
|
|
workspace_agent_volume_resource_monitors
|
|
WHERE
|
|
updated_at > $1;
|
|
|
|
-- name: FetchMemoryResourceMonitorsUpdatedAfter :many
|
|
SELECT
|
|
*
|
|
FROM
|
|
workspace_agent_memory_resource_monitors
|
|
WHERE
|
|
updated_at > $1;
|
|
|
|
-- name: FetchMemoryResourceMonitorsByAgentID :one
|
|
SELECT
|
|
*
|
|
FROM
|
|
workspace_agent_memory_resource_monitors
|
|
WHERE
|
|
agent_id = $1;
|
|
|
|
-- name: FetchVolumesResourceMonitorsByAgentID :many
|
|
SELECT
|
|
*
|
|
FROM
|
|
workspace_agent_volume_resource_monitors
|
|
WHERE
|
|
agent_id = $1;
|
|
|
|
-- name: InsertMemoryResourceMonitor :one
|
|
INSERT INTO
|
|
workspace_agent_memory_resource_monitors (
|
|
agent_id,
|
|
enabled,
|
|
state,
|
|
threshold,
|
|
created_at,
|
|
updated_at,
|
|
debounced_until
|
|
)
|
|
VALUES
|
|
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
|
|
|
|
-- name: InsertVolumeResourceMonitor :one
|
|
INSERT INTO
|
|
workspace_agent_volume_resource_monitors (
|
|
agent_id,
|
|
path,
|
|
enabled,
|
|
state,
|
|
threshold,
|
|
created_at,
|
|
updated_at,
|
|
debounced_until
|
|
)
|
|
VALUES
|
|
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *;
|
|
|
|
-- name: UpdateMemoryResourceMonitor :exec
|
|
UPDATE workspace_agent_memory_resource_monitors
|
|
SET
|
|
updated_at = $2,
|
|
state = $3,
|
|
debounced_until = $4
|
|
WHERE
|
|
agent_id = $1;
|
|
|
|
-- name: UpdateVolumeResourceMonitor :exec
|
|
UPDATE workspace_agent_volume_resource_monitors
|
|
SET
|
|
updated_at = $3,
|
|
state = $4,
|
|
debounced_until = $5
|
|
WHERE
|
|
agent_id = $1 AND path = $2;
|