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

[Heartbeat] Migrate to ECS url.* fields for 7.0.0 Release #9570

Merged
merged 1 commit into from
Jan 10, 2019

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Dec 14, 2018

This PR migrates a number of different heartbeat fields to their ECS counterparts in the url.* namespace.

This now adds url.full for all monitor types. It's still WIP since the tests haven't been updated, but I wanted to makes sure what it does is correct.

@andrewvc andrewvc added enhancement in progress Pull request is currently in progress. Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team labels Dec 14, 2018
@andrewvc andrewvc requested a review from a team as a code owner December 14, 2018 20:15
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime

webmat
webmat previously approved these changes Dec 14, 2018
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.

LGTM :-)

@webmat webmat dismissed their stale review December 14, 2018 20:24

Reviewed too fast. The mapping is good, but the work isn't done ;-)

@andrewvc andrewvc mentioned this pull request Dec 18, 2018
7 tasks
@andrewvc
Copy link
Contributor Author

@ruflin ready to have a look taken at the code even though tests are broken.

@andrewvc andrewvc changed the title WIP Add monitor.url move [Heartbeat] Add monitor.url move Jan 1, 2019
@urso urso removed the request for review from a team January 2, 2019 15:19
@andrewvc andrewvc added review and removed in progress Pull request is currently in progress. labels Jan 3, 2019
@andrewvc andrewvc requested a review from a team as a code owner January 4, 2019 19:37
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.

Does this PR also need a changelog entry?

@@ -625,3 +625,8 @@
to: event.dataset
alias: false
comment: No alias mapping as field did not always exist

- from: http.url
Copy link
Member

Choose a reason for hiding this comment

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

I would also expect a change to the fields.yml file that introduces this alias?

Also in the code I couldn't find where http.url is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now it's just being duplicated and we're relying on ECS to provide that field as a non-alias.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going to keep the original http.url field present and just copy its value, you should remove the entry from ecs-migration.yml.

Copy link
Member

Choose a reason for hiding this comment

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

It should still show up here if we potentially need to migrate this in the dashboards.

But in case we keep the old field around, alias: true should be set to false as we can't create an alias for the old field.

@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 8, 2019

@ruflin @webmat OK, so I took this a lot further and refactored all the monitors to use the url.* namespace in ECS extensively.

This actually cleans up the code in heartbeat quite a bit, which is a good sign I think! It lets a lot of the event field population happen at a high level (before the task is started) rather than deep in the bowels of the event's execution, and lets it happen consistently with a couple simple helper functions.

This is of course a 7.0.0 only change, and breaks cases where people use fields directly. I made an effort to alias all the moved fields and document them as well.

heartbeat/_meta/fields.common.yml Show resolved Hide resolved
dev-tools/ecs-migration.yml Show resolved Hide resolved
dev-tools/ecs-migration.yml Outdated Show resolved Hide resolved
@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 8, 2019

@ruflin I believe I've addressed all of your concerns

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.

Looking good overall.

However you shouldn't list http.url as aliased to url.full in ecs-migration.yml, if it's only copied. Unless I misunderstand something about this?

"github.com/elastic/beats/libbeat/common"
)

func TestURLFields(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️ this whole test file

@@ -625,3 +625,8 @@
to: event.dataset
alias: false
comment: No alias mapping as field did not always exist

- from: http.url
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going to keep the original http.url field present and just copy its value, you should remove the entry from ecs-migration.yml.

@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 9, 2019

@webmat I changed this PR since I first wrote it. Now there are no copies. Just aliases, so this is a breaking change for 7.0.0.

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.

What I would like to see in the changelog is having pairs of field old -> new to easily follow what changed. So if someone had queries on these fields and looks at the changes, it's very easy for him to decide what to rename it to. Yes, the ecs-migration.yml would also be there for a look up but I don't expect users to check there. Also having it in the PR description would be nice as we do for other ECS migration PR's.

In metricbeat we create these data.json with example events: https://github.com/elastic/beats/blob/master/metricbeat/module/elasticsearch/index_recovery/_meta/data.json We use these also in the docs. This would be super nice for Heartbeat to have and would make it more obvious what things change in such PR's. No need to add something like this in this PR but an idea for the future.

heartbeat/_meta/fields.common.yml Show resolved Hide resolved
heartbeat/hbtest/hbtestutil.go Outdated Show resolved Hide resolved
@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 9, 2019

@ruflin I think I've addressed all concerns here aside from the data.json. +1 to doing that at a future time.

@andrewvc andrewvc changed the title [Heartbeat] Add monitor.url move [Heartbeat] Migrate to ECS url.* fields for 7.0.0 Release Jan 9, 2019
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.

LGTM

The field by field explicit listing of the fields migrated is way out of scope for this. We should just generate one massive (and extremely boring) documentation file for the website, to list them.

@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 9, 2019

Thanks @webmat ! FWIW I did add that to the changelog already.

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.

LGTM

Left 2 more minor comments but can be addressed in a follow up PR.

Could you after merge update the PR description as at the moment it's not fully in line with what we have in the final PR.

description: >
Service url used by monitor.
multi_fields:
Copy link
Member

Choose a reason for hiding this comment

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

The type of the field changed here because of ECS. It means we don't have the indexed field anymore (text). Should this also be mentioned somewhere?

This field encodes a full URL version of the monitor, and adds URL encodings for HTTP, TCP, and ICMP.

Fix tests, unify host behavior

Use all ECS URL fields

Alias heartbeat fields to ECS ones

Refactor URL assignment

Fix failing tests

Add changelog entry

Add required comments

Fix PY testS

Improve docs

Fix samples

Minor improvements to migration yml

Fix imports

Incorporate PR feedback

Don't ignore URL parse errors

Make update
@andrewvc
Copy link
Contributor Author

Failures unrelated

@andrewvc andrewvc merged commit 529feda into elastic:master Jan 10, 2019
andrewvc added a commit to andrewvc/beats that referenced this pull request Jan 10, 2019
Continues the work in elastic#9570 , aliasing this field for convenience.
In ECS this field is already a keyword, so this should be fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Heartbeat review 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.

5 participants