-
Notifications
You must be signed in to change notification settings - Fork 80
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 constants for known ecs fields for code efficiency when you log #38
Comments
Hi and welcome! We have some ideas around auto-generating a typed object hierarchy based on the generated ECS yaml file: https://github.com/elastic/ecs/blob/master/generated/ecs/ecs_nested.yml. That would have the benefit that the fields are not only named but also that the types correspond to those used in ECS. Combine that with a fluent API and you could do something like: logger.info(EcsMessage
.withMessage("Hello World")
.withUser()
.withId(42)
.withName("Jon Doe")
.and()
.withGeo()
.withCountry("Canada")); ThreadContext.putAll(EcsMessage.withUser().withId(42).withName("Jon Doe").toFlatMap()): |
I understand the example is not implemented yet. Thank you, much appreciated. |
It's just an idea at the moment and there's no timeline for that. |
I'd like to implement it. Do you have some details about where I should start to auto-generate "a typed object hierarchy based on the generated ECS yaml"? What would the input? How do you see it works? I'm not sure about the specifications but I really like this feature and I would enjoy to implement it myself. Is it to parse the yaml to create constant in a enum that we could instantiate with numbers? |
These are the fields from ECS: https://github.com/elastic/ecs/blob/master/generated/ecs/ecs_flat.yml. See also https://github.com/elastic/ecs-dotnet for how a typed object hierarchy is generated for .NET. |
Hello, For jackson, this example shows how to create instances of an object but not the java class definition. https://www.baeldung.com/jackson-yaml I have been recommend to use swagger and I think it would really be the way to go. In the image, we can see that from the yaml file, we can describe the java classes, their members, getters and setters. Can elastic create a ecs_nested.yml file that fit the swagger format? |
Not sure that swagger would be the way to go. It's about specifying HTTP-based APIs. On the plus side, it does come with a wide range of generators for different languages. |
Hi,
I'd like to have the ability to contribute to the project. It would be the first time I do it, so I am not sure if I can create a branch or anything. Would that be possible?
I'd like juste to create a Constants.java class that would have all the ECS fields so it would be accessible from any project and that would be more efficient.
Plus, it would be more easy to look at which fields already exist.
The text was updated successfully, but these errors were encountered: