Skip to content
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 agent.{id,ephemeral_id} to all beat events #9404

Merged
merged 4 commits into from
Jan 3, 2019

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Dec 5, 2018

This adds the ECS fields agent.id and agent.ephemeral_id to all beats.

Heartbeat in particular needs these to execute aggregations queries in dashboards.

I could use some feedback here on the best place to add tests. AFAICT existing similar functionality for these baseline fields is not tested. Thoughts @urso ?

@andrewvc andrewvc added libbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team labels Dec 5, 2018
@andrewvc andrewvc requested a review from ruflin December 5, 2018 18:56
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime

@andrewvc andrewvc added enhancement needs_backport PR is waiting to be backported to other branches. labels Dec 5, 2018
@andrewvc andrewvc requested a review from urso December 5, 2018 18:57
Copy link
Member

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

+1 on adding this feature. @urso your input would be good here.

Name string // configured beat name
Hostname string // hostname
UUID uuid.UUID // ID assigned to beat instance
EphemeralUUID uuid.UUID // ID assigned to beat instance
Copy link
Member

Choose a reason for hiding this comment

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

We already have a ephemeral id: https://github.com/elastic/beats/blob/master/libbeat/cmd/instance/metrics_common.go#L31

Yes, not easy to find. I think here is a better place for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it already is pulled from where you mentioned (this line is the type declaration)

Copy link

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

+1 on this change.

As we convert them to strings anyway (which needs an alloc) how about changing the fields to string and name them ID and EphemeralID (yeah I know this would be a breaking change)?

@andrewvc
Copy link
Contributor Author

andrewvc commented Dec 6, 2018

@urso yeah, I'm glad to rename UUID -> EphemeralID

@andrewvc
Copy link
Contributor Author

andrewvc commented Dec 6, 2018

@urso @ruflin I've done the rename. That wound up touching a number of files FYI

Copy link
Contributor

@webmat webmat left a comment

Choose a reason for hiding this comment

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

Wearing my ECS hat, this LGTM.

I can't comment much on the Go code (although it looks good to me).

@ruflin ruflin mentioned this pull request Dec 6, 2018
@andrewvc andrewvc self-assigned this Dec 7, 2018
Copy link
Member

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

This also needs a changelog entry. Overall LGTM.

@@ -26,7 +26,8 @@ type Info struct {
Version string // The beat version. Defaults to the libbeat version when an implementation does not set a version
Name string // configured beat name
Hostname string // hostname
UUID uuid.UUID // ID assigned to beat instance
ID uuid.UUID // ID assigned to beat machine
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change thsi to beat machine from instance? This is unique for each instance.

@andrewvc
Copy link
Contributor Author

Hit a flaky test. This PR is now blocked on the SkipTest PR for that here: #9503

@andrewvc
Copy link
Contributor Author

@ruflin changelog entry added. Let me know if we're LGTM (though we'll still be blocked on the Flaky test merge)

@ruflin
Copy link
Member

ruflin commented Dec 12, 2018

@andrewvc The tests that are failing are golden files which do not seem to be up-to-date. But I could not reproduce it locally. Any chance you could rebase on master and see if it still happens?

@ruflin
Copy link
Member

ruflin commented Dec 13, 2018

@andrewvc I just realised now that the failing tests are actually correct. The reason is that we have added a new field to Beats so it affects the golden files. To update them run the following commands:

cd testing/environment
make start
cd ../../filebeat
make update && make filebeat.test
. ./build/python-env/bin/activate
INTEGRATION_TESTS=1 GENERATE=1 nosetests tests/system/test_modules.py

Hope it has no typos inside. Please let me know if you need some help with the above.

@andrewvc
Copy link
Contributor Author

@ruflin I ran those commands but it only updated some of the stuff in c246f83 . Still getting test failures: https://beats-ci.elastic.co/job/elastic+beats+pull-request+multijob-linux/2507/beat=filebeat,label=ubuntu/

@ruflin
Copy link
Member

ruflin commented Dec 14, 2018

The problem is that the agent_id and ephemeral id change every time. So we should skip these two fields. Let me fix it locally and provide you with the code.

@ruflin
Copy link
Member

ruflin commented Dec 14, 2018

Can you try to replace line https://github.com/elastic/beats/blob/master/filebeat/tests/system/test_modules.py#L189 with the following content?

    # These keys are host dependent
    host_keys = ["host.name", "agent.hostname", "agent.type", "agent.ephemeral_id", "agent.id"]

This exclude the two ids from being generated. Afterwards you need to run the command again.

@andrewvc andrewvc requested a review from a team as a code owner December 14, 2018 16:29
@ruflin
Copy link
Member

ruflin commented Dec 17, 2018

I did run the branch locally and on my end it removes the ids also from the files which still contain it in this PR. Not sure what happened? Can you run it again?

@andrewvc
Copy link
Contributor Author

@ruflin the tests were failing for me at the last line your command list (where nosetests is run). Weirdly, after trying a few things, the cause seemed to be line breaks in the formatting of the new geo.name field's description. I removed them in dd19ce0 . WFG to see if that did it.

@andrewvc
Copy link
Contributor Author

Hmmm, still getting errors on filebeat. Looks like it's still looking for agent.id?

https://beats-ci.elastic.co/job/elastic+beats+pull-request+multijob-linux/2605/

@ruflin
Copy link
Member

ruflin commented Dec 18, 2018

@andrewvc
Copy link
Contributor Author

jenkins, please retest this

@andrewvc
Copy link
Contributor Author

OK , just rebased with a make update (again).

Anything else needed here @ruflin?

FYI, this PR has a high chance of needing extra rebases due to it being sensitive to any field changes in any other beat.

Copy link
Member

@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 cleaned up the changelog but found one more change that should be reverted and needs make update afterwards.

libbeat/_meta/fields.ecs.yml Outdated Show resolved Hide resolved
@ruflin
Copy link
Member

ruflin commented Dec 27, 2018

@andrewvc Can you rebase this one?

@kuisathaverat One interesting thing I saw in this PR: It seems the Check step in the Jenkinsfile fails here because of a merge conflict. Does this mean what the Jenkinsfile tests is the PR merged with master?

@andrewvc andrewvc force-pushed the add-beat-ids-to-agent branch 2 times, most recently from 3e745a5 to 5b46ed4 Compare December 31, 2018 21:29
@kuisathaverat
Copy link
Contributor

Does this mean what the Jenkinsfile tests is the PR merged with master?

yes, the default configuration makes a merge before building the PR.

This adds the ECS fields `agent.id` and `agent.ephemeral_id` to all beats.
@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 3, 2019

Failure unrelated

@andrewvc andrewvc merged commit 700e982 into elastic:master Jan 3, 2019
@andrewvc andrewvc removed the needs_backport PR is waiting to be backported to other branches. label Jan 3, 2019
@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 3, 2019

@ruflin @urso do y'all think this should be backported at all? 7.0 does seem like a fine time to introduce this.

@ruflin
Copy link
Member

ruflin commented Jan 7, 2019

I don't see a need to backport this at the moment.

@urso
Copy link

urso commented Jan 7, 2019

No need to backport.

We found this change to break indexing if %{[beat.version]} was used. Will need to investigate why the code string formatter didn't produce an error here.

DStape pushed a commit to DStape/beats that referenced this pull request Aug 20, 2019
* Add agent.{id,ephemeral_id} to all beat events

This adds the ECS fields `agent.id` and `agent.ephemeral_id` to all beats.

* Bring back whitespace

* Use CHANGELOG.next

* Update fb tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecs enhancement libbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants