With variable output file name : "The starting part of the path should not be dynamic"

When I add a output file with variable in the pipiline.conf

path => "%{type}_%{+yyyy_MM_dd}.log"

I get the logstash error :

The starting part of the path should not be dynamic

It works fine when I remove the path line or without variable name:

path => "access.log"

Here is the pipelines.conf

input {
    file {
        path => "/mylogstash/data/apache_access.log"
        start_position => "beginning"
        type => "access"
    }
    http {
        type => "access"
    }
}
filter {
    grok {
    match => { "message" => '%{HTTPD_COMMONLOG} "%{GREEDYDATA:referrer}" "%{GREEDYDATA:agent}"' }
    }
    mutate {
        convert => {
            "response" => "integer"
            "bytes" => "integer"
        }
    }
}
output {
    stdout {
        codec => rubydebug
    }
    file {
        path => "%{type}_%{+yyyy_MM_dd}.log"
    }
}

Any hint?

You can't begin the path with %{whatever}. It must begin with something non-dynamic.

1 Like

Thanks @magnusbaeck for your prompt reply, appreciate it.

Indeed, I added the absolute path to the beginning of the file and the error disapeared

file {
    path => "/data/%{type}_%{+yyyy_MM_dd}.log"
}

Thanks a lot!!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.