-
Notifications
You must be signed in to change notification settings - Fork 717
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
Support ECS in operator logs #2002
Comments
How do things like name and namespace map to ECS? Or does it make sense to map the things we can (looks like |
As they don't map to any ECS fields they would just stay in their original form. |
Just to share an issue I'm facing: In case of an error in ECK the following log is generated by the controller runtime: {
"log": "{\"log.level\":\"error\",\"@timestamp\":\"2020-01-20T13:53:19.874Z\",\"log.logger\":\"controller-runtime.controller\",\"message\":\"Reconciler error\",\"service.version\":\"1.0.0-bf9563a3\",\"service.type\":\"eck\",\"ecs.version\":\"1.4.0\",\"controller\":\"webhook-certificates-controller\",\"request\":\"/elastic-webhook.k8s.elastic.co\",\"error\":\"validatingwebhookconfigurations.admissionregistration.k8s.io \\\"elastic-webhook.k8s.elastic.co\\\" not found\",\"errorCauses\":[{\"error\":\"validatingwebhookconfigurations.admissionregistration.k8s.io \\\"elastic-webhook.k8s.elastic.co\\\" not found\"}],\"error.stack_trace\":\"github.com/go-logr/zapr.(*zapLogger).Error\\n\\t/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128\\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\\n\\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:258\\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\\n\\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:232\\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker\\n\\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:211\\nk8s.io/apimachinery/pkg/util/wait.JitterUntil.func1\\n\\t/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20191028221656-72ed19daf4bb/pkg/util/wait/wait.go:152\\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\\n\\t/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20191028221656-72ed19daf4bb/pkg/util/wait/wait.go:153\\nk8s.io/apimachinery/pkg/util/wait.Until\\n\\t/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20191028221656-72ed19daf4bb/pkg/util/wait/wait.go:88\"}\n",
"stream": "stderr",
"time": "2020-01-20T13:53:19.874360282Z"
} The problem is that there is an {"type":"mapper_parsing_exception","reason":"object mapping for [error] tried to parse field [error] as object, but found a concrete value"} I have tried to use the I'm still trying to understand how to circumvent this situation... |
I finally managed to rename to |
I think I will create a first PR to add a minimal set of fields to be compliant with ECS. But there are some things that could be investigated/improved:
It is worth to note that it is not easy to be consistent re. the key/values added to the log. if result, err := c.Do.Reconcile(req); err != nil {
c.Queue.AddRateLimited(req)
log.Error(err, "Reconciler error", "controller", c.Name, "request", req)
[...]
return false
} This would produce: {
"message": "Reconciler error",
"log.logger": "controller-runtime.controller",
"log.level": "error",
"controller": "kibana-association-controller",
"error.message": "An error message about kibanas.kibana.k8s.elastic.co \"kb-apm-sample\": something bad happened",
"error.stack_trace": "github.com/go-logr/zapr.(*zapLogger).Error\n\t/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:258\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:232\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/internal/controller/controller.go:211\nk8s.io/apimachinery/pkg/util/wait.JitterUntil.func1\n\t/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20191028221656-72ed19daf4bb/pkg/util/wait/wait.go:152\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20191028221656-72ed19daf4bb/pkg/util/wait/wait.go:153\nk8s.io/apimachinery/pkg/util/wait.Until\n\t/go/pkg/mod/k8s.io/apimachinery@v0.0.0-20191028221656-72ed19daf4bb/pkg/util/wait/wait.go:88",
"request": "namespace1/kb-apm-sample"
} In the above example if a user is filtering on log.Error(err, "Reconciler error", "controller", c.Name, "namespace", req.Namespace, "name", req.name) (we would still have a problem with the "name" field but this could be revisited in our code) We also have some inconsistencies in our code, mostly in the "common" packages, for example when a certificate is generated:
I think it would be nice to add a reference to the owner in order to link this log to the parent resource. |
Closed in favor of #2467 |
Currently our logging output does not play nicely with Elastic observability tooling in Kibana for example because we don't follow ECS in the JSON logs we produce.
Example: ECK log output not fully parsed in Kibana logs view:
There are two options to solve this:
\2. seems easier as we have full control over what we produce and it would simplify ingestion (no transformation needed at ingest)
The text was updated successfully, but these errors were encountered: