-
Notifications
You must be signed in to change notification settings - Fork 528
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 ECS log files to the intake log endpoint #9349
Conversation
This pull request does not have a backport label. Could you fix it @lahsivjar? 🙏
NOTE: |
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.
Looks good, just left a couple of suggestions.
Handling maybe-flattened-maybe-not JSON will be interesting. I haven't looked into using it myself before, but json-iterator has an extension API which might be useful? https://pkg.go.dev/github.com/json-iterator/go#Extension
@axw Thanks for this. I was not aware of this and my searches also came up empty, it sounds way better than what I am doing right now which is introducing a map to decode the nested structure into and finally merging them with the flat decoded values via generated code. Something like this: type ecsLogService struct {
NestedStruct map[string]interface{} `json:"service" flattenSource:"true"`
ServiceName nullable.String `json:"service.name" validate:"maxLength=1024"`
ServiceVersion nullable.String `json:"service.version" validate:"maxLength=1024"`
ServiceEnvironment nullable.String `json:"service.environment" validate:"maxLength=1024"`
ServiceNodeName nullable.String `json:"service.node.name" validate:"maxLength=1024"`
} Finally, the generator will scan the |
📚 Go benchmark reportDiff with the
report generated with https://pkg.go.dev/golang.org/x/perf/cmd/benchstat |
Another edge case that's worth discussing is how to deal with duplicate keys. As ECS loggers allow users to add arbitrary keys at the top level, the resulting JSON may contain duplicate keys, such as |
When testing this PR with Java agent draft PR, I get a parsing error on the It's quite easy to reproduce with the following payload:
|
Great point. Yeah, the Thanks for testing this @SylvainJuge 👏 |
Thanks, @SylvainJuge, and @felixbarny for the proactive feedback and testing. Currently, APM-Server only supports UPDATE: I have added a PR #9376 to add support for string timestamp. For now, I have only added format |
Yes, I think |
@felixbarny Thanks for the clarification. Based on this doc, IIUC, |
Yes, that's correct. |
This pull request is now in conflicts. Could you fix it @lahsivjar? 🙏
|
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! Just a couple of minor things.
docs/spec/v2/log.json
Outdated
], | ||
"maxLength": 1024 | ||
}, | ||
"ecslogerrorfields": { |
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 wonder if we should just not produce JSON Schema for logs for now? IIRC that's what @felixbarny suggested earlier. Otherwise we should probably ensure the embedded structs don't affect the schema.
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 wonder if we should just not produce JSON Schema for logs for now?
How are the generated specs utilized? FWIW, I was planning on fixing the embedded struct handling in the schema generation code but if we don't have a use case for the schema or if it is not required for the logs then removing it sounds good to me.
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.
At least some of the agents use the schema for payload validation in tests. We used to use it in APM Server, before we generated the validation code. Let's drop it for now and come back to it if agents want to start validating logs payloads.
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.
Thanks @axw, I have removed the JSON spec generation for now.
@SylvainJuge Thanks for the earlier testing. Whenever you have time can you test again with the JAVA agent as all the required PRs are now merged. |
I just did a quick test and it seems that not all "string-based" timestamps formats are supported, see #9376 (comment) for an example. |
Motivation/summary
Add ECS logging fields to intake API's log endpoint.
Checklist
- [ ] Update package changelog.yml (only if changes toapmpackage
have been made)How to test these changes
log
event type:Related issues
Closes #9100