Server monitoring
Watch CPU, memory, disk, load and network of your Linux servers and get paged when one stops reporting.
Incidion collects server metrics from a small shell script that runs on your server every minute. You see every host with charts in the web dashboard and the app, alert on thresholds (CPU over 90% for 10 minutes) and get paged when a server stops sending data.
Install the collector
You need a Linux server with bash, awk, df, curl and cron (every common distribution has them), a user with sudo, and a project API key: Settings > API keys in the app or the web dashboard (owners and admins). The public key (pk_...) is the one to use; it needs the metrics:write scope if you limited its scopes. Secret keys (sk_...) are refused.
The quickest way is the connect page: Settings > Projects, a project, Connect a source, Server metrics. It shows the install command with your key and the addresses of the Incidion you use filled in. Copy it and run it on the server:
curl -fsSL https://incidion.dev/install/incidion-metrics.sh | sudo bash -s -- --install \
--key pk_your_key \
--endpoint https://ingest.incidion.dev/v1/metrics \
--script-url https://incidion.dev/install/incidion-metrics.sh
Put sudo before bash, not before curl: the install needs root, the download does not. The command:
- copies the collector script to
/opt/incidion/incidion-metrics.sh, - writes the cron job
/etc/cron.d/incidion-metrics, which runs the script every minute as root (the file is readable by root only, because it holds the key), - sends one test report and prints the result:
OK: Metrics sent to ingest.incidion.dev (HTTP 200; cpu=12.3% cores=4 mem=45.6% disk=32% load=0.8 rx=9009B/s tx=132442B/s)
The host shows up under Server metrics within a minute. If the test report fails, the command says why (see Troubleshooting); the cron job stays installed and keeps trying, so fix the cause and run the command again.
Running the command again replaces the script and the cron job, for example with a new key. Add --host web-1 for another host name and --environment <id> for an environment (see Configuration).
Read the script before you run it if you like: open the /install/incidion-metrics.sh address in a browser. It only reads /proc and df and sends one request a minute to the Incidion ingest.
Uninstall
sudo bash /opt/incidion/incidion-metrics.sh --uninstall
This removes the cron job and the script; the log file stays. The host stops counting for alert rules 24 hours after its last data point.
Logs
Errors of the cron runs go to /var/log/incidion-metrics.log, one line per failed run with the time. A successful run writes nothing. To watch it:
sudo tail -f /var/log/incidion-metrics.log
To try one run by hand at any time:
sudo bash /opt/incidion/incidion-metrics.sh --verbose --key pk_your_key --endpoint https://ingest.incidion.dev/v1/metrics
Manual install
If you prefer your own crontab, download the script and add a line with sudo crontab -e (into the crontab, not into the shell):
sudo mkdir -p /opt/incidion
sudo curl -fsSL -o /opt/incidion/incidion-metrics.sh https://incidion.dev/install/incidion-metrics.sh
sudo chmod +x /opt/incidion/incidion-metrics.sh
* * * * * INCIDION_API_KEY=pk_your_key INCIDION_ENDPOINT=https://ingest.incidion.dev/v1/metrics /opt/incidion/incidion-metrics.sh >>/var/log/incidion-metrics.log 2>&1
Cron does not read your shell’s environment, so the key goes into the line itself. Without root, write the log somewhere your user may write, such as $HOME/incidion-metrics.log. For a point every 30 seconds, add a second line with sleep 30 && in front of the command. Send at least once a minute: a host stopped reporting rule fires after 5 minutes without data by default.
Configuration
Each setting is a flag of the script or an environment variable (the install writes them into the cron job):
| Flag | Variable | Default | Description |
|---|---|---|---|
--key |
INCIDION_API_KEY |
(required) | Project API key (pk_...) |
--endpoint |
INCIDION_ENDPOINT |
https://ingest.incidion.dev/v1/metrics |
Ingest address; the connect page shows the one of your Incidion |
--host |
INCIDION_HOST |
output of hostname |
Name the server appears under. Keep it stable: a new name is a new host |
--environment |
INCIDION_ENVIRONMENT_ID |
(none) | Environment ID (production, staging, …), from Settings > Environments |
--verbose |
INCIDION_VERBOSE |
(off) | 1 prints a line after every successful run |
--script-url |
INCIDION_SCRIPT_URL |
the website next to the ingest | Where --install downloads the script when it is piped into bash |
Several servers with the same hostname (for example cloned machines) need their own --host, or they show up as one host.
What is collected
| Metric | Unit | What it measures |
|---|---|---|
cpu_usage |
percent | CPU utilisation over one second, all cores |
cpu_iowait |
percent | CPU time spent waiting for the disk |
cpu_cores |
cores | Number of CPU cores (from nproc); a load average above it means the CPU is saturated |
memory_usage |
percent | Memory in use (total minus available) |
swap_usage |
percent | Swap in use (0 without swap) |
disk_usage |
percent | Root filesystem / |
disk_usage:<mount> |
percent | Every other real filesystem, for example disk_usage:/var (up to 20) |
disk_inodes_usage |
percent | Inodes in use on / (a disk can be “full” with free space when inodes run out) |
load_avg_1m, load_avg_5m, load_avg_15m |
load | Load averages; compare them with cpu_cores (a load of 4 is busy on 2 cores and fine on 16) |
network_rx_bytes, network_tx_bytes |
bytes/s | Received and sent bytes per second, every interface except loopback |
Each run takes about one second. Metrics do not count against the log quota and are kept for 90 days. To send your own values (queue length, open connections), see Send logs.
Where you see it
- Web dashboard: Observe > Server metrics lists every host with its latest values; a host’s page has charts over a chosen range and the alert rules that apply to it.
- App (iPhone and Android): Servers lists your hosts, whether they are reporting and their latest values; tap one for its charts.
- iPhone home screen: the Server health widget.
Alert on high usage
A metric threshold rule compares the average of a metric per host over a window, for example CPU over 90% for 10 minutes or root disk over 85%. Each host gets its own alert, which resolves itself when the host is back under the line. Create one in Alert rules or from a host’s page. Details: Alert rules.
Get paged when a server goes down
A server that crashed or lost its network sends nothing, so no threshold can catch it. A host stopped reporting rule does: it fires for each host that sent metrics in the last 24 hours and then none for its minutes (default 5), opens an incident and pages your escalation policy. The incident resolves itself with the host’s next data point.
- Leave the host empty to watch every host of the project, or name one.
- If you turn a server off on purpose, resolve its incident; after 24 hours without data the host no longer counts.
- If Incidion’s own metric ingest is interrupted, these rules wait instead of paging everyone.
Details: Alert rules.
Troubleshooting
The script never fails silently: every failed run prints one line starting with Error: (in /var/log/incidion-metrics.log for cron runs), and the install prints the result of its test report.
“–install needs root”: put sudo before bash in the pipe (curl ... | sudo bash -s -- --install ...), not before curl.
“INCIDION_API_KEY is not set”: a manual cron line needs the key in the line itself; cron does not pass your shell’s variables. The install writes it for you.
“this is a secret key (sk_…)”: use the project’s public key (pk_...).
“cannot reach ingest… (curl 6: could not resolve host)”: the server cannot resolve the ingest’s name. Check its DNS, and that the endpoint is the one the connect page shows.
“cannot reach ingest… (curl 7 or 28)”: no connection or a timeout. The server needs outbound HTTPS (port 443) to the ingest; check its firewall and any outbound proxy.
HTTP 401: the key is wrong or deactivated. Check it under Settings > API keys.
HTTP 403: the key’s scopes do not include metrics:write.
HTTP 404: the endpoint is not the metrics endpoint; it ends in /v1/metrics.
HTTP 422: the body was refused, usually an empty host name or a bad environment ID. The error line shows the start of the answer, which says why.
HTTP 429: too many requests for your plan’s rate limit; send once a minute, not more often than every 30 seconds.
“line N: … failed”: a command the script needs failed on this server (for example df). The line names it; please tell us if it persists.
The host does not appear: check /var/log/incidion-metrics.log, run the script once by hand with --verbose (see Logs), and check the time range and project in the dashboard and that the host name is what you expect.