Skip to content

move agent metadata to a processor#9952

Merged
graphaelli merged 5 commits intoelastic:masterfrom
graphaelli:agent-meta-processor
Jan 9, 2019
Merged

move agent metadata to a processor#9952
graphaelli merged 5 commits intoelastic:masterfrom
graphaelli:agent-meta-processor

Conversation

@graphaelli
Copy link
Copy Markdown
Member

and make it disable-able

and make it disable-able
@graphaelli graphaelli requested a review from a team as a code owner January 8, 2019 16:03
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 was initially thinking that the processor would decide to write the fields or not based on if agent object exists or not but having it as an option in the pipeline is probably even more efficient.

LGTM

@urso WDYT?


// By default events are decorated with agent metadata.
// To skip adding that metadata set this to true.
SkipAgentMetadata bool
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.

Was not even aware we have these options 👍

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 settings 'Fields', 'Meta', 'EventMetadata', 'DynamicFields' are legacy fields we will remove in the future in favor of processors (I'm in the middle of introducing add_fields and add_tags processor).

I think I'd prefer to be able to set the agent metadata in the pipeline constructor, and have this optionally be empty in comparison to build more logic/support for the client to change/overwrite global settings. But I know it's not really possible yet to 'influence' the constructor.

By introducing SkipAgentMetadata we loose the Beats meta-data always. Is this really intended? I wonder if we want to change but the beats agent meta-data into another namespace (e.g. collector.agent...).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

By introducing SkipAgentMetadata we loose the Beats meta-data always. Is this really intended?

Yes, for APM we never want libbeat to set these fields, even if apm-server hasn't set them.
Another namespace would be fine for the APM case, as we had planned to put them under observer. In that case, we'd want these to be merged (overwrite would be fine even) as observer will have other fields too.

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.

Perhaps we can later put the Beat info under @metadata so apm-server could still fetch it.

I suggest for now to move forward with this as the only customer of this for now will be apm-server and we can still improve it later. On the Beats side this should not change anything.

* skip agent adding agent metadata by default
* test adding agent metadata
Copy link
Copy Markdown
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

metadata.Put("name", info.Name)
}
return newProcessor("add_agent_metadata", func(event *beat.Event) (*beat.Event, error) {
_, err := event.Fields.Put("agent", metadata)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use metadata.Clone() or pass the needsCopy bool to make sure you don't need to clone. If user adds processors adding/removing fields from the agent namespace beats will panic here or in the json encoder due to concurrent access.

Why use put instead of (Deep)Update? This is another change in semantics. With put you overwrite agent, while update (old behavior) would merge the contents if metadata if agent is already known to Fields.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch on both, will make those changes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

@graphaelli
Copy link
Copy Markdown
Member Author

jenkins, retest this please

@urso
Copy link
Copy Markdown

urso commented Jan 9, 2019

I forgot, but can you please add an entry to Changelog.next.developer.asciidoc?

@graphaelli graphaelli merged commit 2e2c62b into elastic:master Jan 9, 2019
@graphaelli graphaelli deleted the agent-meta-processor branch January 9, 2019 17:34
@ruflin ruflin mentioned this pull request Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants