Skip to content

Latest commit

 

History

History
158 lines (116 loc) · 5.48 KB

monitoring.md

File metadata and controls

158 lines (116 loc) · 5.48 KB

Prometheus Monitoring

This chart includes comprehensive Prometheus monitoring capabilities through:

  • Integrated upstream squid-exporter for standard Squid metrics
  • A per-site exporter that parses Squid access logs (via STDOUT piping) to emit per-host request metrics

Both exporters are bundled into the single Squid container image.

The standard exporter connects to Squid's cache manager over localhost, which is the only source allowed by the chart's cache-manager access rules. The chart does not configure cachemgr_passwd, so exporter authentication is not needed. The unused squidExporter.squidLogin and squidExporter.squidPassword options have been removed from the chart. These keys are no longer accepted by the schema, including when their values are empty; remove them from any existing values files.

Metrics Overview

The monitoring system provides detailed metrics about Squid's operational status:

  • Liveness: Squid service information and connection status
  • Bandwidth Usage: Client HTTP and Server HTTP traffic metrics
  • Hit/Miss Rates: Cache performance metrics (general and detailed)
  • Storage Utilization: Cache information and memory usage
  • Service Times: Response times for different operations
  • Connection Information: Active connections and request details

Enabling Monitoring

Monitoring is enabled by default. To customize or disable it:

# In values.yaml or via --set flags
squidExporter:
  enabled: true  # Set to false to disable
  port: 9301
  metricsPath: "/metrics"
  extractServiceTimes: "true"  # Enables detailed service time metrics
  resources:
    requests:
      cpu: 10m
      memory: 16Mi
    limits:
      cpu: 100m
      memory: 64Mi

Per-site exporter (enabled by default):

# In values.yaml or via --set flags
perSiteExporter:
  enabled: true
  port: 9302
  metricsPath: "/metrics"

Prometheus Integration

Option 1: Prometheus Operator (Recommended)

If you're using Prometheus Operator, the chart automatically creates a ServiceMonitor:

prometheus:
  serviceMonitor:
    enabled: true
    interval: 30s
    scrapeTimeout: 10s
    namespace: ""  # Leave empty to use the same namespace as the app

When enabled, the ServiceMonitor exposes endpoints for both exporters: 9301 (standard, HTTP) and 9302 (per-site, HTTPS). The per-site endpoint is scraped with scheme: https by default, with TLS configured via prometheus.serviceMonitor.perSiteTLS (auto-derives the CA secret name as <namespace>-tls, e.g., squid-proxy-tls when deployed to the squid-proxy namespace).

Option 2: Manual Prometheus Configuration

ServiceMonitor CRD Included:

The chart includes the ServiceMonitor CRD in the crds/ directory, so it will be automatically installed by Helm when the chart is deployed.

If you don't want ServiceMonitor functionality, you can disable it:

helm install caching ./caching --set prometheus.serviceMonitor.enabled=false

For non-Prometheus Operator setups, disable ServiceMonitor and use manual Prometheus configuration:

scrape_configs:
  - job_name: 'squid-proxy'
    static_configs:
      - targets: ['squid.<NAMESPACE>.svc.<CLUSTER_DOMAIN>:9301']
    scrape_interval: 30s
    metrics_path: '/metrics'

Complete example: See docs/prometheus-config-example.yaml in this repository for a full Prometheus configuration file.

Available Metrics

Standard Squid Metrics (Port 9301)

  • squid_client_http_requests_total: Total client HTTP requests
  • squid_client_http_hits_total: Total client HTTP hits
  • squid_client_http_errors_total: Total client HTTP errors
  • squid_server_http_requests_total: Total server HTTP requests
  • squid_cache_memory_bytes: Cache memory usage
  • squid_cache_disk_bytes: Cache disk usage
  • squid_service_times_seconds: Service times for different operations
  • squid_up: Squid availability status

Per-site Metrics (Port 9302)

  • squid_site_requests_total{hostname="<hostname>"}: Total requests per origin host
  • squid_site_hits_total{hostname="<hostname>"}: Cache hits per host
  • squid_site_misses_total{hostname="<hostname>"}: Cache misses per host
  • squid_site_bytes_total{hostname="<hostname>"}: Bytes transferred per host
  • squid_site_hit_ratio{hostname="<hostname>"}: Hit ratio gauge per host
  • squid_site_response_time_seconds{hostname="<hostname>",le="..."}: Response time histogram per host

Accessing Metrics

Via Port Forward

# Forward the standard squid-exporter metrics port
kubectl port-forward -n squid-proxy svc/squid 9301:9301

# View standard metrics in your browser or with curl
curl http://localhost:9301/metrics

Per-site exporter metrics (note: port 9302 uses HTTPS):

# Forward the per-site exporter metrics port
kubectl port-forward -n squid-proxy svc/squid 9302:9302

# View per-site metrics (TLS, skip cert verification for local testing)
curl -k https://localhost:9302/metrics

Via Service

The metrics are exposed on the service:

# Standard squid-exporter metrics (from within the cluster)
# Replace <NAMESPACE> (default: "squid-proxy") and <CLUSTER_DOMAIN> (default: "cluster.local")
curl http://squid.<NAMESPACE>.svc.<CLUSTER_DOMAIN>:9301/metrics

# Per-site exporter metrics (from within the cluster — uses HTTPS)
curl -k https://squid.<NAMESPACE>.svc.<CLUSTER_DOMAIN>:9302/metrics

Troubleshooting Metrics

See the troubleshooting guide for common monitoring issues.