loggie
loggie copied to clipboard
goccy/go-yaml deal with blank string uncorrectly
goccy/go-yaml deal with blank string uncorrectly which is introduced by #242. And I met problem with parsing default containerd log.
CODE
package main
import (
"fmt"
errYaml "github.com/goccy/go-yaml"
okYaml "gopkg.in/yaml.v2"
)
func main() {
v := struct {
Key string
}{
Key: " ",
}
d1, _ := okYaml.Marshal(v)
fmt.Printf("%s\n%s\n", "YES", string(d1))
d2, _ := errYaml.Marshal(v)
fmt.Printf("%s\n%s\n", "NO", string(d2))
}
OUTPUT
YES
key: ' '
NO
key:
In what area(s)?
/area interceptor
What version of Loggie?
v1.2.0+
Expected Behavior
Load interceptor successfully
Actual Behavior
Got warnning log. get processor error: Key: 'SplitConfig.Separator' Error:Field validation for 'Separator' failed on the 'required' tag.
Steps to Reproduce the Problem
- Config CRD Interceptor
- type: normalize
processors:
- split:
separator: ' '
max: 4
keys: [ "time", "stream", "F", "message" ]
- drop:
targets: [ "F", "body" ]
- rename:
convert:
- from: "message"
to: "body"
- underRoot:
keys:
- kubernetes
- kubectl delete pod and kubectl logs pod
@ethfoo PTAL
Please refer to this document first when parsing the container log. The two YAML libraries do have some differences, and I'm still trying to figure out how to handle them.
@ethfoo
Thanks. If I understand correctly, the document link you given seems to LogConfig. However, I use ClusterLogConfig to collect all pod's logs.
My CRD spec:
apiVersion: loggie.io/v1beta1
kind: ClusterLogConfig
metadata:
name: all-pod-logs
spec:
selector:
type: cluster
cluster: {{ .Values.config.loggie.discovery.kubernetes.cluster }}
pipeline:
sources: |
- type: file
name: container-logs
paths:
- /var/log/pods/**/*.log
sinkRef: {{ .Values.sink.name }}
interceptorRef: containerd
I also encountered a similar problem when collecting container logs with k8s discovery enabled: if belongTo was specified explicitly, the belongTo field was not updated with the value podName/containerName/originalName. if rolling back to gopkg.in/yaml.v2, the belongTo field could be updated successfully.
apiVersion: loggie.io/v1beta1
kind: Interceptor
metadata:
name: test
spec:
interceptors: |
- type: normalize
name: test
belongTo: ["test"]
processors:
...
https://github.com/goccy/go-yaml/issues/309
Fixed: #317