Csv output plugin - custom field


#1

I'm following Csv output plugin | Logstash Reference [6.1] | Elastic and I have a question...

How would I add extra field with my own text?

Please advise.


(Krunal Kalaria) #2

hi @alexus,

https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-add_field

https://www.elastic.co/guide/en/logstash/current/plugins-filters-kv.html

You can use mutate or kv plugin in filter to add field.

Thanks & Regard,
Krunal.


#3

I've tried adding following:

    filter {
      mutate {
        add_field => { "key" => "value" }
      }
    }

yet file came out without new column "key" with "value" in every row...


(Krunal Kalaria) #4

i have been try this to add extra field and its working fine:

filter
{
mutate
{
add_field => ["Local_ip", "%{[Local][2]}"]
}
}


#5

hmm, your example looks similar to mine, except for in mine (per Logstash's reference example), I used curly brackets and you use square brackets...

Did you had to adjust output somehow to reflect new field in output file somehow? maybe that's the part I'm missing somehow?


#6

ahh, I was right... I added in output csv fields added my new field and now it's working as expected)


(Krunal Kalaria) #7

Great :slight_smile:


(system) #8

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