No description
Find a file
Vitaliy Vasylenko d7f343c0db
Some checks failed
release-please / Creating release (push) Failing after 15s
fix: migrate from github actions to forgejo actions
2026-06-09 00:48:24 -04:00
.forgejo fix: migrate from github actions to forgejo actions 2026-06-09 00:48:24 -04:00
internal feat: initial atop2prom implementation 2026-05-30 23:05:34 -04:00
.gitignore feat: initial atop2prom implementation 2026-05-30 23:05:34 -04:00
go.mod feat: initial atop2prom implementation 2026-05-30 23:05:34 -04:00
go.sum feat: initial atop2prom implementation 2026-05-30 23:05:34 -04:00
main.go feat: initial atop2prom implementation 2026-05-30 23:05:34 -04:00
README.md feat: initial atop2prom implementation 2026-05-30 23:05:34 -04:00

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)
  • instance identifiers 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 counter
  • atop_mem_free_bytes{host="myhost"} — gauge of free memory
  • atop_dsk_read_bytes_total{dev="sda",host="myhost"} — disk read counter
  • atop_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.