Collect Process Metrics with the procstat Plugin
The procstat plugin enables you to collect metrics from individual processes. The plugin is supported on Linux servers and Windows Server. This document explains how to configure the CloudWatch agent for procstat, view imported metrics, and lists the metrics that procstat collects.
Note The
procstatplugin is not supported for the Fargate launch type in Amazon ECS environments.
Topics
Configure the CloudWatch Agent for procstat
To use the procstat plugin, add a procstat section under the metrics_collected section in the CloudWatch agent configuration file. You can specify processes to monitor using one of the following methods (only one method is used even if multiple are specified):
pid_file: Selects processes by PID file name.exe: Selects processes with names matching a specified string (regex).pattern: Selects processes by the full command-line string (regex).
If multiple sections are specified,
CloudWatch agentuses:
pid_file(if present)- Otherwise,
exe- Otherwise,
pattern
- On Linux,
exeandpatternare evaluated as regular expressions. - On Windows Server, they are evaluated as WMI queries (e.g.,
pattern: "%apache%").
You can optionally include metrics_collection_interval (in seconds). Default is 60.
Configure with pid_file
{
"metrics": {
"metrics_collected": {
"procstat": [
{
"pid_file": "/var/run/example1.pid",
"measurement": ["cpu_usage", "memory_rss"]
},
{
"pid_file": "/var/run/example2.pid",
"measurement": ["read_bytes", "read_count", "write_bytes"],
"metrics_collection_interval": 10
}
]
}
}
}Configure with exe
{
"metrics": {
"metrics_collected": {
"procstat": [
{
"exe": "agent",
"measurement": ["cpu_time", "cpu_time_system", "cpu_time_user"]
},
{
"exe": "plugin",
"measurement": ["cpu_time", "cpu_time_system", "cpu_time_user"]
}
]
}
}
}Configure with pattern
{
"metrics": {
"metrics_collected": {
"procstat": [
{
"pattern": "config",
"measurement": [
"rlimit_memory_data_hard",
"rlimit_memory_data_soft",
"rlimit_memory_stack_hard",
"rlimit_memory_stack_soft"
]
},
{
"pattern": "-c",
"measurement": [
"rlimit_memory_data_hard",
"rlimit_memory_data_soft",
"rlimit_memory_stack_hard",
"rlimit_memory_stack_soft"
]
}
]
}
}
}Metrics Collected by procstat
The following table lists metrics collected by the procstat plugin. For Linux, metric names are prefixed with procstat_. For Windows Server, a space is used (e.g., procstat cpu_time).
| Metric Name | Available On | Description | Unit |
|---|---|---|---|
| cpu_time | Linux | CPU time used by process | Count |
| cpu_time_guest | Linux | Time in guest mode | None |
| cpu_time_guest_nice | Linux | Time in nice guest | None |
| cpu_time_idle | Linux | Time in idle mode | None |
| cpu_time_iowait | Linux | Time waiting for I/O | None |
| cpu_time_irq | Linux | Time servicing interrupts | None |
| cpu_time_nice | Linux | Time in nice mode | None |
| cpu_time_soft_irq | Linux | Time servicing software interrupts | None |
| cpu_time_steal | Linux | Time spent running other OS in virtualization | None |
| cpu_time_stolen | Linux, Windows Server | Time in stolen mode | None |
| cpu_time_system | Linux, Windows Server, macOS | Time in system mode | Count |
| cpu_time_user | Linux, Windows Server, macOS | Time in user mode | Count |
| cpu_usage | Linux, Windows Server, macOS | CPU utilization percentage | Percent |
| memory_data | Linux, macOS | Memory used for data | Bytes |
| memory_locked | Linux, macOS | Locked memory | Bytes |
| memory_rss | Linux, Windows Server, macOS | Resident set memory usage | Bytes |
| memory_stack | Linux, macOS | Stack memory usage | Bytes |
| memory_swap | Linux, macOS | Swap memory usage | Bytes |
| memory_vms | Linux, Windows Server, macOS | Virtual memory size | Bytes |
| num_fds | Linux | Number of file descriptors open | None |
| num_threads | Linux, Windows, macOS | Number of threads | None |
| pid | Linux, Windows Server, macOS | Process ID | None |
| pid_count | Linux, Windows Server, macOS | Number of PIDs (e.g., procstat_lookup_pid_count) | None |
| read_bytes | Linux, Windows Server | Disk bytes read by the process | Bytes |
| write_bytes | Linux, Windows Server | Disk bytes written by the process | Bytes |
| read_count | Linux, Windows Server | Number of disk read operations | None |
| rlimit_realtime_priority_hard | Linux | Hard limit for real-time priority | None |
| rlimit_realtime_priority_soft | Linux | Soft limit for real-time priority | None |
| rlimit_signals_pending_hard | Linux | Hard limit for pending signals | None |
| rlimit_signals_pending_soft | Linux | Soft limit for pending signals | None |
| rlimit_nice_priority_hard | Linux | Hard limit for nice priority | None |
| rlimit_nice_priority_soft | Linux | Soft limit for nice priority | None |