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

[processor/geoip] Detect source.address from signal's attributes #34036

Open
rogercoll opened this issue Jul 11, 2024 · 3 comments
Open

[processor/geoip] Detect source.address from signal's attributes #34036

rogercoll opened this issue Jul 11, 2024 · 3 comments
Labels
enhancement New feature or request processor/geoip

Comments

@rogercoll
Copy link
Contributor

rogercoll commented Jul 11, 2024

Component(s)

processor/geoip

Is your feature request related to a problem? Please describe.

The current GeoIP processor looks for the source.address field in the resource attributes of every signal. The processor should be able to detect the IP from other contexts too, for example, the source.address might be located in the attributes instead of the identifying resource attributes.

Describe the solution you'd like

Detect the IP from the signal's attributes if not present in the resource ones, and add the corresponding geographical attributes to the same context.

Describe alternatives you've considered

No response

Additional context

No response

@rogercoll rogercoll added enhancement New feature or request needs triage New item requiring triage labels Jul 11, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@crobert-1
Copy link
Member

Makes sense to me, and was filed by a code owner, removing needs triage.

One thing to note: The README currently specifies that source.address is taken from the resource attributes. This will need updated as a part of this change. (You're probably already aware, just wanted to point it out so we don't miss it 👍)

@crobert-1 crobert-1 removed the needs triage New item requiring triage label Jul 11, 2024
@rogercoll
Copy link
Contributor Author

In order to let the user configure whether to look in the resource attributes or the signal's attributes (in the future could be any other source), I purpose to add the following configuration structure in the processor.

geoip:
  source:
    from: resource_attributes

The source configuration option would tell the processor whether to look for the source.address from the resource_attributes or attributes. The configuration naming is similar to the k8sattributes processor.

I think being a map configuration option would ease the addition of future options for narrowed IP look ups, for example, specifying a different attribute name to override the default source.address:

geoip:
  source:
    from: attributes
    name: upstream.address

andrzej-stencel added a commit that referenced this issue Aug 19, 2024
**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

- Adds a `source.from` configuration option to let the user define where
the IP address will be looked for.
- Adds the `attribute` source.from option. IP address can be located in
the inner signal's attributes, thus adding the geographical attributes
accordingly.
- Decouples the signals processing in `geoip_processor_metrics.go`,
`geoip_processor_traces.go` and `geoip_processor_logs.go`. Polymorphism
could not be applied due to their different types and iteration
mechanism, with Go `1.23` we could undo this changes in favor of a
`pcommon.Map` iterator.


**Link to tracking Issue:** <Issue number if applicable>
#34036

**Testing:** <Describe what testing was performed and which tests were
added.>
- Removes the manual generation of testing signals in favor of
`testdata` + golden checks. The same test cases are applied for unit and
integration tests.

**Documentation:** <Describe the documentation added.> README.md updated

---------

Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Co-authored-by: Andrzej Stencel <andrzej.stencel@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request processor/geoip
Projects
None yet
Development

No branches or pull requests

2 participants