Hello @DOkuwa
If i understand this below is your sample message/log lines :
message :
openconfig-interfaces:interfaces/interface/state/counters,host=ibcinmnrffd1v,name=GigabitEthernet0/0,path=openconfig-interfaces:interfaces/interface/state/counters,source=hclab043-gnmic,subscription=140 in_octets=3522806333i 1753175837837000000
openconfig-interfaces:interfaces/interface/state/counters,host=ibcinmnrffd1v,name=GigabitEthernet0/0,path=openconfig-interfaces:interfaces/interface/state/counters,source=hclab043-gnmic,subscription=140 in_octets=3522829569i 1753175867837000000
In current scenario you are adding a static field where name is "interface" & value is "GigabitEthernet0/0" for all records
add_field => { "interface" => "GigabitEthernet0/0" }
Currently in kibana for each record this value is added :
{
"other_fields" : "values",
"interface": "GigabitEthernet0/0", // Static value added to every record
"message": "openconfig-interfaces:interfaces/interface/state/counters,host=ibcinmnrffd1v,name=GigabitEthernet0/0,path=openconfig-interfaces:interfaces/interface/state/counters,source=hclab043-gnmic,subscription=140 in_octets=3522806333i 1753175837837000000"
}
But you do not want this to be static as the value will change & this should be extracted from the message/log file where field is "name"
name=GigabitEthernet0/0
I am not sure if you are looking for below where it will extract the data dynamically :
input {
tcp {
port => 5085
codec => json {}
}
}
filter {
mutate {
remove_field => ["_tags"]
remove_field => ["tags"]
remove_field => ["timestamp"]
add_field => { "source" => "hclab043.zz.db.com" }
}
# Extract the `interface` value dynamically from the `message` field
grok {
match => { "message" => ".*name=%{DATA:interface},.*" }
}
mutate {
rename => { "[fields][in_octets]" => "[in_octets]" }
}
}
For sample below record in log file , i see this entry in Kibana
openconfig-interfaces:interfaces/interface/state/counters,host=ibcinmnrffd1v,name=GigabitEthernet2/1,path=openconfig-interfaces:interfaces/interface/state/counters,source=hclab043-gnmic,subscription=140 in_octets=3522806333i 1753175837837000000

Thanks!!