Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

Squid Forward Proxy File Descriptor Exhaustion Sentinel

Audits Squid forward proxy metrics to detect file descriptor leaks, socket exhaustion, and DNS latency spikes to prevent network egress stalls.

Categories
CoreInfrastructure

Audits Squid forward caching proxy clusters across corporate egress gateways to detect file descriptor exhaustion, socket allocation leaks, and upstream DNS resolution latency spikes.

How it works

  1. A schedule trigger executes the forward proxy audit workflow every 15 minutes.
  2. The Python task queries the Squid Prometheus exporter endpoint (squid-exporter:9301).
  3. The script extracts open file descriptor allocations, maximum socket limits, client HTTP request throughput, and P99 DNS lookup latency.
  4. An evaluation gate determines whether file descriptor utilization percentages or DNS resolution latencies breach operational tolerance bounds.
  5. When thresholds are breached, a high-priority Slack alert is dispatched to network operations and egress proxy SREs.
  6. When proxy socket pools operate smoothly within safe margins, nominal telemetry is logged.
  7. A structured JSON audit manifest is emitted for network infrastructure compliance logs and proxy SLA telemetry archives.

Architecture diagram

graph TD
    Trigger[Schedule Trigger: 15m] --> ScanMetrics[Python Script: Scrape Squid Exporter Metrics]
    ScanMetrics --> EvalBreach{FD Util >= Threshold OR DNS Latency > 250ms?}
    EvalBreach -- Yes --> SlackAlert[Slack: High-Urgency NetOps Alert]
    EvalBreach -- No --> LogNominal[Log: Nominal Squid Proxy State]
    SlackAlert --> EmitManifest[Debug Return: Squid Audit Manifest]
    LogNominal --> EmitManifest

Architecture components

  • Trigger: Automated schedule polling at 15-minute intervals.
  • Script Task: Scrapes Squid Prometheus exporter metrics using Docker container isolation.
  • Decision Gate: Evaluates whether file descriptor consumption percentage exceeds stability safety limits.
  • Notification Task: Dispatches structured Slack alerts with cluster identity and socket utilization metrics.
  • Audit Manifest: Emits JSON execution payloads containing proxy socket capacity and timestamps.

Key capabilities

  • Continuous surveillance of Squid caching forward proxy socket and file descriptor consumption.
  • Rapid detection of TCP socket leaks, unclosed client keep-alive connections, and DNS delays.
  • Early warning before Linux kernel file table saturation causes EMFILE connection resets.
  • Zero external dependency execution via isolated containerized Python runners.

What you get

  • Preemptive alerting on enterprise forward proxy capacity exhaustion before egress traffic halts.
  • Automated tracking of open file descriptors relative to system max_filedescriptors settings.
  • Real-time audit manifests capturing proxy capacity health for network reliability compliance.
  • Configurable tolerance thresholds adaptable to regional office forward proxies and core datacenter pools.

Who it's for

  • Network operations engineers maintaining corporate forward proxy and content filtering clusters.
  • Site Reliability Engineers (SREs) safeguarding outbound Internet access and API egress connectivity.
  • Linux systems administrators configuring kernel limits, PAM limits, and systemd service units.
  • Security engineers monitoring outbound web traffic compliance and TLS inspection gateways.

Why orchestrate this with Kestra

  • Deterministic Scheduling: Guarantees regular proxy health audits without fragile local crontab scripts.
  • Containerized Runners: Runs Python tasks inside isolated Docker containers without host library dependencies.
  • Condition Branching: Flowable If tasks route alerts and nominal logging cleanly without spaghetti code.
  • Enterprise Secret Safety: Securely injects Slack webhook credentials without plain-text exposure.

Use cases

  • Client Keepalive Leak: Detects misconfigured microservices holding open idle HTTP connections indefinitely.
  • Kernel FD Limit Mismatch: Alerts when Squid hits systemd LimitNOFILE before reaching configured cache limits.
  • Upstream DNS Stall: Identifies internal recursive DNS server slowdowns delaying outbound proxy request forwarding.
  • Web Scraping Storm: Surfaces sudden surges in concurrent client outbound connections exceeding pool capacity.

Inputs

Name Type Default Description
squid_metrics_url STRING http://squid-exporter.network.svc.cluster.local:9301 Base HTTP URL exposing Squid Prometheus metrics.
proxy_cluster_id STRING squid-egress-proxy-pool-01 Target Squid forward proxy cluster identifier under surveillance.
max_fd_utilization_percent INT 85 Maximum allowable file descriptor utilization percentage before alerting.
lookback_minutes INT 15 Lookback evaluation window in minutes for failure rates.
alert_on_fd_exhaustion BOOL true Toggle Slack alert dispatch upon detecting FD exhaustion.

Expected outputs

  • {{ outputs.scan_squid_proxy_metrics.vars.file_descriptors_used_count }}: Count of currently open file descriptors in Squid.
  • {{ outputs.scan_squid_proxy_metrics.vars.file_descriptors_max_count }}: Maximum configured file descriptor limit for the daemon.
  • {{ outputs.scan_squid_proxy_metrics.vars.file_descriptor_utilization_pct }}: Percentage of allocated file descriptors in use.
  • {{ outputs.scan_squid_proxy_metrics.vars.requests_total_count }}: Cumulative volume of client HTTP requests handled.
  • {{ outputs.scan_squid_proxy_metrics.vars.is_alerting }}: Boolean flag indicating whether utilization thresholds were breached.
  • {{ outputs.emit_audit_manifest.value }}: Structured JSON audit manifest emitted for compliance archives.

Prerequisites

  • Squid caching proxy daemon configured with squid-exporter exporting metrics on port 9301.
  • Exporter port reachable from the Kestra worker execution environment.
  • Docker daemon running on the Kestra host to execute containerized Python tasks.

Secrets

  • SLACK_WEBHOOK_URL: Incoming webhook URL for the target NetOps Slack alerting channel.

Quick start

  1. Ensure Squid configuration has max_filedescriptors configured and squid-exporter running.
  2. Configure the SLACK_WEBHOOK_URL secret in your Kestra namespace settings.
  3. Specify your proxy cluster name in proxy_cluster_id.
  4. Execute a manual test run via the Kestra UI to verify socket metric ingestion.
  5. Enable the periodic_squid_audit trigger to establish automated continuous surveillance.

Common pitfalls and troubleshooting

  • Systemd LimitNOFILE: Squid will not exceed the systemd service file descriptor limit regardless of squid.conf.
  • Squid Cachemgr Port: Ensure squid-exporter has network access to Squid's cachemgr port (default 3128).
  • TCP TIME_WAIT Sockets: Rapid connection closing can accumulate thousands of TIME_WAIT sockets in Linux kernel.
  • DNS Helper Processes: Insufficient dns_children processes cause DNS lookups to block the main Squid event loop.

How to extend

  • Automated Worker Scale-Out: Chain a cloud VM scaling flow to add proxy instances to the pool during socket surges.
  • DNS Cache Refresh: Trigger a helper script to restart or flush local Unbound/dnsmasq forwarders on latency spikes.
  • PagerDuty Escalation: Escalate to on-call network engineers if file descriptor utilization exceeds 95%.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.