-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[processor/dnslookup] Add log processing and host file resolver #40910
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
base: main
Are you sure you want to change the base?
Conversation
…tor-contrib into dnslookup_basic_op
update readme description
- `record`: Attributes within a data point, log record or a span. | ||
- `source_attributes`: An array of attribute names, which are used for lookup. The first valid hostname/IP is used. | ||
- [`source.address`](https://github.com/open-telemetry/semantic-conventions/blob/v1.32.0/docs/general/attributes.md#source) is the default for forward resolution. | ||
- `source.ip` is the default for reverse resolution. |
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.
Did you consider network.peer.address? See here for an example: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-client-server-example.
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.
*_address
in semconv can be IP or hostname. Ideally, an attribute dedicated solely to the IP address would be great. I am not sure "network.peer" is the right description to store the resolved IP.
If you think network.peer
is better than creating a new attribute, I can change it.
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.
I think that makes sense for HTTP, but in the DNS context, the peer
part would make it confusing IMO, as it's not the DNS server's peer address we're referring to on this config.
Co-authored-by: Andrzej Stencel <[email protected]>
@edmocosta I have discussed with Andrzej that this is the minimum testable processor and he agreed to move on base on the current functionality. A noop resolver is added to temporarily replace the default resolver. This is ready for your review. |
|
||
// LookupConfig defines the configuration for forward/reverse DNS resolution. | ||
type LookupConfig struct { | ||
Enabled bool `mapstructure:"enabled"` |
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.
Do we need to support this Enabled
config? If the lookup is configured, it's enabled, otherwise users could just remove/comment it on their configuration.
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.
My concern is the default value for Resolve and Reverse. Typically, a processor has default values and semconv attributes to simplify user configuration.
lookup | source_attributes | target_attribute |
---|---|---|
Resolve | "source.address" | "source.ip" |
Reverse | "source.ip" | "source.address" |
Without enabled
, two lookups overwrite each other's result. Therefore I set enabled: false
to Reverse.
For consistency, I avoid to set empty default for Reverse, while Reverse has values.
If no default values for Resolve and Reverse, I think enabled
can be removed, but I am not sure it is the right way to go. Having enabled
flag is handy to quickly turn on/off some features.
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 I agree, but considering those are different operations, and that we don't actually know which one the user wants, I wouldn't enabled any lookup by default, and I would enforce them to be explicit set on the config.
Regarding the defaults, we could probably reach similar results by using the source_attributes
and target_attribute
default values at code level, making them optional config keys.
I personally find something like:
dnslookup:
reverse:
Easier to read/understand than:
dnslookup:
resolve:
enabled: false
reverse:
enabled: true
Also, the following would still do resolve
lookups, which IMO, is somehow hidden at config level (but not at the docs):
dnslookup:
reverse:
enabled: true
Anyway, just my 2 cents :)
func (g *dnsLookupProcessor) processTraces(_ context.Context, ts ptrace.Traces) (ptrace.Traces, error) { | ||
return ts, nil | ||
func newDNSLookupProcessor(config *Config, logger *zap.Logger) (*dnsLookupProcessor, error) { | ||
dnsResolver, err := createResolverChain(config, logger) |
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.
Do we want to create the resolvers/chain instances per signal type? If the same configuration applies to all signals, and they're stateless, we probably could create it once and re-use the same chain, avoiding for example reading all hostfiles
3 times, and also allowing it (in the future) to leverage/share the same cache.
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.
Very good point. It make sense to share the cache for signals per component.ID
. I think we can implement it later to keep this PR slim enough for review. I will add a todo
@edmocosta I have removed |
Hi @kaisecheng, could you please resolve the conflicts, so it can run the CI? thanks! |
88e86a8
to
709bf73
Compare
Description
This PR adds log processing for DNS Lookup Processor and implements host files resolver.
The Resolver interface defines
Resolve()
for forward lookup andReverse()
for reverse lookup.Hostfile resolver supports a list of hostfiles to resolve IP <> hostname.
Config
nameserver resolver, system default resolver and cache implementation will be in the next PR
Link to tracking issue
Parts of #34398
Testing
Documentation