forked from mtusi2026/mtusi2026lab6
98 lines
3.1 KiB
YAML
98 lines
3.1 KiB
YAML
messenger_attachment_jobs:
|
|
query: |
|
|
WITH statuses(status) AS (
|
|
VALUES ('queued'), ('processing'), ('failed')
|
|
)
|
|
SELECT
|
|
statuses.status,
|
|
COUNT(j.id)::bigint AS count,
|
|
COALESCE(EXTRACT(EPOCH FROM (clock_timestamp() - MIN(j.created_at))), 0)::double precision AS oldest_age_seconds
|
|
FROM statuses
|
|
LEFT JOIN attachment_jobs j ON j.status = statuses.status
|
|
GROUP BY statuses.status
|
|
metrics:
|
|
- status:
|
|
usage: LABEL
|
|
description: Attachment job status.
|
|
- count:
|
|
usage: GAUGE
|
|
description: Attachment jobs in this status.
|
|
- oldest_age_seconds:
|
|
usage: GAUGE
|
|
description: Age of the oldest attachment job in this status.
|
|
|
|
messenger_outbox:
|
|
query: |
|
|
SELECT
|
|
COUNT(*) FILTER (WHERE published_at IS NULL)::bigint AS pending,
|
|
COALESCE(
|
|
EXTRACT(EPOCH FROM (clock_timestamp() - MIN(created_at) FILTER (WHERE published_at IS NULL))),
|
|
0
|
|
)::double precision AS oldest_pending_age_seconds
|
|
FROM outbox_events
|
|
metrics:
|
|
- pending:
|
|
usage: GAUGE
|
|
description: Unpublished outbox events.
|
|
- oldest_pending_age_seconds:
|
|
usage: GAUGE
|
|
description: Age of the oldest unpublished outbox event.
|
|
|
|
messenger_attachment_terminal_transitions:
|
|
query: |
|
|
WITH statuses(status) AS (
|
|
VALUES ('ready'), ('failed')
|
|
)
|
|
SELECT
|
|
statuses.status,
|
|
COUNT(events.job_id)::bigint AS total
|
|
FROM statuses
|
|
LEFT JOIN attachment_terminal_events events ON events.status = statuses.status
|
|
GROUP BY statuses.status
|
|
metrics:
|
|
- status:
|
|
usage: LABEL
|
|
description: First terminal status recorded for a durable attachment job.
|
|
- total:
|
|
usage: COUNTER
|
|
description: Durable attachment jobs whose first terminal outcome has this status.
|
|
|
|
messenger_attachment_time_to_ready_seconds:
|
|
query: |
|
|
WITH bounds(le, upper_bound) AS (
|
|
VALUES
|
|
('0.05', 0.05::double precision),
|
|
('0.1', 0.1::double precision),
|
|
('0.25', 0.25::double precision),
|
|
('0.5', 0.5::double precision),
|
|
('1', 1::double precision),
|
|
('2.5', 2.5::double precision),
|
|
('5', 5::double precision),
|
|
('10', 10::double precision),
|
|
('15', 15::double precision),
|
|
('20', 20::double precision),
|
|
('30', 30::double precision),
|
|
('60', 60::double precision),
|
|
('+Inf', NULL::double precision)
|
|
)
|
|
SELECT
|
|
bounds.le,
|
|
COUNT(events.job_id) FILTER (
|
|
WHERE events.status = 'ready'
|
|
AND (
|
|
bounds.upper_bound IS NULL
|
|
OR EXTRACT(EPOCH FROM (events.terminal_at - events.accepted_at)) <= bounds.upper_bound
|
|
)
|
|
)::bigint AS bucket
|
|
FROM bounds
|
|
LEFT JOIN attachment_terminal_events events ON events.status = 'ready'
|
|
GROUP BY bounds.le, bounds.upper_bound
|
|
ORDER BY bounds.upper_bound NULLS LAST
|
|
metrics:
|
|
- le:
|
|
usage: LABEL
|
|
description: Upper bound of the durable time-to-ready bucket in seconds.
|
|
- bucket:
|
|
usage: COUNTER
|
|
description: Durable attachment jobs reaching ready within the bucket bound.
|