MicroAgent is a lightweight Linux process monitoring agent written in C, designed for ARM and x86_64 platforms, including embedded systems and resource-constrained environments such as Raspberry Pi. It collects process metrics directly from /proc and provides a modular architecture with pluggable encoders and outputs, currently supporting Prometheus text format over HTTP.
- Linux (ARM or x86_64)
- GCC
- GNU Make
- A running VictoriaMetrics instance
makeMonitor MicroAgent itself using the default configuration:
./microagentMonitor a specific process with a custom configuration:
./microagent --pid 1234 --interval 1000 --target-host 127.0.0.1 --target-port 8428MicroAgent can be configured through command-line arguments and environment variables.
Configuration is loaded once at startup, in the following order:
- Default values
- Environment variables
- Command-line arguments
Each configuration level overrides the previous one.
Invalid configuration values cause MicroAgent to exit at startup, even if a higher-priority configuration would override them.
| Argument | Environment variable | Default | Description |
|---|---|---|---|
--pid |
MICROAGENT_PID |
Own PID | Process ID to monitor |
--process |
MICROAGENT_PROCESS |
Unset | Process name to monitor |
--service |
MICROAGENT_SERVICE |
Unset | Logical service name |
--instance |
MICROAGENT_INSTANCE |
Unset | Service instance identifier |
--hostname |
MICROAGENT_HOSTNAME |
System hostname | Metric source hostname |
--interval |
MICROAGENT_INTERVAL |
1000 |
Collection interval in milliseconds |
--target-host |
MICROAGENT_TARGET_HOST |
127.0.0.1 |
Metric destination IPv4 address |
--target-port |
MICROAGENT_TARGET_PORT |
8428 |
Metric destination port |
--target-path |
MICROAGENT_TARGET_PATH |
/api/v1/import/prometheus |
HTTP request path |
PID and process name are mutually exclusive within the same configuration level.
If neither is specified, MicroAgent monitors itself.
Service and instance are optional metric labels and do not affect process selection.
PID-based monitoring targets a specific process instance and stops when the process terminates.
Name-based monitoring uses the Linux process name (comm) and automatically discovers the process again after termination.
During discovery, MicroAgent waits until exactly one matching process is available.
Linux process names are limited to 15 bytes, excluding the terminating null byte.
Monitor a specific process:
./microagent --pid 1234Monitor a process by name and assign a service identity:
./microagent --process myapp --service paymentMICROAGENT_PROCESS=myapp \
MICROAGENT_SERVICE=payment \
MICROAGENT_INSTANCE=payment-01 \
MICROAGENT_TARGET_HOST=192.168.1.100 \
./microagentEach MicroAgent process has its own environment, allowing multiple instances to run independently on the same host.
Environment-based configuration can be supplied through systemd, Docker, Docker Compose and Kubernetes without additional MicroAgent configuration files.
Metrics include the following labels:
host: Metric source hostname.process: Monitored process name.pid: Current process ID.service: Logical service name (optional).instance: Service instance identifier (optional).
The target host, port and path define the metric destination and are independent of the metric source identity.
All collectors are enabled by default.
Individual collectors can be disabled at compile time using their corresponding WITH_* build options.
Examples:
# Build with all collectors
make
# Disable the IO collector
make WITH_IO=0
# Disable multiple collectors
make WITH_IO=0 WITH_FD=0Disabled collectors are completely excluded from the binary.
See the collector documentation below for available build options.
The logging level is selected at compile time using the LOG_LEVEL build option.
| Log level | Enabled levels |
|---|---|
ERROR |
ERROR |
WARN |
ERROR, WARN |
INFO (default) |
ERROR, WARN, INFO |
DEBUG |
ERROR, WARN, INFO, DEBUG |
Examples:
# Build with the default logging level
make
# Build with warnings and errors only
make LOG_LEVEL=WARN
# Build with detailed debug logging
make LOG_LEVEL=DEBUG
# Combine collector and logging options
make WITH_IO=0 LOG_LEVEL=WARNDisabled logging levels are excluded at compile time, including their log messages and function calls.
ERROR logging is always enabled.
All log messages are written to stderr, keeping operational logs separate from metric data.
DEBUG logging includes HTTP requests, metric payloads and HTTP response headers.
MicroAgent collects process metrics directly from the Linux /proc filesystem.
Collects process memory usage, thread count, file descriptor table capacity and context switch counters.
- Data source:
/proc/[pid]/status - Metrics: 20
- Documentation: proc_pid_status(5)
Collects CPU time, minor and major page faults, and process start time relative to system boot.
- Data source:
/proc/[pid]/stat - Metrics: 5
- Documentation: proc_pid_stat(5)
Collects process I/O statistics, including transferred bytes, read and write system calls, storage I/O and cancelled writes.
- Data source:
/proc/[pid]/io - Metrics: 7
- Documentation: proc_pid_io(5)
Collects the number of open file descriptors, including files, sockets and pipes.
- Data source:
/proc/[pid]/fd - Metrics: 1
- Documentation: proc_pid_fd(5)
For more information about the underlying data sources, see the official Linux Kernel /proc Filesystem Documentation.
Metric availability may depend on the Linux kernel version, kernel configuration and process access permissions.
This project is currently under active development and is not yet production-ready. The main goals are simplicity, minimal resource usage, and minimal dependencies.