Skip to content
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

kv filter overwrites existing fields without warning/log entry #1883

Closed
awuetz opened this issue Oct 12, 2014 · 4 comments
Closed

kv filter overwrites existing fields without warning/log entry #1883

awuetz opened this issue Oct 12, 2014 · 4 comments

Comments

@awuetz
Copy link

awuetz commented Oct 12, 2014

The KV filter overwrites existing field values if the key is identical to the fieldname.

Assume you have the following log line:

url=http://www.google.com/my.jpeg,type=image/jpeg

And the following logstash configuration:

input { 
        file {  
                path => "/tmp/http_wwwrelay.csv"              
                type => "http_www"
        }
}

filter {
        if [type] == "http_www" {
                grok {    
                        match => { "message" => "^%{GREEDYDATA:kv_source}$" }
                }
                kv {
                        source => "kv_source"
                        field_split => ","
                        value_split => "="
                        remove_field => "kv_source"
        }
      }
}

output {
    if [type] == "http_www" {
              stdout {}
    }
}

At the input file statement we set "type" to "http_www".
After the kv filter processing, the field "type" with previous value "http_www" has the new value "image/jpeg". Thats why the output filter is not working.

The workaround is to use "prefix" or "target" at the kv filter, to find it out was quite hard.

The replacement of an existing field value should be logged.

@jsvd
Copy link
Member

jsvd commented Oct 13, 2014

That's a problem indeed..finding overlapping fields on each event might be costly though..
Maybe we could issue a warning of possible overwrites on startup time if "kv" filter is used without prefix or target?

@awuetz
Copy link
Author

awuetz commented Oct 13, 2014

Yes, that would be one solution. Maybe extending the documentation would be better.

I also thought about making the parameter prefix/target mandatory instead of optional. But i don't know if this is a good solution.

@widhalmt
Copy link

What about a blacklist of fields that can never be overwritten? Maybe even with some predefined excludes like "type"?

@suyograo
Copy link
Contributor

suyograo commented Aug 7, 2015

@suyograo suyograo closed this as completed Aug 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants