module(load="mmkubernetes"
       filenamerulebase="/etc/rsyslog.d/viaq/k8s_filename.rulebase"
       containerrulebase="/etc/rsyslog.d/viaq/k8s_container_name.rulebase"
       tls.cacert="/etc/rsyslog.d/viaq/mmk8s.ca.crt"
       tokenfile="/etc/rsyslog.d/viaq/mmk8s.token" annotation_match=["."])

input(type="imfile" file="/var/log/containers/*.log" tag="kubernetes" addmetadata="on")

if ((strlen($!CONTAINER_NAME) > 0) and (strlen($!CONTAINER_ID_FULL) > 0)) or
    ($!metadata!filename startswith "/var/log/containers/") then {
    if $!metadata!filename startswith "/var/log/containers/" then {
        action(type="mmjsonparse" cookie="") # parse entire message as json
    }
    action(type="mmkubernetes")
}
