-
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
Win perf counters expand wildcards #3018
Win perf counters expand wildcards #3018
Conversation
…tion expands wildcards in ObjectName, Instances and Counter.
return "\\" + objectname + "(" + instance + ")\\" + counter | ||
} | ||
|
||
func expandQuery(query string, expand bool) ([]string, error) { |
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.
Hi it looks like this could be the solution for #2879 the only thing would be to check if the instance name equals "*" and than expand the query. The expandQuery and formatCounterQuery Method could handle this together.
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 will be supplying a new patch today with both the changes you proposed and my comment at #2336
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.
On second thought, we shouldn't only check for equality with '' as the ExpandWildcardPath function expands both counter and instance names and also partial wildcards, such as "chrome".
I will be supplying the first patch shortly, if you could review it and make comments, it would be really helpful.
Gather() now uses PdhGetFormattedCounterValue. Move character sanitization out of the Gather() function to the ParseConfig stage.
Hi @vtsingaras thank you for your work. I created a fork and tried to simplify your logic a little bit. I think that this is all you need or do i miss something on the expand feature?! |
// return PDH_MORE_DATA and will not set the bufSize. | ||
bufCount = 0 | ||
bufSize = 0 | ||
ret = PdhGetFormattedCounterValueDouble(metric.counterHandle, &emptyBuf[0], &counterValue) |
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'm curious, can you explain why PdhGetFormattedCounterValueDouble don't need the removed code and why you are not sanitze the counter and measurment names?
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.
Sure, the previous code used PdhGetFormattedCounterArrayDouble, my version expands the counter queries to a list of individual counter queries and handle all the removed logic in different parts now. I also sanitize the names in AddItem().
sanitized_measurement := sanitizedChars.Replace(measurement)
if sanitized_measurement == "" {
sanitized_measurement = "win_perf_counters"
}
sanitized_counter := sanitizedChars.Replace(counter)
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.
Sorry my mistake
|
||
"github.com/influxdata/telegraf" | ||
"github.com/influxdata/telegraf/plugins/inputs" | ||
"github.com/influxdata/telegraf/metric" |
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.
btw do you really need telegraf/metric? I'm getting an unused import error
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.
Nope, it seems this import was inserted by my IDE prior to committing.
@bullshit I'm currently on vacation with no access to a PC. Would it be possible for me to answer in detail on saturday/sunday? Thanks for the quick turnaround. |
@vtsingaras sure no problem, have fun |
@vtsingaras i know i wanted to start from scratch and do minimum changes to the existing code. There is only one thing. For example:
telegraf is running, everything is ok. When you start chrome after telegraf you will never get a query to this instance. So if you use wildcards in your telegraf configuration we should periodically refresh the handles. I think somebody tried to fix this a while ago #2345 but it was never merged |
Hello @vtsingaras @bullshit , how can I build telefraf for windows with your latest commits? I'm on version 1.4.0 but the issue persists so I would try if possible... |
@bullshit Are you already working on it? I can make it reload the counters, add a ClearItems() func and calling ParseConfig again with locking after a configurable interval would be the easiest I think. @aventrax You can do a go get for the original repo, cd to ..../influxdata/telegraf, change the remote to point to interworkslcoud/telegraf, do a git fetch and checkout this branch and finally do a go build. Alternatively I can provide you with the build we use here, however take extra care as I don't like distributing binary builds and can guarantee neither safety and/or quality. |
@vtsingaras many thanks, anyway I do not understand where is interworkscloud:win_perf_counters-expand-wildcards. Is not on github... 😕 |
@vtsingaras Finally I have been able to checkout that fork and compile it on windows. A little nightmare. My config is the following:
|
I'm doing other tests. With this branch the asterisk is working but I noticed that Telegraf does not start if there isn't at least one process active before starting.
Here, I must open at least one notepad.exe before Telegraf, otherwise it throws an error and it crashes. @bullshit Any news regarding the periodic handles refresh? |
hi, |
This PR has been superseded by #4189 |
Required for all PRs:
Resolves conflicts against current master from: #2336