Set up comprehensive monitoring for Cherokee web server with Prometheus metrics collection, custom Grafana dashboards for performance visualization, and automated alerting for critical performance thresholds.
Prerequisites
- Cherokee web server installed
- Root or sudo access
- Python 3 with pip
- At least 2GB RAM for monitoring stack
What this solves
Cherokee web server monitoring requires specialized metrics collection and visualization to track performance, identify bottlenecks, and prevent downtime. This tutorial establishes a complete monitoring stack with Prometheus for metrics collection, Grafana for dashboard visualization, and automated alerting for performance thresholds.
Step-by-step installation
Update system packages
Start by updating your package manager to ensure you get the latest versions of all components.
sudo apt update && sudo apt upgrade -y
Install Cherokee web server with status module
Install Cherokee with the admin interface and status monitoring module enabled for metrics collection.
sudo apt install -y cherokee cherokee-admin libcherokee-mod-admin libcherokee-mod-server-info
Configure Cherokee status endpoint
Enable the server-info module to expose performance metrics that Prometheus can scrape.
sudo cherokee-admin -b &
CHEROKEE_ADMIN_PID=$!
Access the Cherokee admin interface and configure the status endpoint:
# Navigate to http://localhost:9090
Go to vServers -> default -> Behavior
Add new rule: Directory /server-status
Set Handler to: Server Info
Apply and restart Cherokee
Install Prometheus
Download and install Prometheus for metrics collection and storage.
wget https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz
tar xzf prometheus-2.47.0.linux-amd64.tar.gz
sudo mv prometheus-2.47.0.linux-amd64 /opt/prometheus
sudo useradd --no-create-home --shell /bin/false prometheus
sudo chown -R prometheus:prometheus /opt/prometheus
Create Prometheus configuration
Configure Prometheus to scrape Cherokee metrics from the status endpoint.
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- "cherokee_alerts.yml"
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'cherokee'
static_configs:
- targets: ['localhost:80']
metrics_path: '/server-status'
params:
format: ['prometheus']
scrape_interval: 10s
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
Install Node Exporter for system metrics
Add Node Exporter to collect system-level metrics alongside Cherokee metrics.
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz
tar xzf node_exporter-1.6.1.linux-amd64.tar.gz
sudo mv node_exporter-1.6.1.linux-amd64/node_exporter /usr/local/bin/
sudo useradd --no-create-home --shell /bin/false node_exporter
Create Cherokee metrics exporter script
Create a custom exporter to parse Cherokee status output into Prometheus format.
#!/usr/bin/env python3
import requests
import re
import time
from prometheus_client import start_http_server, Gauge, Counter
Define Cherokee metrics
cherokee_connections = Gauge('cherokee_connections_total', 'Total connections')
cherokee_requests = Counter('cherokee_requests_total', 'Total requests served')
cherokee_bytes_sent = Counter('cherokee_bytes_sent_total', 'Total bytes sent')
cherokee_uptime = Gauge('cherokee_uptime_seconds', 'Server uptime in seconds')
cherokee_cpu_usage = Gauge('cherokee_cpu_usage_percent', 'CPU usage percentage')
cherokee_memory_usage = Gauge('cherokee_memory_usage_bytes', 'Memory usage in bytes')
def collect_cherokee_metrics():
try:
response = requests.get('http://localhost/server-status?format=text', timeout=5)
if response.status_code == 200:
content = response.text
# Parse metrics from Cherokee status output
connections_match = re.search(r'Total connections:\s*(\d+)', content)
if connections_match:
cherokee_connections.set(int(connections_match.group(1)))
requests_match = re.search(r'Total requests:\s*(\d+)', content)
if requests_match:
cherokee_requests._value._value = int(requests_match.group(1))
bytes_match = re.search(r'Total bytes sent:\s*(\d+)', content)
if bytes_match:
cherokee_bytes_sent._value._value = int(bytes_match.group(1))
uptime_match = re.search(r'Uptime:\s*(\d+)', content)
if uptime_match:
cherokee_uptime.set(int(uptime_match.group(1)))
except Exception as e:
print(f"Error collecting Cherokee metrics: {e}")
if __name__ == '__main__':
start_http_server(9101)
while True:
collect_cherokee_metrics()
time.sleep(10)
sudo chmod +x /opt/cherokee_exporter.py
sudo chown prometheus:prometheus /opt/cherokee_exporter.py
Create systemd services
Set up systemd services for Prometheus, Node Exporter, and Cherokee exporter.
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus/ \
--web.console.templates=/opt/prometheus/consoles \
--web.console.libraries=/opt/prometheus/console_libraries \
--web.listen-address=0.0.0.0:9090 \
--web.enable-lifecycle
[Install]
WantedBy=multi-user.target
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
[Unit]
Description=Cherokee Exporter
Wants=network-online.target
After=network-online.target cherokee.service
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/bin/python3 /opt/cherokee_exporter.py
Restart=always
[Install]
WantedBy=multi-user.target
Create Prometheus data directories
Set up the required directories with correct ownership for Prometheus data storage.
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
sudo mv /opt/prometheus/prometheus.yml /etc/prometheus/
Install Grafana
Install Grafana for dashboard visualization of Cherokee and system metrics.
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install -y grafana
Create Cherokee alerting rules
Define Prometheus alerting rules for Cherokee performance thresholds and error conditions.
groups:
- name: cherokee_alerts
rules:
- alert: CherokeeDown
expr: up{job="cherokee"} == 0
for: 30s
labels:
severity: critical
annotations:
summary: "Cherokee web server is down"
description: "Cherokee has been down for more than 30 seconds."
- alert: CherokeeHighConnections
expr: cherokee_connections_total > 1000
for: 2m
labels:
severity: warning
annotations:
summary: "Cherokee high connection count"
description: "Cherokee has {{ $value }} active connections."
- alert: CherokeeHighCPUUsage
expr: cherokee_cpu_usage_percent > 80
for: 5m
labels:
severity: warning
annotations:
summary: "Cherokee high CPU usage"
description: "Cherokee CPU usage is {{ $value }}% for more than 5 minutes."
- alert: CherokeeHighMemoryUsage
expr: cherokee_memory_usage_bytes > 1073741824
for: 5m
labels:
severity: warning
annotations:
summary: "Cherokee high memory usage"
description: "Cherokee memory usage is {{ $value | humanizeBytes }}."
- alert: CherokeeHighResponseTime
expr: increase(cherokee_requests_total[5m]) / increase(cherokee_uptime_seconds[5m]) < 10
for: 3m
labels:
severity: warning
annotations:
summary: "Cherokee low request rate"
description: "Cherokee request rate has dropped below 10 req/sec for 3 minutes."
Install and configure Alertmanager
Set up Alertmanager to handle alert notifications from Prometheus rules.
wget https://github.com/prometheus/alertmanager/releases/download/v0.26.0/alertmanager-0.26.0.linux-amd64.tar.gz
tar xzf alertmanager-0.26.0.linux-amd64.tar.gz
sudo mv alertmanager-0.26.0.linux-amd64 /opt/alertmanager
sudo useradd --no-create-home --shell /bin/false alertmanager
sudo chown -R alertmanager:alertmanager /opt/alertmanager
global:
smtp_smarthost: 'localhost:587'
smtp_from: 'alerts@example.com'
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'web.hook'
receivers:
- name: 'web.hook'
email_configs:
- to: 'admin@example.com'
subject: 'Cherokee Alert: {{ range .Alerts }}{{ .Annotations.summary }}{{ end }}'
body: |
{{ range .Alerts }}
Alert: {{ .Annotations.summary }}
Description: {{ .Annotations.description }}
{{ end }}
[Unit]
Description=Alertmanager
Wants=network-online.target
After=network-online.target
[Service]
User=alertmanager
Group=alertmanager
Type=simple
ExecStart=/opt/alertmanager/alertmanager \
--config.file=/etc/alertmanager/alertmanager.yml \
--storage.path=/var/lib/alertmanager/
[Install]
WantedBy=multi-user.target
Start and enable all services
Enable and start Cherokee, Prometheus, Node Exporter, Cherokee exporter, Grafana, and Alertmanager.
sudo mkdir -p /var/lib/alertmanager /etc/alertmanager
sudo chown alertmanager:alertmanager /var/lib/alertmanager /etc/alertmanager
sudo systemctl daemon-reload
sudo systemctl enable --now cherokee
sudo systemctl enable --now prometheus
sudo systemctl enable --now node_exporter
sudo systemctl enable --now cherokee_exporter
sudo systemctl enable --now grafana-server
sudo systemctl enable --now alertmanager
Configure Cherokee admin interface access
Set up Cherokee admin access and configure the server-status endpoint properly.
# Stop the background admin process
kill $CHEROKEE_ADMIN_PID
Configure Cherokee via command line
sudo cherokee-admin -b -C /etc/cherokee/cherokee.conf
Create Grafana Cherokee dashboard
Import a custom dashboard configuration for Cherokee monitoring in Grafana.
{
"dashboard": {
"id": null,
"title": "Cherokee Web Server Monitoring",
"tags": ["cherokee", "web-server"],
"timezone": "browser",
"panels": [
{
"id": 1,
"title": "Cherokee Status",
"type": "stat",
"targets": [
{
"expr": "up{job=\"cherokee\"}",
"legendFormat": "Cherokee Status"
}
],
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}
},
{
"id": 2,
"title": "Active Connections",
"type": "graph",
"targets": [
{
"expr": "cherokee_connections_total",
"legendFormat": "Connections"
}
],
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}
},
{
"id": 3,
"title": "Request Rate",
"type": "graph",
"targets": [
{
"expr": "rate(cherokee_requests_total[5m])",
"legendFormat": "Requests/sec"
}
],
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8}
},
{
"id": 4,
"title": "Bandwidth Usage",
"type": "graph",
"targets": [
{
"expr": "rate(cherokee_bytes_sent_total[5m])",
"legendFormat": "Bytes/sec"
}
],
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 8}
},
{
"id": 5,
"title": "System Resources",
"type": "graph",
"targets": [
{
"expr": "cherokee_cpu_usage_percent",
"legendFormat": "CPU %"
},
{
"expr": "cherokee_memory_usage_bytes / 1024 / 1024",
"legendFormat": "Memory MB"
}
],
"gridPos": {"h": 8, "w": 24, "x": 0, "y": 16}
}
],
"time": {
"from": "now-1h",
"to": "now"
},
"refresh": "5s"
}
}
Configure Grafana data source and dashboard
Add Prometheus data source to Grafana
Configure Grafana to use Prometheus as a data source for Cherokee metrics.
# Access Grafana at http://localhost:3000
Default login: admin/admin
Go to Configuration > Data Sources > Add data source
Select Prometheus
URL: http://localhost:9090
Click Save & Test
Import Cherokee dashboard
Import the custom Cherokee dashboard using the Grafana API or web interface.
curl -X POST \
http://admin:admin@localhost:3000/api/dashboards/db \
-H 'Content-Type: application/json' \
-d @/tmp/cherokee-dashboard.json
Verify your setup
Check that all components are running and collecting metrics properly.
# Check service status
sudo systemctl status cherokee prometheus node_exporter cherokee_exporter grafana-server alertmanager
Test Cherokee status endpoint
curl http://localhost/server-status
Test Prometheus metrics
curl http://localhost:9090/metrics
curl http://localhost:9101/metrics
Test Prometheus targets
curl http://localhost:9090/api/v1/targets
Access Grafana dashboard
curl -I http://localhost:3000
Test alerting rules
curl http://localhost:9090/api/v1/rules
You can also use the existing monitoring tutorials for additional insights. The Prometheus and Grafana monitoring stack tutorial provides complementary configuration options, while the Kubernetes monitoring with Prometheus guide offers advanced dashboard techniques.
Common issues
| Symptom | Cause | Fix |
|---|---|---|
| Cherokee exporter fails to start | Missing Python dependencies | sudo apt install -y python3-requests python3-prometheus-client |
| Prometheus cannot scrape Cherokee | Server-status endpoint not configured | Enable server-info module in Cherokee admin interface |
| Grafana dashboard shows no data | Incorrect data source configuration | Verify Prometheus URL is http://localhost:9090 |
| Alerts not firing | Alertmanager not connected | Check alertmanager service and Prometheus config |
| Permission denied on metrics files | Incorrect file ownership | sudo chown prometheus:prometheus /var/lib/prometheus -R |
| Cherokee status returns 404 | Virtual server misconfiguration | Add /server-status rule to default virtual server |
Next steps
- Configure Cherokee reverse proxy and load balancing for advanced Cherokee setups
- Integrate Nagios with Grafana dashboards for additional monitoring integration
- Configure Cherokee SSL and performance optimization for production deployments
- Set up Cherokee log analysis with ELK stack for comprehensive log monitoring
Automated install script
Run this to automate the entire setup
#!/usr/bin/env bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Default values
DOMAIN=${1:-"localhost"}
PROMETHEUS_VERSION="2.47.0"
NODE_EXPORTER_VERSION="1.6.1"
usage() {
echo "Usage: $0 [domain]"
echo "Example: $0 example.com"
exit 1
}
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
cleanup() {
log_error "Installation failed. Cleaning up..."
systemctl stop prometheus node_exporter cherokee-exporter || true
systemctl disable prometheus node_exporter cherokee-exporter || true
rm -rf /opt/prometheus /opt/node_exporter /opt/cherokee-exporter
userdel prometheus node_exporter cherokee-exporter 2>/dev/null || true
exit 1
}
trap cleanup ERR
# Check prerequisites
if [[ $EUID -ne 0 ]]; then
log_error "This script must be run as root"
exit 1
fi
# Auto-detect distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu|debian)
PKG_MGR="apt"
PKG_INSTALL="apt install -y"
PKG_UPDATE="apt update && apt upgrade -y"
PYTHON_PKG="python3 python3-pip"
FIREWALL_CMD="ufw"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_INSTALL="dnf install -y"
PKG_UPDATE="dnf update -y"
PYTHON_PKG="python3 python3-pip"
FIREWALL_CMD="firewall-cmd"
;;
amzn)
PKG_MGR="yum"
PKG_INSTALL="yum install -y"
PKG_UPDATE="yum update -y"
PYTHON_PKG="python3 python3-pip"
FIREWALL_CMD="firewall-cmd"
;;
*)
log_error "Unsupported distribution: $ID"
exit 1
;;
esac
else
log_error "Cannot detect distribution"
exit 1
fi
log_info "[1/12] Updating system packages..."
$PKG_UPDATE
log_info "[2/12] Installing Cherokee web server..."
if [[ "$PKG_MGR" == "apt" ]]; then
$PKG_INSTALL cherokee cherokee-admin libcherokee-mod-admin libcherokee-mod-server-info
else
$PKG_INSTALL cherokee cherokee-admin || {
log_warn "Cherokee not available in default repos, installing from EPEL..."
$PKG_INSTALL epel-release
$PKG_INSTALL cherokee cherokee-admin
}
fi
log_info "[3/12] Installing system dependencies..."
$PKG_INSTALL wget tar $PYTHON_PKG
log_info "[4/12] Installing Python dependencies..."
pip3 install prometheus_client requests
log_info "[5/12] Creating system users..."
useradd --no-create-home --shell /bin/false prometheus || true
useradd --no-create-home --shell /bin/false node_exporter || true
useradd --no-create-home --shell /bin/false cherokee-exporter || true
log_info "[6/12] Installing Prometheus..."
cd /tmp
wget -q "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz"
tar xzf "prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz"
mkdir -p /opt/prometheus /etc/prometheus /var/lib/prometheus
mv "prometheus-${PROMETHEUS_VERSION}.linux-amd64"/* /opt/prometheus/
chown -R prometheus:prometheus /opt/prometheus /etc/prometheus /var/lib/prometheus
chmod 755 /opt/prometheus /etc/prometheus /var/lib/prometheus
log_info "[7/12] Installing Node Exporter..."
wget -q "https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz"
tar xzf "node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz"
mkdir -p /opt/node_exporter
mv "node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter" /opt/node_exporter/
chown -R node_exporter:node_exporter /opt/node_exporter
chmod 755 /opt/node_exporter
log_info "[8/12] Creating Cherokee metrics exporter..."
mkdir -p /opt/cherokee-exporter
cat > /opt/cherokee-exporter/exporter.py << 'EOF'
#!/usr/bin/env python3
import requests
import re
import time
from prometheus_client import start_http_server, Gauge, Counter
cherokee_connections = Gauge('cherokee_connections_total', 'Total connections')
cherokee_requests = Counter('cherokee_requests_total', 'Total requests served')
cherokee_uptime = Gauge('cherokee_uptime_seconds', 'Server uptime in seconds')
def collect_cherokee_metrics():
try:
response = requests.get('http://localhost/server-status', timeout=5)
if response.status_code == 200:
content = response.text
connections_match = re.search(r'Total connections:\s*(\d+)', content)
if connections_match:
cherokee_connections.set(int(connections_match.group(1)))
requests_match = re.search(r'Total requests:\s*(\d+)', content)
if requests_match:
cherokee_requests._value._value = int(requests_match.group(1))
uptime_match = re.search(r'Uptime:\s*(\d+)', content)
if uptime_match:
cherokee_uptime.set(int(uptime_match.group(1)))
except Exception as e:
print(f"Error collecting metrics: {e}")
if __name__ == '__main__':
start_http_server(9101)
while True:
collect_cherokee_metrics()
time.sleep(15)
EOF
chown -R cherokee-exporter:cherokee-exporter /opt/cherokee-exporter
chmod 755 /opt/cherokee-exporter
chmod 644 /opt/cherokee-exporter/exporter.py
log_info "[9/12] Creating Prometheus configuration..."
cat > /etc/prometheus/prometheus.yml << EOF
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'cherokee'
static_configs:
- targets: ['localhost:9101']
scrape_interval: 10s
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
EOF
chown prometheus:prometheus /etc/prometheus/prometheus.yml
chmod 644 /etc/prometheus/prometheus.yml
log_info "[10/12] Creating systemd services..."
cat > /etc/systemd/system/prometheus.service << EOF
[Unit]
Description=Prometheus
After=network.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --web.console.templates=/opt/prometheus/consoles --web.console.libraries=/opt/prometheus/console_libraries
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/systemd/system/node_exporter.service << EOF
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/opt/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/systemd/system/cherokee-exporter.service << EOF
[Unit]
Description=Cherokee Exporter
After=network.target cherokee.service
[Service]
User=cherokee-exporter
Group=cherokee-exporter
Type=simple
ExecStart=/usr/bin/python3 /opt/cherokee-exporter/exporter.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
log_info "[11/12] Configuring firewall..."
if command -v ufw >/dev/null; then
ufw allow 9090/tcp
ufw allow 9100/tcp
ufw allow 9101/tcp
elif command -v firewall-cmd >/dev/null; then
firewall-cmd --permanent --add-port=9090/tcp
firewall-cmd --permanent --add-port=9100/tcp
firewall-cmd --permanent --add-port=9101/tcp
firewall-cmd --reload
fi
log_info "[12/12] Starting services..."
systemctl daemon-reload
systemctl enable --now cherokee prometheus node_exporter cherokee-exporter
sleep 5
# Verification
log_info "Verifying installation..."
if systemctl is-active --quiet prometheus; then
log_info "✓ Prometheus is running"
else
log_error "✗ Prometheus failed to start"
fi
if systemctl is-active --quiet node_exporter; then
log_info "✓ Node Exporter is running"
else
log_error "✗ Node Exporter failed to start"
fi
if systemctl is-active --quiet cherokee; then
log_info "✓ Cherokee is running"
else
log_error "✗ Cherokee failed to start"
fi
if systemctl is-active --quiet cherokee-exporter; then
log_info "✓ Cherokee Exporter is running"
else
log_error "✗ Cherokee Exporter failed to start"
fi
log_info "Installation completed successfully!"
log_info "Prometheus: http://localhost:9090"
log_info "Cherokee Admin: http://localhost:9090 (configure /server-status endpoint)"
log_info "Node Exporter: http://localhost:9100"
log_info "Cherokee Metrics: http://localhost:9101"
Review the script before running. Execute with: bash install.sh