Logstash - mutate - add_field problem


(Thorsten Hock) #1

Hi !

I do have the following event and I want to add another field and populate this with the content of event_data.IpAddress:

{
       "process_id" => 476,
       "level" => "Information",
        "event_data" => {
                        "IpAddress" => "172.16.87.87",
                        "ProcessId" => "0x0"
        },
        "opcode" => "Info",
        "type" => "wineventlog",
        "event_id" => 4624
}

In the logstash config I added this to achieve this, but it doesn't work:

...
filter {
    mutate {
        add_field => { "host" => "%{event_data.IpAddress} }
}
...

It does work if I take for example the event_id:

...
filter {
  mutate {
    add_field => { "host" => "%{event_id}}
  }
...

Any suggestion ?

Kind regards,
Thorsten


(Catalin Tileaga) #2

Try this:

add_field => [ "[host]", "%{event_data.IpAddress}" ]


(Magnus B├Ąck) #3

%{[event_data][IpAddress]}, not %{event_data.IpAddress}.

https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references


(Thorsten Hock) #4

This approach does create this additional field and content:

...
"host" => "%{event_data.IpAddress}",
...

Not what I need as I need the content of the field 'event_data.IpAddress' in the new field 'host'.


(Thorsten Hock) #5

The solution from Magnus is working:

add_field => { "host" => "%{[event_data][IpAddress]}" }

Thank's a lot !
Thorsten


(system) #6

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