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

Refactor add_cloud_metadata processor to improve ECS fields handling #26337

Closed
ChrsMark opened this issue Jun 16, 2021 · 3 comments · Fixed by #26438
Closed

Refactor add_cloud_metadata processor to improve ECS fields handling #26337

ChrsMark opened this issue Jun 16, 2021 · 3 comments · Fixed by #26438
Assignees
Labels
Team:Integrations Label for the Integrations team

Comments

@ChrsMark
Copy link
Member

ChrsMark commented Jun 16, 2021

We can reorganize this processor so the fetchers return the cluster data under the cloud name and the orchestrator data under orchestrator, so we don't need to make so much mangling of this meta.

Originally posted by @jsoriano in #26056 (comment)

We could change the format of the metadata that are returned to sth like this:

{
"cloud": {},
"orchestrator": {},
"other.ecs.fields": {},
}

With this, the data manipulation at

func (p *addCloudMetadata) Run(event *beat.Event) (*beat.Event, error) {
meta := p.getMeta()
if len(meta) == 0 {
return event, nil
}
// If cloud key exists in event already and overwrite flag is set to false, this processor will not overwrite the
// cloud fields. For example aws module writes cloud.instance.* to events already, with overwrite=false,
// add_cloud_metadata should not overwrite these fields with new values.
if !p.initData.overwrite {
cloudValue, _ := event.GetValue("cloud")
if cloudValue != nil {
err := p.extractECSMeta(event, meta)
if err != nil {
return nil, err
}
return event, nil
}
}
err := p.extractECSMeta(event, meta)
if err != nil {
return nil, err
}
_, err = event.PutValue("cloud", meta)
return event, err
}
would be more smooth.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 16, 2021
@ChrsMark ChrsMark added the Team:Integrations Label for the Integrations team label Jun 16, 2021
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@ChrsMark ChrsMark self-assigned this Jun 16, 2021
@ChrsMark
Copy link
Member Author

ChrsMark commented Jun 16, 2021

@kaiyan-sheng I'm assigning this to myself but feel free to pick it up if you have free cycles.

@kaiyan-sheng
Copy link
Contributor

@ChrsMark It's all yours!! Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants