Skip to content

Commit

Permalink
feat(inputs.procstat): Add ability to collect per-process socket stat…
Browse files Browse the repository at this point in the history
…istics (#15423)
  • Loading branch information
srebhan authored Jul 17, 2024
1 parent 7245ea9 commit fd8cbbf
Show file tree
Hide file tree
Showing 10 changed files with 714 additions and 40 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ require (
github.com/twmb/murmur3 v1.1.7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/vishvananda/netlink v1.2.1-beta.2 // indirect
github.com/vishvananda/netlink v1.2.1-beta.2.0.20240524165444-4d4ba1473f21
github.com/vishvananda/netns v0.0.4
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2380,8 +2380,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
github.com/vapourismo/knx-go v0.0.0-20240217175130-922a0d50c241 h1:3r4OPQ/jPYQA0C7i149kevHLGSG4JZtrQv2986fXSCo=
github.com/vapourismo/knx-go v0.0.0-20240217175130-922a0d50c241/go.mod h1:aGkV5xHz9sBkAckp2hez7khfehKp4YvyBwAmVdVEulg=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs=
github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
github.com/vishvananda/netlink v1.2.1-beta.2.0.20240524165444-4d4ba1473f21 h1:tcHUxOT8j/R+0S+A1j8D2InqguXFNxAiij+8QFOlX7Y=
github.com/vishvananda/netlink v1.2.1-beta.2.0.20240524165444-4d4ba1473f21/go.mod h1:whJevzBpTrid75eZy99s3DqCmy05NfibNaF2Ol5Ox5A=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
Expand Down Expand Up @@ -2816,7 +2816,6 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -2894,6 +2893,7 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
Expand Down
70 changes: 62 additions & 8 deletions plugins/inputs/procstat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,40 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
## result in a large number of series, especially with short-lived processes,
## creating high cardinality at the output.
## Available options are:
## cmdline -- full commandline
## pid -- ID of the process
## ppid -- ID of the process' parent
## status -- state of the process
## user -- username owning the process
## cmdline -- full commandline
## pid -- ID of the process
## ppid -- ID of the process' parent
## status -- state of the process
## user -- username owning the process
## socket only options:
## protocol -- protocol type of the process socket
## state -- state of the process socket
## src -- source address of the process socket (non-unix sockets)
## src_port -- source port of the process socket (non-unix sockets)
## dest -- destination address of the process socket (non-unix sockets)
## dest_port -- destination port of the process socket (non-unix sockets)
## name -- name of the process socket (unix sockets only)
# tag_with = []

## Properties to collect
## Available options are "cpu", "limits", "memory", "mmap"
## Available options are
## cpu -- CPU usage statistics
## limits -- set resource limits
## memory -- memory usage statistics
## mmap -- mapped memory usage statistics (caution: can cause high load)
## sockets -- socket statistics for protocols in 'socket_protocols'
# properties = ["cpu", "limits", "memory", "mmap"]

## Protocol filter for the sockets property
## Available options are
## all -- all of the protocols below
## tcp4 -- TCP socket statistics for IPv4
## tcp6 -- TCP socket statistics for IPv6
## udp4 -- UDP socket statistics for IPv4
## udp6 -- UDP socket statistics for IPv6
## unix -- Unix socket statistics
# socket_protocols = ["all"]

## Method to use when finding process IDs. Can be one of 'pgrep', or
## 'native'. The pgrep finder calls the pgrep executable in the PATH while
## the native finder performs the search directly in a manor dependent on the
Expand Down Expand Up @@ -141,8 +164,8 @@ Below are an example set of tags and fields:

- procstat
- tags:
- pid (when `pid_tag` is true)
- cmdline (when 'cmdline_tag' is true)
- pid (if requested)
- cmdline (if requested)
- process_name
- pidfile (when defined)
- exe (when defined)
Expand Down Expand Up @@ -231,6 +254,36 @@ Below are an example set of tags and fields:
- pid_count (int)
- running (int)
- result_code (int, success = 0, lookup_error = 1)
- procstat_socket (if configured, Linux only)
- tags:
- pid (if requested)
- protocol (if requested)
- cmdline (if requested)
- process_name
- pidfile (when defined)
- exe (when defined)
- pattern (when defined)
- user (when selected)
- systemd_unit (when defined)
- cgroup (when defined)
- cgroup_full (when cgroup or systemd_unit is used with glob)
- supervisor_unit (when defined)
- win_service (when defined)
- fields:
- protocol
- state
- pid
- src
- src_port (tcp and udp sockets only)
- dest (tcp and udp sockets only)
- dest_port (tcp and udp sockets only)
- bytes_received (tcp sockets only)
- bytes_sent (tcp sockets only)
- lost (tcp sockets only)
- retransmits (tcp sockets only)
- rx_queue
- tx_queue
- inode (unix sockets only)

*NOTE: Resource limit > 2147483647 will be reported as 2147483647.*

Expand All @@ -239,4 +292,5 @@ Below are an example set of tags and fields:
```text
procstat_lookup,host=prash-laptop,pattern=influxd,pid_finder=pgrep,result=success pid_count=1i,running=1i,result_code=0i 1582089700000000000
procstat,host=prash-laptop,pattern=influxd,process_name=influxd,user=root involuntary_context_switches=151496i,child_minor_faults=1061i,child_major_faults=8i,cpu_time_user=2564.81,pid=32025i,major_faults=8609i,created_at=1580107536000000000i,voluntary_context_switches=1058996i,cpu_time_system=616.98,memory_swap=0i,memory_locked=0i,memory_usage=1.7797634601593018,num_threads=18i,cpu_time_iowait=0,memory_rss=148643840i,memory_vms=1435688960i,memory_data=0i,memory_stack=0i,minor_faults=1856550i 1582089700000000000
procstat_socket,host=prash-laptop,process_name=browser,protocol=tcp4 bytes_received=826987i,bytes_sent=32869i,dest="192.168.0.2",dest_port=443i,lost=0i,pid=32025i,retransmits=0i,rx_queue=0i,src="192.168.0.1",src_port=52106i,state="established",tx_queue=0i 1582089700000000000
```
Loading

0 comments on commit fd8cbbf

Please sign in to comment.