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
otel: hostname handling #4954
Merged
Merged
otel: hostname handling #4954
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This Pull Request introduces config grammar changessyslog-ng/9d3c3c3c128788a9917bace9856315dd3995e0b3 -> MrAnno/otel-source-hostname --- a/parser
+++ b/parser
opentelemetry(
+ set-hostname(<yesno>)
)
|
bazsi
reviewed
May 14, 2024
bazsi
reviewed
May 14, 2024
const gchar *type = log_msg_get_value_with_type(msg, logmsg_handle::RAW_TYPE, &len, &log_msg_type); | ||
|
||
/* _parse_metadata() may invalidate the returned char pointer, so a copy is made with std::string */ | ||
std::string type = log_msg_get_value_with_type(msg, logmsg_handle::RAW_TYPE, &len, &log_msg_type); |
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.
[optional] we could avoid the copy/malloc by mapping the borrowed pointer to an enum and then using that to
determine how we unpack the protobuf.
The opentelemetry() source does not parse anything, so HOST can't be set properly according to the keep-hostname() option. Since opentelemetry() is a no-parse source, we let HOST fall back to saddr (in LogSource). The opentelemetry() parser should be used if one wants to keep the original hostname. Signed-off-by: László Várady <laszlo.varady@anno.io>
Signed-off-by: László Várady <laszlo.varady@anno.io>
This is a preparation step for adding HOST extraction. The hostname may appear in the resource/scope metadata, or in the log itself, so the order it is parsed matters. Signed-off-by: László Várady <laszlo.varady@anno.io>
Signed-off-by: László Várady <laszlo.varady@anno.io>
MrAnno
force-pushed
the
otel-source-hostname
branch
from
May 14, 2024 10:15
129ddff
to
8c72617
Compare
alltilla
approved these changes
May 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
keep-hostname(yes/no)
won't work inopentelemetry()
/syslog-ng-otlp()
, becausesyslog-ng-otlp()
andopentelemetry()
syslog-ng-otlp()
opentelemetry()
, we have a separate parser for thatInstead of implementing
keep-hostname(yes/no)
scenarios for these 2 sources, we ignore this flag.syslog-ng-otlp()
keeps the original hostname,opentelemetry()
doesn't do anything, so it falls back to using the peer address (saddr) as HOST.(The code forces
keep-hostname(yes)
on both sources, but in practice the above is done due to the fallback mechanism.)For the
opentelemetry()
parser, theset-hostname(yes/no)
option is introduced,yes
is the default.It extracts the
host.name
attribute if available, or leaves the HOST field as-is (https://opentelemetry.io/docs/specs/semconv/attributes-registry/host/).With these defaults the
syslog-ng-otlp() + opentelemetry()
parser scenario ends up being correct, we'll get the original hostname regardless of where the message originally came from (OTLP, syslog, etc.).