-
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
Add Fields and Tag to monitor config #4141
Conversation
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
1 similar comment
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
@glefloch Haven't checked the code yet, but could you add a changelog entry? |
Oh yes for sure, I'm doing it right now |
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 haven't looked into it yet but I was kind of hoping we could add the meta data either in monitors
package or even beater
package as it is generic for all monitors. The way it is added at the moment it has to be implemented for each monitor. Means if someone adds a new monitor the code also has to be added.
Can you check if there is an option to add the code on a more global level?
@@ -46,6 +46,22 @@ heartbeat.monitors: | |||
# Waiting duration until another ICMP Echo Request is emitted. | |||
wait: 1s | |||
|
|||
# The tags of the monitors are included in their own field with each |
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 must be added to heartbeat/_meta/beat.full.yml
and then you have to run make update
.
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.
Ok, I'm reverting those modifications.
heartbeat/heartbeat.full.yml
Outdated
@@ -119,6 +135,22 @@ heartbeat.monitors: | |||
# Required TLS protocols | |||
#supported_protocols: ["TLSv1.0", "TLSv1.1", "TLSv1.2"] | |||
|
|||
# The tags of the monitors are included in their own field with each |
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 suggest we add it only to one monitor (first one) as an example and not every single one.
heartbeat/heartbeat.full.yml
Outdated
@@ -189,6 +221,22 @@ heartbeat.monitors: | |||
# Required response contents. | |||
#body: | |||
|
|||
# The tags of the monitors are included in their own field with each |
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 comment above.
@@ -71,6 +71,12 @@ func create( | |||
} | |||
|
|||
settings := monitors.MakeHostJobSettings(jobName, host, config.Mode) | |||
metadata, e := monitors.AddMetadata(config.EventMetadata) |
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.
Can you call it err
instead of e
to be consistent with most of the other code?
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 will update the name.
Codecov Report
@@ Coverage Diff @@
## master #4141 +/- ##
==========================================
- Coverage 64.64% 64.59% -0.05%
==========================================
Files 490 491 +1
Lines 34392 34440 +48
==========================================
+ Hits 22233 22247 +14
- Misses 10159 10188 +29
- Partials 2000 2005 +5
Continue to review full report at Codecov.
|
@ruflin, I was expecting the same thing before starting working on this issue. But there I didn't found any common configuration object between monitors, that's why I added the |
I wast thinking perhaps somewhere around BTW: This should also be added to the docs under the common config options: https://github.com/elastic/beats/blob/master/heartbeat/docs/reference/configuration/heartbeat-options.asciidoc |
The common configurations for monitors are currently 'implicit' in code (no special type), as originally I have had only one field to load from: See here With us adding more fields, this should become it's own type. All settings are added to MonitorTask. Not sure, but I think I didn't touch any of this code yet, as we were planning to redo the reloading functionality, to resemble filebeat/metricbeat conf.d support. |
@urso Thanks for those explanation. I'm going to do what you said and I will push that up. |
Can one of the admins verify this patch? |
I finally got time to work on this. Thanks @urso, your solution is way muck cleaner. |
@glefloch For the |
@tsg thanks, I ran make check and fixed code format. |
5cd9516
to
70e97b6
Compare
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.
Code change looks quite clean, but I left you 2 minor comments.
Great you also added an integration test. Much appreciated. But checking travis, the test seem to have failed. Any idea why?
heartbeat/beater/manager.go
Outdated
name := m.config.Name | ||
if name == "" { | ||
name = m.config.Name | ||
} |
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 name never changes. we can move this line before returning the func and execute the check only once instead of per event/run...
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 are right, I move it on top of the return
heartbeat/beater/manager.go
Outdated
err := common.MergeFields(event, m.config.EventMetadata.Fields, m.config.EventMetadata.FieldsUnderRoot) | ||
if err != nil { | ||
logp.Err("Failed to merge fields: %v", err) | ||
return nil |
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 really want to stop the job by returning here? How 'fatal' is an error when adding fields? e.g. we still want to try to report the original event if this op failed? MergeFields
only errors if some field can not be spliced into, because some supposed to be intermediate object is an actual leaf/primitive value.
Normall If len(next) > 0
, more followup tasks will be executed to finish the final job. We want to kill the job on 'naming' conflicts in MergeFields?
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.
Well, you right, should we also ignore errors on while add tags?
Thanks for the review @urso, I'm going to fix your comments and check the test as well. |
@glefloch Travis complains about the latest version. Is that test passing locally for you? |
@tsg actually, when I run |
@tsg, heartbeat testsuite is ok, but filebeat testsuite got broken because of a timeout with elasticsearch... There is also a weird error with the heartbeat testsuite using |
@tsg, I rebase master and all check are ok. Can you check this PR again? |
Merged. Thanks for you patience and time getting this change in. |
You're welcome that was a pleasure to implement this feature. |
Removing need_docs tag. Docs were added in #4753 |
Add Tags and fields attribute to monitor configuration.
Close #3623