-
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
move agent metadata to a processor #9952
Changes from 1 commit
733346a
1ba4454
6f8ec6a
e6f631e
4d44f83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,12 @@ func newProcessorPipeline( | |
processors.add(makeAddFieldsProcessor("beatsMeta", meta, needsCopy)) | ||
} | ||
|
||
// setup 7: pipeline processors list | ||
// setup 7: add agent metadata | ||
if !config.SkipAgentMetadata { | ||
processors.add(makeAddAgentMetadataProcessor(info)) | ||
} | ||
|
||
// setup 8: pipeline processors list | ||
processors.add(global.processors) | ||
|
||
// setup 9: debug print final event (P) | ||
|
@@ -290,6 +295,23 @@ func makeAddDynMetaProcessor( | |
}) | ||
} | ||
|
||
func makeAddAgentMetadataProcessor(info beat.Info) *processorFn { | ||
metadata := common.MapStr{ | ||
"type": info.Beat, | ||
"ephemeral_id": info.EphemeralID.String(), | ||
"hostname": info.Hostname, | ||
"id": info.ID.String(), | ||
"version": info.Version, | ||
} | ||
if info.Name != info.Hostname { | ||
metadata.Put("name", info.Name) | ||
} | ||
return newProcessor("add_agent_metadata", func(event *beat.Event) (*beat.Event, error) { | ||
_, err := event.Fields.Put("agent", metadata) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Why use put instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch on both, will make those changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
return event, err | ||
}) | ||
} | ||
|
||
func debugPrintProcessor(info beat.Info) *processorFn { | ||
// ensure only one go-routine is using the encoder (in case | ||
// beat.Client is shared between multiple go-routines by accident) | ||
|
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.
Was not even aware we have these options 👍
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 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
andadd_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...
).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, 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) asobserver
will have other fields too.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.
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.