-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Perfmon wildcard queries #4502
Perfmon wildcard queries #4502
Conversation
Hi @maddin2016, we have found your signature in our records, but it seems like you have signed with a different e-mail than the one used in yout Git commit. Can you please add both of these e-mails into your Github profile (they can be hidden), so we can match your e-mails to your Github profile? |
Can one of the admins verify this patch? |
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically on build-eu-00. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Hey @andrewkroh, @ruflin. Sorry for the delay. I added the function to perform wildcard queries. I just check if the path contains
Maybe you have any other suggestions. |
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 continuing to improve the perfmon metricset!
There is a binary file (metricbeat/debug
) in the PR that I think was added accidentally.
} | ||
defer handle.query.Close() | ||
|
||
values, err := handle.Read() |
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 is the error not checked? If you intentially are going to ignore an error then I recommend writing the assignment as values, _ := handle.Read()
to be clear that it was intentional.
println(k) | ||
} | ||
|
||
if m, n := values["processor"].(common.MapStr); n { |
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.
If processor
or processor.time
or processors.time.pct
are not found, should this be a test failure? I'm pretty sure this block could be simplified to:
pcts, err := values.GetValue("processors.time.pct`)
if err != nil {
t.Fatal(err)
}
assert.NotEmpty(t, pcts)
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.
VS Code Intellisense wasn't working 😄 That's what i've searched for.
} | ||
|
||
for k, _ := range values { | ||
println(k) |
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.
Use t.Log()
so that the -v
flag is honored for tests.
@@ -77,6 +80,26 @@ func PdhGetFormattedCounterValue(counter PdhCounterHandle, format PdhCounterForm | |||
return counterType, &value, nil | |||
} | |||
|
|||
func PdhGetFormattedCounterArray(counter PdhCounterHandle, format PdhCounterFormat) (int, *[]PdhCounterValueItem, 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.
Why not return []PdhCounterValueItem
instead of a *[]PdhCounterValueItem
?
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.
Also I don't think it should return the int
when that can be obtained using len()
on the returned slice.
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.
After looking at the PdhCounterValueItem
and how it's used, I think it would be best to return a different struct that has the a Name
field that is a string
. This way the users of the method don't need to follow the pointer and convert the UTF16 bytes to UTF8.
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.
The returned slice is larger. So we need the bufferCount
value to iterate over the slice to get the items which has a value.
) | ||
|
||
var ( | ||
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) |
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 don't see where this is used?
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.
This is coming from go generate
. I think its since go 1.8.x
.
Because the are separate instances of the same counter it seems like each instance should be its own event so that they can easily be compared to each other like apples to apples. For example you might want to create a line graph showing diskio for C, D, and E all at once. Having a data structure similar to what we have now with the non-wildcard would make this easier. But a field would need to be added specifying the instance name (like C, D, or E).
So maybe in the config you have something like:
|
@andrewkroh, thanks for your comments. Based on this i have changed the logic and fixed the test. To do is to separate the instances. |
Maybe we should make this config standard. Lets take the following config
This would produce the following output
So here perfmon produce only one value What do you think about? |
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.
Yes, I think having a single way to configure all the counters is more clear to the user.
break | ||
} | ||
} | ||
runes := utf16.Decode(a[:size:size]) |
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.
That second size
should be unnecessary as that is the capacity, right?
|
||
for i = 0; i < bufferCount; i++ { | ||
value := CounterValueItem{} | ||
a := (*[1<<30 - 1]uint16)(unsafe.Pointer(pdhValues[i].SzName)) |
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.
We should try to find a more "safe" way to do this in the future. Using the unsafe pointer to cast an arbitrary size array worries me. But that's for another PR another time. :)
@@ -80,24 +85,43 @@ func PdhGetFormattedCounterValue(counter PdhCounterHandle, format PdhCounterForm | |||
return counterType, &value, nil | |||
} | |||
|
|||
func PdhGetFormattedCounterArray(counter PdhCounterHandle, format PdhCounterFormat) (int, *[]PdhCounterValueItem, error) { | |||
func PdhGetFormattedCounterArray(counter PdhCounterHandle, format PdhCounterFormat) ([]CounterValueItem, 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.
That looks better.
@andrewkroh, tests are passing on my local machine. Can you please run the tests again. Thanks! |
jenkins, test it |
Ok, I triggered a rebuild of AppVeyor and Jenkins. |
What is this |
I'm seeing it fail before getting to
But |
22d7493
to
60dabc5
Compare
🙈 This happens if you work on 3 different machines 😑 |
|
🎉 Thanks! |
`alias` was removed in elastic#4502.
Add the possibility to perform wildcard queries for instances. See #3828