Skip to content

Add Fields and Tag to monitor config#4141

Merged
urso merged 1 commit intoelastic:masterfrom
glefloch:fix/3623
Jun 26, 2017
Merged

Add Fields and Tag to monitor config#4141
urso merged 1 commit intoelastic:masterfrom
glefloch:fix/3623

Conversation

@glefloch
Copy link
Copy Markdown
Contributor

Add Tags and fields attribute to monitor configuration.

Close #3623

@elasticmachine
Copy link
Copy Markdown
Contributor

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
@elasticmachine
Copy link
Copy Markdown
Contributor

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.

@ruflin
Copy link
Copy Markdown
Contributor

ruflin commented Apr 28, 2017

@glefloch Haven't checked the code yet, but could you add a changelog entry?

@glefloch
Copy link
Copy Markdown
Contributor Author

Oh yes for sure, I'm doing it right now

Copy link
Copy Markdown
Contributor

@ruflin ruflin left a 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?

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above.

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown

codecov bot commented May 1, 2017

Codecov Report

Merging #4141 into master will decrease coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
heartbeat/monitors/active/http/config.go 0% <ø> (ø) ⬆️
heartbeat/monitors/active/http/task.go 7.92% <0%> (-0.41%) ⬇️
metricbeat/module/system/process/process.go 57.81% <0%> (-4.69%) ⬇️
metricbeat/mb/module/wrapper.go 84.88% <0%> (-1.15%) ⬇️
filebeat/prospector/prospector.go 86.93% <0%> (ø) ⬆️
filebeat/prospector/prospector_log.go 82.31% <0%> (ø) ⬆️
filebeat/prospector/factory.go 57.89% <0%> (ø) ⬆️
filebeat/crawler/crawler.go 79.72% <0%> (ø) ⬆️
filebeat/channel/outlet.go 86.66% <0%> (ø) ⬆️
filebeat/prospector/prospector_stdin.go
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b01fa9...d9aa64c. Read the comment docs.

@glefloch
Copy link
Copy Markdown
Contributor Author

glefloch commented May 1, 2017

@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 metadata object in each monitor configuration.
Have you any ideas on how I could make this more 'common'?

@ruflin
Copy link
Copy Markdown
Contributor

ruflin commented May 3, 2017

I wast thinking perhaps somewhere around MakeJob? https://github.com/elastic/beats/blob/master/heartbeat/monitors/util.go#L92 Or probably even better around createJobTask? https://github.com/elastic/beats/blob/master/heartbeat/beater/manager.go#L241 The tricky part is how to get the config there. @urso would know more but is offline this week.

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

@ruflin ruflin added the in progress Pull request is currently in progress. label May 4, 2017
@urso
Copy link
Copy Markdown

urso commented May 11, 2017

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 MonitorTask can become a package private type + we can make it act more like the final job factory by moving createJobTask to (*MonitorTask).PrepareSchedulerJob(client publisher.Client) scheduler.TaskFunc. Then, right before PublishEvent we can apply the EventMetaData.

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.

@glefloch
Copy link
Copy Markdown
Contributor Author

@urso Thanks for those explanation. I'm going to do what you said and I will push that up.

@elasticmachine
Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

@glefloch
Copy link
Copy Markdown
Contributor Author

glefloch commented Jun 5, 2017

I finally got time to work on this. Thanks @urso, your solution is way muck cleaner.

@tsg
Copy link
Copy Markdown
Contributor

tsg commented Jun 6, 2017

@glefloch For the make check failure, you need to run goimports on the source code. Thanks a lot for contributing!

@glefloch
Copy link
Copy Markdown
Contributor Author

glefloch commented Jun 6, 2017

@tsg thanks, I ran make check and fixed code format.

@glefloch glefloch force-pushed the fix/3623 branch 2 times, most recently from 5cd9516 to 70e97b6 Compare June 8, 2017 08:32
Copy link
Copy Markdown

@urso urso left a 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?

Copy link
Copy Markdown

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...

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Contributor Author

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?

@glefloch
Copy link
Copy Markdown
Contributor Author

glefloch commented Jun 9, 2017

Thanks for the review @urso, I'm going to fix your comments and check the test as well.

@tsg
Copy link
Copy Markdown
Contributor

tsg commented Jun 12, 2017

@glefloch Travis complains about the latest version. Is that test passing locally for you?

@glefloch
Copy link
Copy Markdown
Contributor Author

@tsg actually, when I run INTEGRATION_TESTS= TESTING_ENVIRONMENT=latest make -C heartbeat testsuite everything looks good but no python tests are ran.. So I'm not able to fix the tests... I'm looking for a fix on my machine.

@glefloch
Copy link
Copy Markdown
Contributor Author

@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 TEST_ENVIRONMENT=0 it seems that something did not answer within 10min on testsuite initialization.
Is it possible to restart test?

@glefloch
Copy link
Copy Markdown
Contributor Author

@tsg, I rebase master and all check are ok. Can you check this PR again?

@urso urso added needs_docs and removed in progress Pull request is currently in progress. labels Jun 26, 2017
@urso urso merged commit be38ce2 into elastic:master Jun 26, 2017
@urso
Copy link
Copy Markdown

urso commented Jun 26, 2017

Merged. Thanks for you patience and time getting this change in.

@glefloch glefloch deleted the fix/3623 branch June 26, 2017 12:18
@glefloch
Copy link
Copy Markdown
Contributor Author

You're welcome that was a pleasure to implement this feature.

@dedemorton dedemorton mentioned this pull request Jul 25, 2017
42 tasks
@dedemorton
Copy link
Copy Markdown
Contributor

Removing need_docs tag. Docs were added in #4753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants