Prometheus & Grafana

Export server metrics in Prometheus format for monitoring with Grafana dashboards.

CeyMail exposes server metrics in Prometheus exposition format, letting you build custom Grafana dashboards for your mail infrastructure.

Business feature

Prometheus metrics export is available on the Business plan and above.

Setup

1. Generate a token

Go to Settings > Security > Prometheus Metrics and click Generate Token. Copy the token immediately — it is only shown once.

2. Configure Prometheus

Add CeyMail as a scrape target in your prometheus.yml:

yaml
scrape_configs:
  - job_name: ceymail
    scheme: https
    metrics_path: /api/stats/metrics
    scrape_interval: 30s
    static_configs:
      - targets: ['your-server.com']
    bearer_token: 'your-token-here'

Replace your-server.com with your dashboard hostname and your-token-here with the token you generated.

3. Connect Grafana

In Grafana, add your Prometheus instance as a data source, then build dashboards using the CeyMail metrics listed below.

Available metrics

System

MetricTypeDescription
ceymail_cpu_idle_jiffiescounterCPU idle time (use rate() to compute usage)
ceymail_cpu_total_jiffiescounterTotal CPU time (use rate() to compute usage)
ceymail_memory_used_bytesgaugeMemory currently in use
ceymail_memory_total_bytesgaugeTotal system memory
ceymail_disk_used_bytesgaugeDisk space used on root partition
ceymail_disk_total_bytesgaugeTotal disk space

Mail queue

MetricTypeDescription
ceymail_queue_activegaugeMessages being delivered
ceymail_queue_deferredgaugeMessages waiting to retry
ceymail_queue_bouncegaugePermanent delivery failures
ceymail_queue_holdgaugeManually held messages

Services

MetricTypeDescription
ceymail_service_up{name="..."}gauge1 if running, 0 if down

Monitored services include Postfix, Dovecot, OpenDKIM, MariaDB, SpamAssassin, Nginx/Apache, Unbound, Rsyslog, Fail2ban, and the CeyMail AI Filter (if enabled).

Counts

MetricTypeDescription
ceymail_domains_totalgaugeNumber of configured mail domains
ceymail_mailboxes_totalgaugeNumber of mailbox accounts
ceymail_aliases_totalgaugeNumber of email aliases

Grafana dashboard examples

CPU usage

To calculate real-time CPU usage percentage from the counter metrics:

100 - (rate(ceymail_cpu_idle_jiffies[5m]) / rate(ceymail_cpu_total_jiffies[5m]) * 100)

Memory usage percentage

ceymail_memory_used_bytes / ceymail_memory_total_bytes * 100

Disk usage percentage

ceymail_disk_used_bytes / ceymail_disk_total_bytes * 100

Service status panel

Use ceymail_service_up with a stat or table panel. Alert when any value drops to 0:

ceymail_service_up == 0

Mail queue depth

ceymail_queue_active + ceymail_queue_deferred + ceymail_queue_bounce + ceymail_queue_hold

Token management

  • One active token at a time — generating a new token revokes the previous one
  • Revoke anytime from Settings > Security > Prometheus Metrics
  • Last used timestamp shows when Prometheus last scraped successfully
  • Tokens are stored as SHA-256 hashes — the plaintext is never saved

Rate limits

The metrics endpoint allows 12 requests per minute per IP. Prometheus default scrape intervals (15-60 seconds) fit well within this limit.