-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(inputs.procstat): Add child level tag #16105
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I have one code question, but also does this close issue #16104? If so could you update the PR description to close the issue? Thanks!
plugins/inputs/procstat/filter.go
Outdated
@@ -202,6 +202,7 @@ func (f *Filter) ApplyFilter() ([]processGroup, error) { | |||
tags[k] = v | |||
} | |||
tags["parent_pid"] = strconv.FormatInt(int64(p.Pid), 10) | |||
tags["child_level"] = strconv.FormatInt(int64(depth), 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a configuration option since it is a new tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree as it will also likely produce high cardinality. How about adding this as a field instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the cardinality is higher on the parent_pid field so this change is less impactful than one might think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, we cannot add a new tag unconditionally...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I understand your point of view.
What option would you suggest to add this tag?
Is there a naming rule?
It also means that for each plugin each time new tags are added, an option is needed. Is this likely to create plugins with long configurations?
We could put:
tag_child_level.
If not defined, the tag is not added.
If tag_child_level=toto then the level is added in the tag "toto"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up ? ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a configuration option since it is a new tag
@DStrand1 Have you a name recommanded for activate new tag ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] It also means that for each plugin each time new tags are added, an option is needed. Is this likely to create plugins with long configurations? [...]
That's why we prefer "lists" of what to add instead of boolean options. This way we have one option with many potential values. For this plugin there actually already is the tag_with
option, so why don't you just add the child-level there?
Check the code for how this option is used to conditionally add tags...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
I tryed, but I have 2 errors that I doesn't understand ...
Yes it's the same. The issue is in the PR description. What do you understand exactly by :
|
@tguenneguez the error means that the You need to add the option documentation to |
Thank you very much, I don't know how you found the cause, if you can tell me I will be more independent next time ;-) |
I understand my error ;-) So I thing it will be great to have possibility to generate "procstat_lookup" for different level... |
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tguenneguez thanks for the update. I do have some comments. The most important one is to only add the child_level
tag if the option is actually set. The code adds it unconditionally still.
## cmdline -- full commandline | ||
## pid -- ID of the process | ||
## ppid -- ID of the process' parent | ||
## status -- state of the process | ||
## user -- username owning the process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you changing the indentation level here?
## tag only available for procstat_lookup | ||
## level -- level of the process filtering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please indent the option similar to the ones above?
## 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments in README.md...
@@ -201,10 +200,11 @@ func (f *Filter) ApplyFilter() ([]processGroup, error) { | |||
for k, v := range group.tags { | |||
tags[k] = v | |||
} | |||
tags["parent_pid"] = strconv.FormatInt(int64(p.Pid), 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you removing this here?
@@ -180,7 +179,7 @@ func (f *Filter) ApplyFilter() ([]processGroup, error) { | |||
|
|||
matched = append(matched, p) | |||
} | |||
result = append(result, processGroup{processes: matched, tags: g.tags}) | |||
result = append(result, processGroup{processes: matched, tags: g.tags, level: 0}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
level
will be 0
without explicitly setting it. Please revert to the previous code.
tags := map[string]interface{}{ | ||
"pid_count": count, | ||
"running": len(running), | ||
"result_code": 0, | ||
} | ||
// Add lookup statistics-metric | ||
acc.AddFields( | ||
"procstat_lookup", | ||
map[string]interface{}{ | ||
"pid_count": count, | ||
"running": len(running), | ||
"result_code": 0, | ||
}, | ||
tags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert as this has nothing to do with your feature I think.
@@ -494,7 +513,7 @@ func (p *Procstat) findSupervisorUnits() ([]PidsTags, error) { | |||
if err != nil { | |||
return nil, fmt.Errorf("getting children for %d failed: %w", pid, err) | |||
} | |||
tags := map[string]string{"pattern": p.Pattern, "parent_pid": p.Pattern} | |||
tags := map[string]string{"pattern": p.Pattern, "parent_pid": p.Pattern, "child_level": p.Pattern} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to conditionally add the child_level
here!
@@ -103,6 +103,15 @@ Debug](https://grokdebug.herokuapp.com) application quite useful! | |||
## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent) | |||
grok_patterns = ["%{COMBINED_LOG_FORMAT}"] | |||
|
|||
## This is a list of patterns to count the given log file(s) for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move changes to the GROK parser to a separate PR!
Summary
Add tag for children process to be able to have information by level
Checklist
Related issues
resolves #16104