No description
- Go 100%
|
Some checks failed
release-please / Creating release (push) Failing after 15s
|
||
|---|---|---|
| .forgejo | ||
| internal | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| README.md | ||
atop2prom
One-shot tool that parses an atop log file and ships every sample to a
Prometheus-compatible backend via the remote_write protocol.
How it works
atop2prom shells out to the system atop binary and reads its JSON output
(atop -r <file> -J ALL). Each interval becomes a batch of
prometheus.TimeSeries samples that are sent to the configured
remote_write endpoint.
Requires atop >= 2.8.0 (the version that introduced -J).
Usage
atop2prom \
--file /var/log/atop/atop_20260524 \
--remote-write https://prom.example/api/v1/write \
--username user --password secret \
--header 'X-Scope-OrgID: tenant-a' \
--external-label env=prod \
--external-label datacenter=eu1
Flags
| Flag | Description |
|---|---|
--file |
Path to the atop raw log file (required) |
--remote-write |
Remote write endpoint URL (required) |
--atop-binary |
Override path to the atop binary (default: looked up in $PATH) |
--username / --password |
HTTP basic auth credentials |
--header |
Repeatable custom HTTP header (Key: Value) |
--external-label |
Repeatable static label attached to every series (key=value) |
--batch-size |
Samples per remote_write request (default 500) |
--timeout |
Per-request timeout (default 30s) |
Labels
Every series carries:
host— taken from the atop log (the recorded hostname)instanceidentifiers per metric family (cpu,dev,iface,pid+comm, …)- any
--external-labels the user supplied
Metric naming
Metrics follow atop_<group>_<field>. For example:
atop_cpu_user_ticks_total{cpu="0",host="myhost"}— per-core user time counteratop_mem_free_bytes{host="myhost"}— gauge of free memoryatop_dsk_read_bytes_total{dev="sda",host="myhost"}— disk read counteratop_prc_user_ticks_total{pid="1234",comm="postgres",host="myhost"}— process CPU
CPU times are reported as clock ticks (the unit atop emits); divide by the
atop_cpu_hertz gauge to convert to seconds.