-
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
Add more ECS fields to logs #25998
Add more ECS fields to logs #25998
Conversation
💔 Tests Failed
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪Test errorsExpand to view the tests failures
|
Test | Results |
---|---|
Failed | 1 |
Passed | 47332 |
Skipped | 5244 |
Total | 52577 |
Genuine test errors
💔 There are test failures but not known flaky tests, most likely a genuine test failure.
- Name:
Extended / heartbeat-windows-7-32-windows-7-32-bit / TestQueueRunsInOrder – github.com/elastic/beats/v7/heartbeat/scheduler/timerqueue
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.
Short and sweet! Only thing I'm not keen on is the change to libbeat/logp/configure
. That change means logp requires logp/configure to have been called, which I think is the wrong way around.
libbeat/logp/core.go
Outdated
@@ -196,6 +196,13 @@ func makeOptions(cfg Config) []zap.Option { | |||
if cfg.development { | |||
options = append(options, zap.Development()) | |||
} | |||
if cfg.ECSEnabled { | |||
fields := []zap.Field{zap.String("service.name", cfg.Beat)} | |||
if cfg.Files.Name != "" { |
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 see why this works, but it looks wrong to me since we should add event.dataset
for non-file logging output. How about we introduce a new function in this package like
// logFilename returns the base filename to which logs will be written for
// the "files" log output. If another log output is used, or `logging.files.name`
// is unspecified, then the beat name will be returned.
func logFilename(cfg Config) string {
name := cfg.Beat
if cfg.Files.Name != "" {
name = cfg.Files.Name
}
return name
}
Then you can use that here and in makeFileOutput
, and revert the configure.Logging
.
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.
we should add event.dataset for non-file logging output
I don't get that. If the output is eg. stderr what should be the value of event.dataset
?
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.
See #25997 and https://github.com/elastic/ecs-logging/blob/9507c12f7523741cc06f84a2686d580e50f3465f/spec/spec.json#L79-L95
If the user manually configures the service name, the logging library should set
event.dataset=${service.name}.log
if not explicitly configured otherwise.
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.
LGTM, thanks! Would be good to add a test.
+1 There are unfortunately not many tests on logp, but as we start to add fields dynamically on user config it would be nice to introduce tests that check expected fields to be set. |
jenkins retest this please |
@urso any idea how can i merge this? the metricbeat-windows-10 tests have been stuck for +10 hours 2 times... or do you think is related to these changes? |
jenkins retest this please |
jenkins retest this please |
@urso this failed 6 times with 5 different flaky tests :/ |
Sorry, no. We never manually push to master or other release branches. Teams regularly working on Beats can still overwrite the checks in the UI and merge if there is need. The heartbeat one that failed is new. I'm not aware of it failing and the flaky test checker doesn't seem to know about the failed test either. Maybe some really bad timing or infra problems with windows 7, or a genuine back introduced lately... Regarding Heartbeat there is no real change besides Beats moving to 1.16. But during the migration to 1.16 we already have had to skip some other tests in metricbeat and heartbeat. See #25859 I'm okay to merge this PR for you, but can you please create an issue with the stack trace and skip the test that fails. Maybe @andrewvc might need to have a look. |
Merged. The backport PR will be assigned to you. Feel free to ping me if you have any problems with the backport. |
(cherry picked from commit bfbadaa)
(cherry picked from commit bfbadaa) Co-authored-by: Juan Álvarez <juan.alvarez@elastic.co>
* master: (26 commits) Report total and free CPU for vSphere virtual machines (elastic#26167) [filebeat] Add preserve_original_event option to o365audit input (elastic#26273) Change xml processor names in script processor to match convention (elastic#26263) [Oracle] Fixing default values for paths in config template (elastic#26276) Add more ECS fields to logs (elastic#25998) [Heartbeat] Fix broken invocation of synth package (elastic#26228) rename sqs file name (elastic#26227) Populate the agent action result if there is no matching action handlers (elastic#26152) Add ISO8601 as supported timestamp type (elastic#25564) Move Filebeat azure module to GA (elastic#26168) Filebeat azure module pipeline fixes and changes (elastic#26148) libbeat: monitor version (elastic#26214) Add new parser to filestream input: container (elastic#26115) [Metricbeat] Add state_statefulset replicas.ready (elastic#26088) Disable test processors system test for windows 10 (elastic#26216) Fix startup with failing configuration (elastic#26126) Remove 32 bits version of Elastic Agent. (elastic#25708) Chane fleetmode detection to ony use management.enabled (elastic#26180) Make `filestream` input GA (elastic#26127) libbeat/idxmgmt/ilm: fix alias creation (elastic#26146) ...
What does this PR do?
Adds service.name and event.dataset fields to ECS logs
Checklist
- [ ] I have commented my code, particularly in hard-to-understand areas- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added tests that prove my fix is effective or that my feature works- [ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Start a beat with default settings, both with and without
-e
, and see the implemented fields in the logs.Related issues
Closes #25997