Skip to content

Commit ef0e1e1

Browse files
authored
chore: do not attach pid tag for jstat when there is only one process (#1115)
1 parent cdc1097 commit ef0e1e1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

inputs/procstat/procstat.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,21 @@ func (ins *Instance) gatherLimit(slist *types.SampleList, procs map[PID]Process,
524524
}
525525

526526
func (ins *Instance) gatherJvm(slist *types.SampleList, procs map[PID]Process, tags map[string]string) {
527+
attachPid := false
528+
if len(procs) > 1 {
529+
attachPid = true
530+
}
527531
for pid := range procs {
528532
jvmStat, err := execJstat(pid)
529533
if err != nil {
530534
log.Println("E! failed to exec jstat:", err)
531535
continue
532536
}
533537

534-
pidTag := map[string]string{"pid": fmt.Sprint(pid)}
538+
pidTag := map[string]string{}
539+
if attachPid {
540+
pidTag["pid"] = fmt.Sprint(pid)
541+
}
535542
for k, v := range jvmStat {
536543
slist.PushSample(inputName, "jvm_"+k, v, pidTag, ins.makeCmdlineLabelReggroupTag(procs[pid]), tags)
537544
}

0 commit comments

Comments
 (0)