113 lines
3 KiB
Python
113 lines
3 KiB
Python
from prometheus_client import Counter, Gauge
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Gauges — current scrape state, updated after each outcode
|
|
# ---------------------------------------------------------------------------
|
|
|
|
scrape_state = Gauge(
|
|
"scrape_state",
|
|
"Current scrape state as a labeled gauge (1 = active)",
|
|
["state"],
|
|
)
|
|
|
|
scrape_outcodes_done = Gauge(
|
|
"scrape_outcodes_done",
|
|
"Outcodes processed in current channel",
|
|
)
|
|
|
|
scrape_outcodes_total = Gauge(
|
|
"scrape_outcodes_total",
|
|
"Total outcodes in current channel",
|
|
)
|
|
|
|
scrape_properties_total = Gauge(
|
|
"scrape_properties_total",
|
|
"Properties found so far",
|
|
["channel", "source"],
|
|
)
|
|
|
|
scrape_elapsed_seconds = Gauge(
|
|
"scrape_elapsed_seconds",
|
|
"Seconds since scrape started",
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Counters — Rightmove (monotonically increasing)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
http_requests_total = Counter(
|
|
"http_requests_total",
|
|
"HTTP requests made to Rightmove",
|
|
["status", "endpoint"],
|
|
)
|
|
|
|
http_errors_total = Counter(
|
|
"http_errors_total",
|
|
"Rightmove HTTP connection/timeout errors",
|
|
["type"],
|
|
)
|
|
|
|
ip_rotations_total = Counter(
|
|
"ip_rotations_total",
|
|
"VPN IP rotation attempts",
|
|
["result"],
|
|
)
|
|
|
|
scrape_errors_total = Counter(
|
|
"scrape_errors_total",
|
|
"Per-outcode scrape errors",
|
|
["source"],
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Counters — home.co.uk
|
|
# ---------------------------------------------------------------------------
|
|
|
|
homecouk_requests_total = Counter(
|
|
"homecouk_requests_total",
|
|
"HTTP requests made to home.co.uk API",
|
|
["status"],
|
|
)
|
|
|
|
homecouk_errors_total = Counter(
|
|
"homecouk_errors_total",
|
|
"home.co.uk HTTP connection/timeout errors",
|
|
["type"],
|
|
)
|
|
|
|
homecouk_properties_scraped = Counter(
|
|
"homecouk_properties_scraped",
|
|
"Properties scraped from home.co.uk (before dedup)",
|
|
["channel"],
|
|
)
|
|
|
|
cross_source_dedup_total = Counter(
|
|
"cross_source_dedup_total",
|
|
"home.co.uk properties skipped because same property already found on Rightmove",
|
|
["channel"],
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Counters — FlareSolverr / cookie management
|
|
# ---------------------------------------------------------------------------
|
|
|
|
flaresolverr_attempts_total = Counter(
|
|
"flaresolverr_attempts_total",
|
|
"FlareSolverr Cloudflare challenge-solving attempts",
|
|
["result"],
|
|
)
|
|
|
|
cookie_refreshes_total = Counter(
|
|
"cookie_refreshes_total",
|
|
"home.co.uk cookie refresh attempts (triggered by 403)",
|
|
["result"],
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Gauges — home.co.uk state
|
|
# ---------------------------------------------------------------------------
|
|
|
|
homecouk_enabled = Gauge(
|
|
"homecouk_enabled",
|
|
"Whether home.co.uk scraping is currently active (1=yes, 0=no)",
|
|
)
|