core/observability-core/db/query.sql
Tiago Yamamoto a52bd4519d refactor: optimize Dockerfiles and documentation for core services
- Use Google Distroless images for all services (Go & Node.js).
- Standardize documentation with [PROJECT-NAME].md.
- Add .dockerignore and .gitignore to all projects.
- Remove docker-compose.yml in favor of docker run instructions.
- Fix Go version and dependency issues in observability, repo-integrations, and security-governance.
- Add Podman support (fully qualified image names).
- Update Dashboard to use Node.js static server for Distroless compatibility.
2025-12-30 13:22:34 -03:00

54 lines
1.2 KiB
SQL

-- name: CreateTarget :one
INSERT INTO targets (name, type, config)
VALUES ($1, $2, $3)
RETURNING *;
-- name: GetTarget :one
SELECT * FROM targets
WHERE id = $1;
-- name: CreateCheck :one
INSERT INTO checks (target_id, type, interval_seconds, timeout_seconds)
VALUES ($1, $2, $3, $4)
RETURNING *;
-- name: GetCheck :one
SELECT * FROM checks
WHERE id = $1;
-- name: ListChecks :many
SELECT * FROM checks
WHERE is_active = TRUE;
-- name: CreateMetric :one
INSERT INTO metrics (time, check_id, value, tags)
VALUES ($1, $2, $3, $4)
RETURNING *;
-- name: GetMetricsForCheck :many
SELECT * FROM metrics
WHERE check_id = $1 AND time >= $2 AND time <= $3
ORDER BY time DESC;
-- name: CreateAlertRule :one
INSERT INTO alert_rules (check_id, name, threshold, operator, for_duration, severity)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING *;
-- name: ListAlertRules :many
SELECT * FROM alert_rules;
-- name: CreateIncident :one
INSERT INTO incidents (alert_rule_id, status, start_time)
VALUES ($1, $2, $3)
RETURNING *;
-- name: GetIncident :one
SELECT * FROM incidents
WHERE id = $1;
-- name: UpdateIncidentStatus :one
UPDATE incidents
SET status = $2, updated_at = NOW()
WHERE id = $1
RETURNING *;