-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[fbreceivier] inject log level #42798
base: main
Are you sure you want to change the base?
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
@@ -72,7 +72,11 @@ func (fmp *provider) Retrieve(_ context.Context, uri string, _ confmap.WatcherFu | |||
}, | |||
}, | |||
} | |||
|
|||
// inject log level |
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.
can you move this to beatconverter.go
? Since this is common for all beats
// inject log level | ||
level, _ := cfg.String("logs.level", -1) | ||
if level != "" { | ||
cfgMap["service::telemetry::logs::level"] = level |
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.
you may want to map beats' logging level to otel level first.
For example. logging.level
supports values such as warning
which should translate to WARN
level on otel.
For ref:
https://www.elastic.co/guide/en/beats/filebeat/current/configuration-logging.html#level
https://opentelemetry.io/docs/collector/internal-telemetry/#configure-internal-logs
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.
as Khushi said, please add a translation instead of just copying it to the OTel config.
@AndersonQ can you please re-review? |
/test |
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.
[Blocker]
Shouldn't it reject a wrong log level just as the beats already do?
getOTeLLogLevel
could return an error if the level is invalid.
If I run this code with an invalid log level, it'll error and exit, but not because it's handled here, but because it's handled somewhere else.
config:
filebeat.inputs:
- type: filestream
id: filestream-input-id
enabled: true
paths:
- /home/ainsoph/tmp/log.log
output:
elasticsearch:
hosts: [ "https://localhost:9200" ]
username: elastic
password: changeme
ssl.verification_mode: none
logging.level: pastel
running it:
❯ go run . otel -c filebeat-otel.yml
2025-03-04T16:24:03.466+0100 info service@v0.114.0/service.go:166 Setting up own telemetry...
2025-03-04T16:24:03.467+0100 info telemetry/metrics.go:70 Serving metrics {"address": "localhost:8888", "metrics level": "Normal"}
2025-03-04T16:24:03.467+0100 warn elasticsearchexporter@v0.114.0/config.go:378 dedot has been deprecated: in the future, dedotting will always be performed in ECS mode only {"kind": "exporter", "data_type": "logs", "name": "elasticsearch"}
Error: failed to build pipelines: failed to create "filebeatreceiver" receiver for data type "logs": error creating filebeatreceiver: error unpacking beats logging config: invalid level 'pastel' accessing 'logging.level'
&{{{0xc00207c600} logging} <nil> 0xc00239c020}
Usage:
filebeat otel [flags]
it fails on another place:
Error: failed to build pipelines: failed to create "filebeatreceiver" receiver for data type "logs": error creating filebeatreceiver: error unpacking beats logging config: invalid level 'pastel' accessing 'logging.level'
last but not least, could you add a test as well?
@@ -111,6 +111,12 @@ func (c converter) Convert(_ context.Context, conf *confmap.Conf) error { | |||
beatReceiverConfigKey + "::output::otelconsumer": nil, | |||
} | |||
|
|||
// inject log level | |||
level, _ := config.MustNewConfigFrom(receiverCfg.ToStringMap()).String("logging.level", -1) |
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.
[Blocker]
Please, don't panic.
use the right method and handle the error gracefully
level, _ := config.MustNewConfigFrom(receiverCfg.ToStringMap()).String("logging.level", -1) | |
cfg, err := config.NewConfigFrom(receiverCfg.ToStringMap()) | |
if err!=nil{ | |
return fmt.Errorf("proper error message: %w", err) | |
} | |
level, err:=cfg.String("logging.level", -1) | |
if err!=nil{ | |
return fmt.Errorf("proper error message: %w", err) | |
}``` |
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 we should be good now.
Co-authored-by: Anderson Queiroz <me@andersonq.me>
@AndersonQ @khushijain21 please take a look when you can:
|
@@ -279,6 +280,75 @@ service: | |||
|
|||
}) | |||
|
|||
// t.Run("test log level", |
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.
// t.Run("test log level", | |
LGTM |
/test |
This PR maps
logging.level
from beats toservice::telemetry::logs::level
, so that the log level is respected across config translationScreenshots:
config.yaml
config.yaml
Closes https://github.com/elastic/ingest-dev/issues/5030