Note: I've been very busy on the past couple of months with my personal life and work. Thanks for filing issues and feature requests. I'll start to go through them and provide updates very soon.
Exports squid metrics in Prometheus format
NOTE: From release 1.0 metric names and some parameters has changed. Make sure you check the docs and update your deployments accordingly!
- Using environment variables to configure the exporter
- Adding custom labels to metrics
- Enabling TLS for exporter via WebConfig
Simple usage:
squid-exporter -squid-hostname "localhost" -squid-port 3128
Configure Prometheus to scrape metrics from localhost:9301/metrics
- job_name: squid
# squid-exporter is installed, grab stats about the local
# squid instance.
target_groups:
- targets: ['localhost:9301']
To get all the parameteres, command line arguments always override default and environment variables configs:
squid-exporter -help
The following environment variables can be used to override default parameters:
SQUID_EXPORTER_LISTEN
SQUID_EXPORTER_WEB_CONFIG_PATH
SQUID_EXPORTER_METRICS_PATH
SQUID_HOSTNAME
SQUID_PORT
SQUID_LOGIN
SQUID_PASSWORD
SQUID_EXTRACTSERVICETIMES
Basic setup assuming Squid is running on the same machine:
docker run --net=host -d boynux/squid-exporter
Setup with Squid running on a different host
docker run -p 9301:9301 -d boynux/squid-exporter -squid-hostname "192.168.0.2" -squid-port 3128 -listen ":9301"
With environment variables
docker run -p 9301:9301 -d -e SQUID_PORT="3128" -e SQUID_HOSTNAME="192.168.0.2" -e SQUID_EXPORTER_LISTEN=":9301" boynux/squid-exporter
This project is written in Go, so all the usual methods for building (or cross compiling) a Go application would work.
If you are not very familiar with Go you can download the binary from releases.
Or build it for your OS:
go install https://github.com/boynux/squid-exporter
then you can find the binary in: $GOPATH/bin/squid-exporter
- Expose Squid counters
- Client HTTP
- Server HTTP
- Server ALL
- Server FTP
- Server Other
- ICP
- CD
- Swap
- Page Faults
- Others
- Expose Squid service times
- HTTP requests
- Cache misses
- Cache hits
- Near hits
- Not-Modified replies
- DNS lookups
- ICP queries
- Expose squid Info
- Squid service info (as label)
- Connection information for squid
- Cache information for squid
- Median Service Times (seconds) 5 min
- Resource usage for squid
- Memory accounted for
- File descriptor usage for squid
- Internal Data Structures
- Histograms
- Other metrics
- Squid Authentication (Basic Auth)
-
Q: Which versions of Squid are supported?
-
A: Squid version 3.2.0.10 and later.
-
Q: Why are no Squid metrics reported by the exporter?
-
A: This usually means that the exporter cannot reach the Squid server, or that the cachemgr ACLs are incorrect. To debug and mitigate:
-
First make sure that the host running the exporter can access the Squid cachemgr URL, e.g.:
curl http://localhost:3128/squid-internal-mgr/info
-
If that fails, verify that the Squid ACL configuration allows the exporter host to access the cachemgr. In the following example, a custom
prometheus
ACL is defined to allow cachemgr endpoint access from outside the Squid host, via the network (use with caution).
acl prometheus src 192.0.2.0/24 http_access allow localhost manager http_access allow prometheus manager http_access deny manager
-
-
Q: Why
process_open_fds
metric is not exported? -
A: This usualy means exporter don't have permission to read
/proc/<squid_proc_id>/fd
folder. You can either
- [recommended] Set
CAP_DAC_READ_SEARCH
capability for squid exporter process (or docker). (eg.sudo setcap 'cap_dac_read_search+ep' ./bin/squid-exporter
) - [not recommended] Run the exporter as root.
Pull request and issues are very welcome.