Skip to content

Commit

Permalink
metricbeat: collect total thread count per process
Browse files Browse the repository at this point in the history
Upgrades elastic-agent-system-metrics to v0.5.0 in order to collect the total thread count per process.
  • Loading branch information
AndersonQ committed Sep 14, 2023
1 parent 23347f8 commit 14404e7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]

*Metricbeat*

- System module now collects the total thread count per process.
The elastic-agent-system-metrics was updated to v0.5.0 as the total thread count
is collected by it.

*Osquerybeat*

Expand Down
6 changes: 3 additions & 3 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13025,12 +13025,12 @@ these terms.


--------------------------------------------------------------------------------
Dependency : github.com/elastic/elastic-agent-system-metrics
Version: v0.6.1
Dependency : github.com/AndersonQ/elastic-agent-system-metrics
Version: v0.0.0-20230913114254-ef72b6fa59d9
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-system-metrics@v0.6.1/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/github.com/!anderson!q/elastic-agent-system-metrics@v0.0.0-20230913114254-ef72b6fa59d9/LICENSE.txt:

Apache License
Version 2.0, January 2004
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,5 @@ replace (

// Exclude this version because the version has an invalid checksum.
exclude github.com/docker/distribution v2.8.0+incompatible

replace github.com/elastic/elastic-agent-system-metrics => github.com/AndersonQ/elastic-agent-system-metrics v0.0.0-20230913114254-ef72b6fa59d9
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zum
git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA=
github.com/AndersonQ/elastic-agent-system-metrics v0.0.0-20230913114254-ef72b6fa59d9 h1:aK888FnVMPSUNvP6q+9JUj76wOA0INWY/mXR2e6zmAU=
github.com/AndersonQ/elastic-agent-system-metrics v0.0.0-20230913114254-ef72b6fa59d9/go.mod h1:e2jSj1Fnnyhl21p2g52qhYCyyizX9Lup3z2m/3E9kvg=
github.com/Azure/azure-amqp-common-go/v3 v3.2.1 h1:uQyDk81yn5hTP1pW4Za+zHzy97/f4vDz9o1d/exI4j4=
github.com/Azure/azure-amqp-common-go/v3 v3.2.1/go.mod h1:O6X1iYHP7s2x7NjUKsXVhkwWrQhxrd+d8/3rRadj4CI=
github.com/Azure/azure-event-hubs-go/v3 v3.3.15 h1:2yAik9gS5Qjs4Z6EM1B6d0tfZJ506B/0oA08JlRQxb8=
Expand Down Expand Up @@ -657,8 +659,6 @@ github.com/elastic/elastic-agent-libs v0.3.13 h1:qFiBWeBfjsBId+i31rggyW2ZjzA9qBR
github.com/elastic/elastic-agent-libs v0.3.13/go.mod h1:mpSfrigixx8x+uMxWKl4LtdlrKIhZbA4yT2eIeIazUQ=
github.com/elastic/elastic-agent-shipper-client v0.5.1-0.20230228231646-f04347b666f3 h1:sb+25XJn/JcC9/VL8HX4r4QXSUq4uTNzGS2kxOE7u1U=
github.com/elastic/elastic-agent-shipper-client v0.5.1-0.20230228231646-f04347b666f3/go.mod h1:rWarFM7qYxJKsi9WcV6ONcFjH/NA3niDNpTxO+8/GVI=
github.com/elastic/elastic-agent-system-metrics v0.6.1 h1:LCN1lvQTkdUuU/rKlpKyVMDU/G/I8/iZWCaW6K+mo4o=
github.com/elastic/elastic-agent-system-metrics v0.6.1/go.mod h1:Bj8XM/uNKm553blQHkGNEICRLGnVEtw8yttmV5vBngA=
github.com/elastic/elastic-transport-go/v8 v8.0.0-20230329154755-1a3c63de0db6/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI=
github.com/elastic/elastic-transport-go/v8 v8.3.0 h1:DJGxovyQLXGr62e9nDMPSxRyWION0Bh6d9eCFBriiHo=
github.com/elastic/elastic-transport-go/v8 v8.3.0/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI=
Expand Down
10 changes: 8 additions & 2 deletions metricbeat/module/system/process/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
type: alias
path: process.pgid
migration: true
- name: num_threads
type: alias
description: >
Number of threads in the process
path: process.num_threads
migration: true
- name: cmdline
type: keyword
description: >
Expand Down Expand Up @@ -345,7 +351,7 @@
- name: stats.user.pct
type: scaled_float
description: time the cgroup spent in user space, as a percentage of total CPU time

- name: stats.user.norm.pct
type: scaled_float
description: time the cgroup spent in user space, as a percentage of total CPU time, normalized by CPU count.
Expand Down Expand Up @@ -419,7 +425,7 @@
type: long
format: bytes
description: memory max threshhold

- name: mem.events
type: group
description: number of times the controller tripped a given usage level
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/elastic/elastic-agent-system-metrics/metric/system/resolve"
)

var debugf = logp.MakeDebug("system.process")
var debugf = logp.NewLogger("system.process").Debugf

func init() {
mb.Registry.MustAddMetricSet("system", "process", New,
Expand Down
6 changes: 5 additions & 1 deletion metricbeat/module/system/process/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
_ "github.com/elastic/beats/v7/metricbeat/module/system"
Expand All @@ -32,7 +33,9 @@ import (
)

func TestFetch(t *testing.T) {
logp.DevelopmentSetup()
err := logp.DevelopmentSetup()
require.NoError(t, err, "could not set the logger to DevelopmentSetup")

f := mbtest.NewReportingMetricSetV2Error(t, getConfig())
events, errs := mbtest.ReportingFetchV2Error(f)
assert.Empty(t, errs)
Expand All @@ -44,6 +47,7 @@ func TestFetch(t *testing.T) {
assert.Empty(t, errs)
assert.NotEmpty(t, events)

t.Logf("fetched %d events, showing events[0]:", len(events))
t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(),
events[0].BeatEvent("system", "process").Fields.StringToPrint())
}
Expand Down

0 comments on commit 14404e7

Please sign in to comment.