conmon
conmon copied to clipboard
CONTAINER_NAME doesn't output the correct "io.kubernetes.container.name" label
With docker, the below daemon.json
for journald
:
{
"log-driver": "journald",
"log-opts": {
"tag":"{{.ID}}",
"labels": "io.kubernetes.container.name,io.kubernetes.pod.name"
}
}
We can filter journalctl logs by IO_KUBERNETES_CONTAINER_NAME=<container-name>
. Where container-name
is the one defined in the k8s manifest.
...
containers:
- args:
...
name: kafka
In crio, when logging to journald, the CONTAINER_NAME
filter outputs the pod name instead along with some hash:
k8s_kafka_kafka-0_default_4067521d-941e-460a-b8c0-8ec98ecb9dd0_0
Is there a way to configure the fields we send to journald like docker does? So that we can have only kafka
returned when doing the filter match?
Thanks for giving CRI-O a try!
we don't currently support adding a label, so support for that would need to be added.
also, technically, from cri-o's perspective the container name is that whole string. Here's how that string is constructed:
name := strings.Join([]string{
"k8s",
c.config.Metadata.Name,
c.sboxConfig.Metadata.Name,
c.sboxConfig.Metadata.Namespace,
c.sboxConfig.Metadata.Uid,
fmt.Sprintf("%d", c.config.Metadata.Attempt),
}, "_")
I don't remember exactly why it's done this way.
What changes would be required to meet your use cases?
Thanks for the reply @haircommander
Yes, if we can provide a way to add the label like docker daemon.json it would be great.
Else if we can have another filter IO_KUBERNETES_CONTAINER_NAME
with only the container name (c.config.Metadata.Name
) then it would help filter logs with it.
Is there a way to plug your filters in before we send out to journald?