Skip to content

Commit

Permalink
Trim down beat name if it's longer than 15 characters (elastic#22550)
Browse files Browse the repository at this point in the history
* Trim down beat name if it's longer than 15 characters

* add OS guard, changelog
  • Loading branch information
fearful-symmetry authored Nov 17, 2020
1 parent 9157d18 commit 82b8372
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add interval information to `monitor` metricset in azure. {pull}22152[22152]
- Change Session ID type from int to string {pull}22359[22359]
- Fix filesystem types on Windows in filesystem metricset. {pull}22531[22531]
- Fix failiures caused by custom beat names with more than 15 characters {pull}22550[22550]

*Packetbeat*

Expand Down
6 changes: 6 additions & 0 deletions libbeat/cmd/instance/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func init() {
func setupMetrics(name string) error {
monitoring.NewFunc(systemMetrics, "cpu", reportSystemCPUUsage, monitoring.Report)

//if the beat name is longer than 15 characters, truncate it so we don't fail process checks later on
// On *nix, the process name comes from /proc/PID/stat, which uses a comm value of 16 bytes, plus the null byte
if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && len(name) > 15 {
name = name[:15]
}

beatProcessStats = &process.Stats{
Procs: []string{name},
EnvWhitelist: nil,
Expand Down

0 comments on commit 82b8372

Please sign in to comment.