Skip to content

Conversation

@isaacaflores2
Copy link
Contributor

@isaacaflores2 isaacaflores2 commented Dec 8, 2025

Overview

This PR adds the initial clientaddrmiddleware extension implementation which just includes the configuration, factory and middleware interface implementation.

Currently both confighttp and configgrpc set the client address based only one value RemoteAddress or peer address respectively. This middleware provides the flexibility to determine the client address (client.Info.Addr) from metadata keys.

Enables custom processors such as the elasticapmprocessor to enrich events with client IP address. See PR: #924.

@isaacaflores2 isaacaflores2 requested a review from a team as a code owner December 8, 2025 19:28
// ClientAddressMetadataKeys list of metadata keys to determine the client address.
// Keys are processed in order, the first valid value is used to set the client address.
// If there are no valid addresses found, the client address is not updated.
ClientAddressMetadataKeys []string `mapstructure:"client_address_metadata_keys,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

nit: MetadataKeys should suffice IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call updated to metadata_keys

Receivers should be configured with `include_metadata: true`, so that the context includes client metadata keys.

### Example
The following example configures the middleware to set the client address based on the the `x-forwareded-for` metadata key (header).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The following example configures the middleware to set the client address based on the the `x-forwareded-for` metadata key (header).
The following example configures the middleware to set the client address based on the the `x-forwarded-for` metadata key (header).

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

Thanks!

@isaacaflores2 isaacaflores2 merged commit cd9a3f1 into elastic:main Dec 9, 2025
13 checks passed
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.

3 participants