Slurm History Ingestor
Install, configure and run slurm-history-ingestor for job metrics
Slurm History Ingestor
Overview
The Slurm History Ingestor is a standalone Go service that syncs job history from Slurm HPC clusters into PostgreSQL for analytics and reporting. The dashboard's job metrics read what it writes.
Key Features:
- Incremental Syncing – Saves a per-cluster sync cursor (
ingest_sync_state) and only fetches new data, even on quiet clusters - Robust Data Handling – Uses a lookback window to catch out-of-order jobs
- Data Normalization – Converts TRES strings to query-friendly columns
- Multi-Cluster Support – Tags records with a cluster name for centralized databases
- Automatic Migrations – Creates and updates its tables on startup
- Usage Measurements – Records each job's CPU time (
total_cpu_seconds, from 1.1) for CPU efficiency, and in sacct mode its peak memory (max_rss) for memory efficiency
In sacct mode the ingestor reads job steps as well as allocations, since CPU time and peak memory come from the steps. Steps are folded into their job; they aren't stored separately.
Before You Start
You need a PostgreSQL 13+ database that the dashboard also uses. If you haven't set one up, follow Installation first. The examples here use a database and user both named slurmdash.
The ingestor runs its database migrations every time it starts and only applies the ones that are missing, so you don't need psql or any migration files. Its database user needs permission to create tables.
Choosing a Mode
| Mode | INGEST_MODE | Runs where | Notes |
|---|---|---|---|
| Sacct (recommended) | sacct | A Slurm node with sacct access | Faster and more reliable |
| API | api (default) | Anywhere that can reach slurmrestd | Needs SLURM_SERVER, SLURM_API_ACCOUNT and SLURM_API_TOKEN |
| Requirement | Version | Notes |
|---|---|---|
| PostgreSQL | 13+ | Can be on a different machine |
| Slurm | 20.11+ | With slurmrestd (API mode) or sacct access (sacct mode) |
| Go | 1.22+ | Only for building from source |
Option A: Container Image
The image is published at ghcr.io/thediymaker/slurm-history-ingestor. Releases are tagged :<version> and :latest; builds from main are tagged :main.
Use API Mode in a Container:
The image doesn't include sacct. Use API mode, or run the release binary on
a Slurm node for sacct mode.
Create a .env file:
DATABASE_URL=postgres://slurmdash:change-me@db-host:5432/slurmdash?sslmode=require
CLUSTER_NAME=mycluster
INGEST_MODE=api
SLURM_SERVER=http://slurm-head:6820
SLURM_API_ACCOUNT=slurm
SLURM_API_TOKEN=your_jwt_token_here
Then run it:
docker run -d --name slurm-ingestor --restart unless-stopped \
--env-file .env ghcr.io/thediymaker/slurm-history-ingestor:latest
docker logs -f slurm-ingestor
Quotes in Docker Env Files:
Docker's --env-file keeps quotes as part of the value, so don't quote the
values in this file.
The image runs as the numeric user 1000:1000, so it works with Kubernetes runAsNonRoot.
Option B: Release Binary
Release binaries are published for linux-amd64 and linux-arm64. This is the usual choice for sacct mode on a login node.
Step 1: Download the Binary
# Create installation directory
sudo mkdir -p /opt/slurm-ingestor
cd /opt/slurm-ingestor
# Download the latest release (Linux x64)
sudo wget https://github.com/thediymaker/slurm-history-ingestor/releases/latest/download/slurm-ingestor-linux-amd64 -O slurm-ingestor
sudo chmod +x slurm-ingestor
Step 2: Configure the Service
Get the configuration template and customize it:
# Download the example config
sudo wget https://raw.githubusercontent.com/thediymaker/slurm-history-ingestor/main/.env.example -O .env
# Edit with your database and cluster information
sudo vim .env
# Secure the file
sudo chmod 600 .env
Minimal sacct mode configuration:
# Database connection (the same database as the dashboard)
DATABASE_URL=postgres://slurmdash:change-me@db-host:5432/slurmdash?sslmode=require
# Cluster identification
CLUSTER_NAME=production-hpc
# Use sacct mode (recommended)
INGEST_MODE=sacct
SACCT_PATH=/usr/bin/sacct
# Start syncing from this date on first run
INITIAL_SYNC_DATE=2024-01-01
SSL Mode:
Use sslmode=require (or verify-full) whenever the database is on another
host. sslmode=disable is only appropriate for a local, same-host
PostgreSQL.
Step 3: Create the Systemd Service
Create /etc/systemd/system/slurm-ingestor.service:
sudo vim /etc/systemd/system/slurm-ingestor.service
Add this content:
[Unit]
Description=Slurm History Ingestor
After=network.target remote-fs.target munge.service
Requires=remote-fs.target munge.service
[Service]
Type=simple
User=slurm
Group=slurm
WorkingDirectory=/opt/slurm-ingestor
ExecStart=/opt/slurm-ingestor/slurm-ingestor
Restart=on-failure
RestartSec=10
EnvironmentFile=/opt/slurm-ingestor/.env
[Install]
WantedBy=multi-user.target
Step 4: Start the Service
# Reload systemd to recognize the new service
sudo systemctl daemon-reload
# Enable and start the service
sudo systemctl enable --now slurm-ingestor
# Check that it's running
systemctl status slurm-ingestor
# Watch the logs
journalctl -u slurm-ingestor -f
On startup the log shows Running database migrations... and then Database migrations complete.
Option C: Build from Source
git clone https://github.com/thediymaker/slurm-history-ingestor.git
cd slurm-history-ingestor
# Build (the binary runs migrations itself on startup)
go mod tidy
go build -o slurm-ingestor cmd/ingest/main.go
# Configure and run
cp .env.example .env
vim .env
./slurm-ingestor
Don't Run sqlc generate:
The database code in internal/db is committed and hand-customized.
Regenerating it with sqlc generate breaks ingestion.
The repository also includes an interactive setup.sh that builds the binary and writes .env, and a docker-compose.yaml that builds the image locally (docker compose up -d ingestor). The setup script offers to run migrations with psql; you can skip that, since the binary applies them when it starts.
Configuration Reference
Configure the ingestor using environment variables or a .env file in its working directory.
Required Settings
| Variable | Description | Example |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | postgres://slurmdash:pass@db-host:5432/slurmdash?sslmode=require |
CLUSTER_NAME | Slurm's name for the cluster, ClusterName in slurm.conf (scontrol show config | grep ClusterName). The dashboard records cluster capacity under that name and the metrics page matches jobs to capacity by it, so use the same name, not the dashboard's display name | production-hpc |
Ingest Mode Selection
Sacct Mode (recommended) – runs sacct directly
| Variable | Description | Default |
|---|---|---|
INGEST_MODE | Set to sacct | api |
SACCT_PATH | Path to sacct binary | sacct |
Note:
Sacct mode requires running on a Slurm node with sacct command access. This is the recommended mode for production.
API Mode (default) – uses slurmrestd
| Variable | Description | Example |
|---|---|---|
INGEST_MODE | Set to api (default) | api |
SLURM_SERVER | Slurm REST API URL, including protocol and port | http://slurm-head:6820 |
SLURM_API_ACCOUNT | Username for API authentication | slurm |
SLURM_API_TOKEN | JWT token for authentication | eyJhbGc... |
SLURM_API_VERSION | Optional. Unset: the newest version slurmrestd serves | v0.0.42 |
SLURM_API_TZ | IANA timezone slurmrestd interprets zone-less timestamps in. Must match the slurmrestd host's TZ (default UTC) | America/Phoenix |
SLURM_SERVER Differs from the Dashboard:
The ingestor's SLURM_SERVER is a full URL such as http://slurm-head:6820.
The dashboard's SLURM_SERVER is the hostname only.
Sync Behavior
| Variable | Default | Description |
|---|---|---|
SYNC_INTERVAL | 60 | Seconds between sync cycles |
LOOKBACK_MINUTES | 5 | Overlap window re-scanned before the sync cursor on every sync after the first run, to catch jobs delayed by slurmdbd |
INITIAL_SYNC_DATE | 2024-01-01 | How far back to sync on the first run, when there's no sync cursor and no job history for the cluster (YYYY-MM-DD, UTC). slurmdbd only has jobs back to its PurgeJobAfter; earlier windows come back empty and the ingestor moves past them |
CHUNK_HOURS | 24 | Hours of data to fetch per request. In API mode each job is around 16 KB of JSON. From 1.1.2 the ingestor asks slurmdbd only for jobs that ended in the window; earlier releases receive every job that was pending or running during it, which on a busy cluster can be ten times as much. For busy clusters, try 6 or 1 |
CHUNK_MINUTES | unset | Minutes of data per request; overrides CHUNK_HOURS. For clusters that finish tens of thousands of jobs an hour, try 15 (1.1.3+) |
CHUNK_TARGET_JOBS | 0 | API mode: size each request to about this many finished jobs, between one minute and CHUNK_HOURS/CHUNK_MINUTES, adjusting as it goes. For clusters whose job rate swings widely, try 3000 (1.1.3+) |
BACKFILL_PAUSE_RATIO | 0 | While catching up, wait this many times as long as the last request took before sending the next. 1 keeps slurmrestd busy at most half the time during a backfill (1.1.3+) |
Backfills and slurmrestd:
While slurmrestd builds a large job list it answers nothing else, so a
backfill that asks for an hour with tens of thousands of jobs can stall the
dashboard's own requests for minutes. On busy clusters, set
CHUNK_TARGET_JOBS (for example 3000) and BACKFILL_PAUSE_RATIO=1 before
starting a long backfill. Once the ingestor has caught up, windows are short
and the pause no longer applies.
History Older Than slurmdbd Keeps:
INITIAL_SYNC_DATE is only read on the first run. To backfill further later,
you'd delete the cluster's rows from job_history and ingest_sync_state and
start again, and slurmdbd can only give back what it hasn't purged. Once
ingested, jobs stay in job_history after slurmdbd purges them.
Database Connections:
The ingestor opens at most 4 database connections; set pool_max_conns in
DATABASE_URL to change that (for example
postgres://…/slurmdash?pool_max_conns=8). Releases up to 1.1.0 open one per
CPU on the host, which can be hundreds on a large node or in a container that
sees them all; with those, add pool_max_conns=4 if the database user has a
connection limit or shares one with the dashboard.
The ingestor saves its position in ingest_sync_state after each window, so a quiet cluster no longer re-scans its whole history on every pass. API and sacct mode keep separate positions. After upgrading from an ingestor without the cursor, the first pass scans from the last finished job, once.
Advanced Options
| Variable | Default | Description |
|---|---|---|
HTTP_TIMEOUT | 120 | API request timeout in seconds (API mode only) |
DEBUG | false | Enable verbose logging for troubleshooting |
TZ | unset | Optional. Timestamps are normalized to UTC in code; TZ=UTC only affects log formatting |
Storage Planning
Each job record uses approximately 500 bytes of storage:
| Job Count | Estimated Storage |
|---|---|
| 100,000 | ~50 MB |
| 1 million | ~500 MB |
| 10 million | ~5 GB |
| 100 million | ~50 GB |
Recommendations for large deployments:
- Use a dedicated PostgreSQL server for >1M jobs
- Consider table partitioning by
submit_timefor >10M jobs - Plan for index overhead (roughly 30-40% of table size)
Troubleshooting
Common Issues
| Problem | Solution |
|---|---|
| Connection Refused | Verify SLURM_SERVER URL is correct and slurmrestd is running |
| Authentication Failed | Check that SLURM_API_ACCOUNT exists and token is valid |
| No Jobs Syncing | Enable DEBUG=true and verify CLUSTER_NAME matches your cluster |
| Jobs lag by hours (API mode) | Set SLURM_API_TZ to the slurmrestd host's timezone |
| Metrics show jobs but no utilization | CLUSTER_NAME differs from Slurm's ClusterName, which the dashboard records capacity under |
| Every window is empty | INITIAL_SYNC_DATE is before slurmdbd's PurgeJobAfter; the ingestor catches up to the oldest jobs on its own |
| "Timeout was reached" (API mode) | Reduce CHUNK_HOURS or set CHUNK_TARGET_JOBS, increase HTTP_TIMEOUT, or switch to sacct mode |
| Dashboard slow or timing out during a backfill | slurmrestd is busy with the ingestor's requests; set CHUNK_TARGET_JOBS and BACKFILL_PAUSE_RATIO (1.1.3+) |
| Slow or very large API responses | Upgrade to 1.1.2 or later, which asks slurmdbd only for finished jobs; then reduce CHUNK_HOURS |
| Sacct Permission Denied | Ensure the service user has permissions to run sacct |
| Service Won't Start | Check journalctl -u slurm-ingestor -xe for detailed error messages |
| Dashboard says "No job history yet" | Check that the ingestor and the dashboard use the same database |
Debugging Tips
-
Enable debug logging:
# Add to .env file DEBUG=true # Restart service sudo systemctl restart slurm-ingestor -
Watch logs in real-time:
journalctl -u slurm-ingestor -f -
Test database connection:
psql "$DATABASE_URL" -c "SELECT COUNT(*) FROM job_history;" -
Test sacct access:
sudo -u slurm sacct --starttime now-1hour --format=JobID,JobName,State
Getting Help
If you encounter issues not covered here:
- Check the GitHub Issues
- Review systemd logs:
journalctl -u slurm-ingestor -n 100 - Verify your
.envconfiguration matches the examples above