Files
FabledSteward/plugins/traefik/migrations/versions/traefik_006_status_codes.py
T
bvandeusenandClaude Opus 5.5 81995051dc
CI / lint (push) Failing after 2s
CI / integration (push) Successful in 1m19s
CI / unit (push) Successful in 1m30s
CI / publish (push) Skipped
feat(traefik): keep each router's 4xx and 5xx responses by status code (#5711)
The scraper folded traefik_service_requests_total{code} into two shares and
dropped the code, so a problem couldn't say whether it was scanners (404), a
login wall (401/403) or the app down (502/503/504). Each scrape now stores the
responses per router and code that occurred (traefik_status_codes, migration
traefik_006), pruned with the router metrics and left out of backups (System
180 ruling: Traefik history is not backed up). A problem card lists its codes
over the last 15 minutes, most first, or says none occurred, or that codes
aren't recorded yet.

A counter series new since the previous scrape now counts from 0 instead of
being skipped: Traefik creates a router's 502 series at its first 502, so a
first burst of 5xx read as 0% until it happened again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 11:07:19 -04:00

41 lines
1.7 KiB
Python

"""Each router's 4xx and 5xx responses by status code
The scraper folded traefik_service_requests_total{code} into a 4xx share and
a 5xx share and dropped the code, so a problem couldn't say whether it was
scanners probing (404), a login wall (401/403) or the app down (502/503/504)
(#5711). One row per router, scrape and code that occurred; the page reads a
router's codes over a time window, answered from the index alone.
Revision ID: traefik_006_status_codes
Revises: traefik_005_reload_at
Create Date: 2026-10-14
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = "traefik_006_status_codes"
down_revision: Union[str, None] = "traefik_005_reload_at"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"traefik_status_codes",
sa.Column("id", sa.String(36), primary_key=True),
sa.Column("router_name", sa.String(255), nullable=False),
sa.Column("scraped_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("code", sa.String(8), nullable=False),
sa.Column("count", sa.Integer, nullable=False),
)
op.create_index("ix_traefik_status_codes_router_scraped", "traefik_status_codes",
["router_name", "scraped_at"], postgresql_include=["code", "count"])
op.create_index("ix_traefik_status_codes_scraped", "traefik_status_codes", ["scraped_at"])
def downgrade() -> None:
op.drop_index("ix_traefik_status_codes_scraped", "traefik_status_codes")
op.drop_index("ix_traefik_status_codes_router_scraped", "traefik_status_codes")
op.drop_table("traefik_status_codes")