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 procstat plugin 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 agent uses:

  • pid_file (if present)
  • Otherwise, exe
  • Otherwise, pattern
  • On Linux, exe and pattern are 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 NameAvailable OnDescriptionUnit
cpu_timeLinuxCPU time used by processCount
cpu_time_guestLinuxTime in guest modeNone
cpu_time_guest_niceLinuxTime in nice guestNone
cpu_time_idleLinuxTime in idle modeNone
cpu_time_iowaitLinuxTime waiting for I/ONone
cpu_time_irqLinuxTime servicing interruptsNone
cpu_time_niceLinuxTime in nice modeNone
cpu_time_soft_irqLinuxTime servicing software interruptsNone
cpu_time_stealLinuxTime spent running other OS in virtualizationNone
cpu_time_stolenLinux, Windows ServerTime in stolen modeNone
cpu_time_systemLinux, Windows Server, macOSTime in system modeCount
cpu_time_userLinux, Windows Server, macOSTime in user modeCount
cpu_usageLinux, Windows Server, macOSCPU utilization percentagePercent
memory_dataLinux, macOSMemory used for dataBytes
memory_lockedLinux, macOSLocked memoryBytes
memory_rssLinux, Windows Server, macOSResident set memory usageBytes
memory_stackLinux, macOSStack memory usageBytes
memory_swapLinux, macOSSwap memory usageBytes
memory_vmsLinux, Windows Server, macOSVirtual memory sizeBytes
num_fdsLinuxNumber of file descriptors openNone
num_threadsLinux, Windows, macOSNumber of threadsNone
pidLinux, Windows Server, macOSProcess IDNone
pid_countLinux, Windows Server, macOSNumber of PIDs (e.g., procstat_lookup_pid_count)None
read_bytesLinux, Windows ServerDisk bytes read by the processBytes
write_bytesLinux, Windows ServerDisk bytes written by the processBytes
read_countLinux, Windows ServerNumber of disk read operationsNone
rlimit_realtime_priority_hardLinuxHard limit for real-time priorityNone
rlimit_realtime_priority_softLinuxSoft limit for real-time priorityNone
rlimit_signals_pending_hardLinuxHard limit for pending signalsNone
rlimit_signals_pending_softLinuxSoft limit for pending signalsNone
rlimit_nice_priority_hardLinuxHard limit for nice priorityNone
rlimit_nice_priority_softLinuxSoft limit for nice priorityNone

Ref: AWS DOCS (opens in a new tab)