Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Add "elastic-agent' product origin header when running under the Elastic agent. #66

Open
cmacknz opened this issue Jan 25, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.5.0

Comments

@cmacknz
Copy link
Member

cmacknz commented Jan 25, 2022

Describe the enhancement:

In elastic/beats#29966 the Elastic product origin header was added to all requests made to Elasticsearch with the hard coded value "beats". When the code involved is used by or run under the Elastic agent the header value should be changed to "elastic-agent" to properly attribute the source of the request.

This will require adding a new value to the list of known product origins, currently defined here: https://github.com/elastic/kibana/blob/main/x-pack/plugins/upgrade_assistant/common/constants.ts#L50

Describe a specific use case for the enhancement or feature:

Requests made by or under the supervision of the Elastic agent should not be attributed to the beats product.

@cmacknz cmacknz added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jan 25, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@cmacknz cmacknz added the enhancement New feature or request label Jan 25, 2022
@jlind23 jlind23 added the good first issue Good for newcomers label Jan 26, 2022
@jlind23
Copy link
Contributor

jlind23 commented Jan 26, 2022

@cmacknz with Elastic Agent moving to its own repository, the impact mentioned may be a little bit different right?
@narph it may be interesting for your current move.

@cmacknz
Copy link
Member Author

cmacknz commented Jan 26, 2022

Possibly the repository move would affect this, but if we want to distinguish between beats run under agent and beats run stand alone there would still be a change to beats.

@cmacknz
Copy link
Member Author

cmacknz commented Feb 24, 2022

The simplest way to deal with this is to use the "elastic-agent" header for connections from the shipper. If that doesn't cover all our interactions with Elasticsearch we can open a follow up issue.

@cmacknz
Copy link
Member Author

cmacknz commented Jun 21, 2022

Spotted this in progress and this issue is pretty old relative to the shipper. Just to clarify

The simplest way to deal with this is to use the "elastic-agent" header for connections from the shipper

The connection I was referencing there is from the shipper to Elasticsearch. We can just hard code the product origin header of the shipper's Elasticsearch output to "elastic-agent" since that is the only place it runs.

The existing ES client takes a list of Headers to attach to every request: https://github.com/elastic/beats/blob/7b99a8ec45729107d47f397ec3976f6d0b483903/libbeat/esleg/eslegclient/connection.go#L71

It looks to ensure the product origin header is set and defaults it to beats if it isn't set.
https://github.com/elastic/beats/blob/7b99a8ec45729107d47f397ec3976f6d0b483903/libbeat/esleg/eslegclient/connection.go#L127-L131

When we complete #10 all we should need to do is set the header appropriately when creating the client and we should be done.

The only additional thing to do is make Kibana actually under the "elastic-agent" header: https://github.com/elastic/kibana/blob/726ea2823bdda5f29bf1e1980dfdb53fa0691ebf/x-pack/plugins/upgrade_assistant/common/constants.ts#L38. We can consider doing this now so it gets released by the time the shipper is ready. We could consider reporting ourselves as "fleet" as well to use something that is already defined.

@cmacknz cmacknz transferred this issue from elastic/beats Jun 21, 2022
@cmacknz
Copy link
Member Author

cmacknz commented Jun 21, 2022

Moved to the shipper repository since this is where we should implement this.

@jlind23
Copy link
Contributor

jlind23 commented Jul 4, 2022

@cmacknz moving this out of 8.4 following your conversation with @rdner

@jlind23 jlind23 added v8.5.0 and removed v8.4.0 labels Jul 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team v8.5.0
Projects
None yet
Development

No branches or pull requests

4 participants