-
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
Do not build internal metrics without CGO #6501
Do not build internal metrics without CGO #6501
Conversation
"github.com/elastic/beats/libbeat/logp" | ||
) | ||
|
||
var ( |
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 we move the ephemeralID part to a third file which gets compile on all platforms? Like this we can make sure we only have to change it in one place.
Metrics reporting should work for the Windows binaries where cgo isn't used. The build tags in metrics.go are
which is
Then over in |
I think we must have a test case to verify that xpack monitoring metrics are working correctly in the released binaries. I don't get a strong confidence from evaluating the build tags in my head against how I think they are set during the builds. A good place to add this would be beats-tester. As you can see on Jenkins we have the log output from each Beat on each platform. The log contains a message like "Total non-zero metrics" that has all the monitoring metrics. We can parse this JSON log message and assert that it contains all of the correct fields as well as the The assertions need to be written twice, once for posix and once for Windows. The two places where it needs added are:
As an example you can use this which collects the line of interest into a variable, parse the data as JSON, then asserts that the object contains particular fields. |
95af99a
to
4d7c8b8
Compare
I updated the branch with build tags I believe to be correct. :) I am still working on adding the assertions to Beats tester. @andrewkroh thanks for the pointers |
I'm wondering if we should merge it as is and then run beats-tester to verify the change or have the beats-tester changes first? I'm good with both options. |
@kvch I added the backport label as I assume the change is also needed for 6.2? |
Thanks for adding the tag. It's definitely needed in 6.2. I would wait for beats-tester. I am running it locally right now to validate changes. I would be more comfortable with merging this after it is validated. |
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 happy to help with the beats-tester changes if you want to pair up over Zoom.
libbeat/cmd/instance/metrics.go
Outdated
@@ -1,5 +1,4 @@ | |||
// +build darwin linux windows | |||
// +build cgo | |||
// +build darwin,cgo freebsd,cgo openbsd,cgo linux windows |
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 would leave openbsd off the list because ProcTime and ProcMem are not supported in gosigar.
@@ -1,8 +1,11 @@ | |||
// +build !darwin,!linux,!windows darwin,!cgo linux,!cgo windows,!cgo | |||
// +build darwin,!cgo freebsd,!cgo openbsd,!cgo |
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.
Definitely double check my work, but I think we have a different set of built tags.
From metrics.go (without openbsd):
(darwin AND cgo) OR (freebsd AND cgo) OR linux OR windows
Negating this and simplifying it:
!((darwin AND cgo) OR (freebsd AND cgo) OR linux OR windows)
!(darwin AND cgo) AND !(freebsd AND !cgo) AND !linux AND !windows
(!darwin OR !cgo) AND (!freebsd OR !cgo) AND !linux AND !windows
Conversion to build tags:
// +build !darwin !cgo
// +build !freebsd !cgo
// +build !linux,!windows
I opened a PR for Beats tester: elastic/beats-tester#74 |
I kicked off a beats-tester job with the updated test cases. https://beats-ci.elastic.co/job/elastic+beats-tester+master/172/ We should see it fail until this PR gets merged. 👀 |
8a12185
to
5aea756
Compare
We found a secondary problem with the new tests we added. See elastic/beats-tester#74 (comment). |
Looking at the errors there also seem to be an error related to this change:
|
@ruflin The error you pasted here is expected. Right now on master the registry named "beat" is not added in case of winlogbeat or anything crosscompiled. This PR fixes that problem, because it adds the registry even if system and beat metrics are not supported on a platform. I would merge this PR now. The other test failures are orthogonal to this PR as @andrewkroh pointed it out. So it should not be blocked. |
libbeat/cmd/instance/metrics.go
Outdated
) | ||
|
||
func init() { | ||
beatMetrics := monitoring.Default.NewRegistry("beat") | ||
systemMetrics = monitoring.Default.NewRegistry("system") | ||
ephemeralID = uuid.NewV4() |
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 ephmeralID init is not needed here anymore I think.
Ok, left a minor comment. Could you also add a CHANGELOG entry? |
5aea756
to
2e4e18b
Compare
2e4e18b
to
e18db5d
Compare
Nice catch! Thanks for the review @ruflin |
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.
WFG
This should be back-ported in case we release a 6.2.4. |
I am doing that now. :D |
* libbeat: build internal metrics on windows and linux without cgo * libbeat: add ephemeral id even if no internal memory metrics is reported * fix incorrect build tags && create common file for all platforms
* libbeat: build internal metrics on windows and linux without cgo * libbeat: add ephemeral id even if no internal memory metrics is reported * fix incorrect build tags && create common file for all platforms
Gosigar only requires CGO for Darwin, FreeBSD and OpenBSD. If someone compiles Beats on these platforms without CGO, metrics are not supported.
Add ephemeral ID to Beats which don't report internal memory usage, etc. So it can still show up in Monitoring UI.