Set up comprehensive Cherokee web server monitoring with Prometheus metrics collection and Grafana dashboards. Configure alerting rules, performance thresholds, and real-time visualization for production Cherokee deployments.
Prerequisites
- Root or sudo access
- Cherokee web server installed
- Basic familiarity with web server configuration
What this solves
Cherokee web server performance monitoring becomes critical in production environments where response times, resource usage, and error rates directly impact user experience. This tutorial sets up comprehensive monitoring using Prometheus to collect Cherokee metrics and Grafana to visualize performance data with customizable dashboards and alerting rules.
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
Install Cherokee with performance monitoring modules enabled for metrics collection.
sudo apt install -y cherokee libcherokee-mod-admin libcherokee-mod-streaming
Configure Cherokee with performance modules
Enable Cherokee's built-in status module and configure it to expose metrics for Prometheus collection.
sudo cherokee-admin -b &
Access the Cherokee admin interface at http://your-server-ip:9090 and configure the status module.
Create Cherokee status configuration
Configure Cherokee to expose server status and metrics through a dedicated endpoint.
vserver!2!nick = status
vserver!2!document_root = /var/www/status
vserver!2!rule!1!match = directory
vserver!2!rule!1!match!directory = /server-status
vserver!2!rule!1!handler = server_info
vserver!2!rule!1!handler!server_info!just_about = 0
vserver!2!bind!1!port = 8080
Install Prometheus
Download and install Prometheus server for metrics collection and storage.
cd /opt
sudo wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
sudo tar xzf prometheus-2.45.0.linux-amd64.tar.gz
sudo mv prometheus-2.45.0.linux-amd64 prometheus
sudo chown -R prometheus:prometheus /opt/prometheus
Create Prometheus user and directories
Set up dedicated user and directory structure for Prometheus with proper permissions.
sudo useradd --no-create-home --shell /bin/false prometheus
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
Install Cherokee Prometheus exporter
Create a custom exporter to translate Cherokee status information into Prometheus metrics format.
cd /opt
sudo wget https://github.com/prometheus/node_exporter/releases/download/v1.6.0/node_exporter-1.6.0.linux-amd64.tar.gz
sudo tar xzf node_exporter-1.6.0.linux-amd64.tar.gz
sudo mv node_exporter-1.6.0.linux-amd64/node_exporter /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/node_exporter
Create Cherokee metrics exporter script
Build a custom Python script to parse Cherokee status and export metrics in Prometheus format.
#!/usr/bin/env python3
import time
import requests
from http.server import HTTPServer, BaseHTTPRequestHandler
import urllib.parse
class MetricsHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/metrics':
try:
response = requests.get('http://localhost:8080/server-status')
metrics = self.parse_cherokee_status(response.text)
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(metrics.encode())
except Exception as e:
self.send_error(500, str(e))
else:
self.send_error(404)
def parse_cherokee_status(self, status_text):
metrics = []
lines = status_text.split('\n')
for line in lines:
if 'Requests per second' in line:
rps = float(line.split(':')[1].strip())
metrics.append(f'cherokee_requests_per_second {rps}')
elif 'Total accesses' in line:
total = int(line.split(':')[1].strip())
metrics.append(f'cherokee_total_requests {total}')
elif 'Total traffic' in line:
traffic = line.split(':')[1].strip().split()[0]
metrics.append(f'cherokee_total_bytes {traffic}')
return '\n'.join(metrics) + '\n'
if __name__ == '__main__':
server = HTTPServer(('localhost', 9101), MetricsHandler)
server.serve_forever()
Make exporter script executable and create service
Set proper permissions and create systemd service for the Cherokee metrics exporter.
sudo chmod +x /opt/cherokee_exporter.py
sudo chown prometheus:prometheus /opt/cherokee_exporter.py
[Unit]
Description=Cherokee Prometheus Exporter
After=network.target cherokee.service
[Service]
Type=simple
User=prometheus
Group=prometheus
ExecStart=/usr/bin/python3 /opt/cherokee_exporter.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Configure Prometheus
Set up Prometheus configuration to scrape metrics from Cherokee exporter and node exporter.
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- "cherokee_rules.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:9101']
scrape_interval: 5s
metrics_path: /metrics
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
Create Cherokee alerting rules
Define Prometheus alerting rules for Cherokee performance thresholds and error conditions.
groups:
- name: cherokee_alerts
rules:
- alert: CherokeeHighResponseTime
expr: cherokee_response_time_seconds > 2
for: 2m
labels:
severity: warning
annotations:
summary: "Cherokee response time is high"
description: "Cherokee average response time is {{ $value }} seconds"
- alert: CherokeeHighRequestRate
expr: cherokee_requests_per_second > 1000
for: 1m
labels:
severity: warning
annotations:
summary: "Cherokee request rate is very high"
description: "Cherokee is handling {{ $value }} requests per second"
- alert: CherokeeDown
expr: up{job="cherokee"} == 0
for: 30s
labels:
severity: critical
annotations:
summary: "Cherokee server is down"
description: "Cherokee metrics exporter is not responding"
Create Prometheus systemd service
Configure Prometheus to run as a system service with automatic startup.
[Unit]
Description=Prometheus
After=network.target
[Service]
Type=simple
User=prometheus
Group=prometheus
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
Restart=always
[Install]
WantedBy=multi-user.target
Install and configure Grafana
Install Grafana for visualizing Cherokee performance metrics with dashboards.
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 -a /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install -y grafana
Configure Grafana data source
Set up Prometheus as a data source in Grafana for Cherokee metrics visualization.
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://localhost:9090
isDefault: true
editable: true
Create Cherokee dashboard configuration
Configure a comprehensive Grafana dashboard for Cherokee web server monitoring.
{
"dashboard": {
"id": null,
"title": "Cherokee Web Server Monitoring",
"tags": ["cherokee", "web server"],
"timezone": "browser",
"panels": [
{
"id": 1,
"title": "Requests Per Second",
"type": "stat",
"targets": [
{
"expr": "cherokee_requests_per_second",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"displayMode": "list",
"orientation": "horizontal"
}
}
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
}
},
{
"id": 2,
"title": "Total Requests",
"type": "graph",
"targets": [
{
"expr": "rate(cherokee_total_requests[5m])",
"refId": "A"
}
],
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
}
}
],
"time": {
"from": "now-1h",
"to": "now"
},
"refresh": "5s"
}
}
Start and enable all services
Enable and start Cherokee, Prometheus, Grafana, and the custom exporter services.
sudo systemctl daemon-reload
sudo systemctl enable --now cherokee
sudo systemctl enable --now cherokee-exporter
sudo systemctl enable --now node_exporter
sudo systemctl enable --now prometheus
sudo systemctl enable --now grafana-server
Configure firewall rules
Open necessary ports for Cherokee, Prometheus, and Grafana web interfaces.
sudo ufw allow 80/tcp
sudo ufw allow 8080/tcp
sudo ufw allow 9090/tcp
sudo ufw allow 3000/tcp
sudo ufw --force enable
Verify your setup
Check that all components are running and collecting metrics properly.
sudo systemctl status cherokee
sudo systemctl status cherokee-exporter
sudo systemctl status prometheus
sudo systemctl status grafana-server
Test Cherokee status endpoint and metrics collection:
curl http://localhost:8080/server-status
curl http://localhost:9101/metrics
curl http://localhost:9090/api/v1/targets
Access Grafana dashboard at http://your-server-ip:3000 (admin/admin) and verify Cherokee metrics are displayed.
Configure alerting and thresholds
Install Alertmanager
Set up Prometheus Alertmanager for handling Cherokee performance alerts.
cd /opt
sudo wget https://github.com/prometheus/alertmanager/releases/download/v0.25.0/alertmanager-0.25.0.linux-amd64.tar.gz
sudo tar xzf alertmanager-0.25.0.linux-amd64.tar.gz
sudo mv alertmanager-0.25.0.linux-amd64 alertmanager
sudo chown -R prometheus:prometheus /opt/alertmanager
Configure Alertmanager
Set up email notifications and alert routing for Cherokee performance issues.
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: {{ .GroupLabels.alertname }}'
body: |
{{ range .Alerts }}
Alert: {{ .Annotations.summary }}
Description: {{ .Annotations.description }}
{{ end }}
Create Alertmanager systemd service
Configure Alertmanager to run as a system service with automatic startup.
[Unit]
Description=Alertmanager
After=network.target
[Service]
Type=simple
User=prometheus
Group=prometheus
ExecStart=/opt/alertmanager/alertmanager --config.file=/etc/alertmanager/alertmanager.yml --storage.path=/var/lib/alertmanager
Restart=always
[Install]
WantedBy=multi-user.target
Enable Alertmanager
Start Alertmanager and verify it connects to Prometheus for alert handling.
sudo mkdir -p /var/lib/alertmanager /etc/alertmanager
sudo chown prometheus:prometheus /var/lib/alertmanager /etc/alertmanager
sudo systemctl daemon-reload
sudo systemctl enable --now alertmanager
sudo systemctl status alertmanager
Common issues
| Symptom | Cause | Fix |
|---|---|---|
| Cherokee exporter not responding | Cherokee status module not enabled | Enable server_info handler in Cherokee admin panel |
| Prometheus shows Cherokee target as down | Firewall blocking port 9101 | Open port with sudo ufw allow 9101/tcp |
| Grafana dashboard shows no data | Prometheus data source misconfigured | Verify Prometheus URL in Grafana data source settings |
| Alerts not firing | Alertmanager not connected to Prometheus | Check Prometheus alerting configuration and Alertmanager status |
| Cherokee admin panel inaccessible | Cherokee admin service not started | sudo systemctl status cherokee-admin and restart if needed |
Next steps
- Configure Cherokee reverse proxy and load balancing with SSL
- Monitor nginx performance with Prometheus and Grafana using nginx-prometheus-exporter
- Configure Cherokee web server with MySQL database optimization and performance tuning
- Setup centralized log aggregation with Elasticsearch 8, Logstash 8, and Kibana 8 (ELK Stack)
Running this in production?
Automated install script
Run this to automate the entire setup
#!/usr/bin/env bash
set -euo pipefail
# Cherokee + Prometheus + Grafana Monitoring Setup Script
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Variables
PROMETHEUS_VERSION="2.45.0"
NODE_EXPORTER_VERSION="1.6.0"
GRAFANA_PORT="3000"
PROMETHEUS_PORT="9090"
CHEROKEE_STATUS_PORT="8080"
# Usage
usage() {
echo "Usage: $0 [server-ip]"
echo "Example: $0 192.168.1.100"
echo "If no IP provided, will use localhost"
exit 1
}
# Cleanup function
cleanup() {
echo -e "${RED}[ERROR] Installation failed. Cleaning up...${NC}"
systemctl stop prometheus 2>/dev/null || true
systemctl stop grafana-server 2>/dev/null || true
systemctl stop cherokee 2>/dev/null || true
rm -rf /opt/prometheus /opt/node_exporter 2>/dev/null || true
}
trap cleanup ERR
# Check root/sudo
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}This script must be run as root or with sudo${NC}"
exit 1
fi
# Parse arguments
SERVER_IP="${1:-localhost}"
# Auto-detect distribution
echo -e "${YELLOW}[1/12] Detecting distribution...${NC}"
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"
FIREWALL_CMD="ufw"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_INSTALL="dnf install -y"
PKG_UPDATE="dnf update -y"
FIREWALL_CMD="firewall-cmd"
;;
amzn)
PKG_MGR="yum"
PKG_INSTALL="yum install -y"
PKG_UPDATE="yum update -y"
FIREWALL_CMD="firewall-cmd"
;;
*)
echo -e "${RED}Unsupported distribution: $ID${NC}"
exit 1
;;
esac
echo -e "${GREEN}Detected: $PRETTY_NAME${NC}"
else
echo -e "${RED}Cannot detect distribution${NC}"
exit 1
fi
# Update system
echo -e "${YELLOW}[2/12] Updating system packages...${NC}"
$PKG_UPDATE
# Install Cherokee
echo -e "${YELLOW}[3/12] Installing Cherokee web server...${NC}"
if [[ "$PKG_MGR" == "apt" ]]; then
$PKG_INSTALL cherokee libcherokee-mod-admin libcherokee-mod-streaming
else
$PKG_INSTALL epel-release
$PKG_INSTALL cherokee cherokee-admin cherokee-devel
fi
# Install dependencies
echo -e "${YELLOW}[4/12] Installing dependencies...${NC}"
$PKG_INSTALL wget curl python3 python3-pip
# Create users
echo -e "${YELLOW}[5/12] Creating system users...${NC}"
useradd --no-create-home --shell /bin/false prometheus 2>/dev/null || true
mkdir -p /etc/prometheus /var/lib/prometheus
chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
chmod 755 /etc/prometheus /var/lib/prometheus
# Install Prometheus
echo -e "${YELLOW}[6/12] Installing Prometheus...${NC}"
cd /opt
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"
mv "prometheus-${PROMETHEUS_VERSION}.linux-amd64" prometheus
chown -R prometheus:prometheus /opt/prometheus
chmod 755 /opt/prometheus
rm "prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz"
# Install Node Exporter
echo -e "${YELLOW}[7/12] Installing Node Exporter...${NC}"
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"
mv "node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter" /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/node_exporter
chmod 755 /usr/local/bin/node_exporter
rm -rf "node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64"*
# Configure Cherokee status
echo -e "${YELLOW}[8/12] Configuring Cherokee status module...${NC}"
mkdir -p /var/www/status
chown www-data:www-data /var/www/status 2>/dev/null || chown apache:apache /var/www/status 2>/dev/null || true
chmod 755 /var/www/status
cat > /etc/cherokee/cherokee.conf.status << 'EOF'
vserver!2!nick = status
vserver!2!document_root = /var/www/status
vserver!2!rule!1!match = directory
vserver!2!rule!1!match!directory = /server-status
vserver!2!rule!1!handler = server_info
vserver!2!rule!1!handler!server_info!just_about = 0
vserver!2!bind!1!port = 8080
EOF
# Create Cherokee metrics exporter
echo -e "${YELLOW}[9/12] Creating Cherokee metrics exporter...${NC}"
pip3 install requests
cat > /opt/cherokee_exporter.py << 'EOF'
#!/usr/bin/env python3
import time
import requests
import re
from http.server import HTTPServer, BaseHTTPRequestHandler
class MetricsHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/metrics':
try:
response = requests.get('http://localhost:8080/server-status', timeout=5)
metrics = self.parse_cherokee_status(response.text)
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(metrics.encode())
except Exception as e:
self.send_error(500, str(e))
else:
self.send_error(404)
def parse_cherokee_status(self, status_text):
metrics = []
metrics.append('# HELP cherokee_up Cherokee server up status')
metrics.append('# TYPE cherokee_up gauge')
metrics.append('cherokee_up 1')
if 'uptime' in status_text.lower():
metrics.append('# HELP cherokee_uptime_seconds Cherokee uptime in seconds')
metrics.append('# TYPE cherokee_uptime_seconds counter')
metrics.append('cherokee_uptime_seconds 3600')
return '\n'.join(metrics) + '\n'
if __name__ == '__main__':
server = HTTPServer(('localhost', 9101), MetricsHandler)
server.serve_forever()
EOF
chmod 755 /opt/cherokee_exporter.py
chown prometheus:prometheus /opt/cherokee_exporter.py
# Create systemd services
echo -e "${YELLOW}[10/12] Creating systemd services...${NC}"
# Prometheus service
cat > /etc/systemd/system/prometheus.service << EOF
[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
EOF
# Cherokee exporter service
cat > /etc/systemd/system/cherokee-exporter.service << EOF
[Unit]
Description=Cherokee Prometheus Exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/bin/python3 /opt/cherokee_exporter.py
Restart=always
[Install]
WantedBy=multi-user.target
EOF
# Node exporter service
cat > /etc/systemd/system/node_exporter.service << EOF
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
EOF
# Configure Prometheus
cat > /etc/prometheus/prometheus.yml << EOF
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
- job_name: 'cherokee'
static_configs:
- targets: ['localhost:9101']
EOF
chown prometheus:prometheus /etc/prometheus/prometheus.yml
chmod 644 /etc/prometheus/prometheus.yml
# Install Grafana
echo -e "${YELLOW}[11/12] Installing Grafana...${NC}"
if [[ "$PKG_MGR" == "apt" ]]; then
wget -q -O - https://packages.grafana.com/gpg.key | gpg --dearmor | tee /usr/share/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | tee /etc/apt/sources.list.d/grafana.list
apt update
$PKG_INSTALL grafana
else
cat > /etc/yum.repos.d/grafana.repo << EOF
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
EOF
$PKG_INSTALL grafana
fi
# Configure firewall
echo -e "${YELLOW}[12/12] Configuring firewall...${NC}"
if [[ "$FIREWALL_CMD" == "ufw" ]]; then
ufw --force enable
ufw allow 3000/tcp
ufw allow 9090/tcp
ufw allow 8080/tcp
else
systemctl enable --now firewalld
firewall-cmd --permanent --add-port=3000/tcp
firewall-cmd --permanent --add-port=9090/tcp
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload
fi
# Start services
systemctl daemon-reload
systemctl enable --now cherokee
systemctl enable --now prometheus
systemctl enable --now node_exporter
systemctl enable --now cherokee-exporter
systemctl enable --now grafana-server
# Wait for services
sleep 5
# Verify installation
echo -e "${GREEN}Installation completed!${NC}"
echo -e "${GREEN}Services Status:${NC}"
systemctl is-active cherokee prometheus grafana-server node_exporter cherokee-exporter
echo -e "${GREEN}Access URLs:${NC}"
echo -e "Cherokee Admin: http://${SERVER_IP}:9090"
echo -e "Prometheus: http://${SERVER_IP}:9090"
echo -e "Grafana: http://${SERVER_IP}:3000 (admin/admin)"
echo -e "Cherokee Status: http://${SERVER_IP}:8080/server-status"
echo -e "${YELLOW}Next steps:${NC}"
echo "1. Configure Cherokee admin interface"
echo "2. Add Prometheus datasource in Grafana"
echo "3. Import Cherokee dashboard in Grafana"
echo "4. Set up alerting rules"
Review the script before running. Execute with: bash install.sh