I some have source with generator Here
generator {
lines => [
'{
"macAddr": "d880397a3b0f",
"sensors": [
{"sensor-id": "s01", "sensor-val": 31},
{"sensor-id": "s02", "sensor-val": 32},
{"sensor-id": "s03", "sensor-val": 33}
],
"@timestamp": "2019-08-08T12:23:34Z"
}'
]
count => 1
codec => json { }
}
and Filter is here
jdbc_static {
loaders => [
{
id => "remote-device"
query => "select deviceId, deviceName, spotId, spotName, locGbCode, locGbName, ipAddr, macAddr from rs_temp_device_t"
local_table => "localDevice"
},
{
id => "remote-sensor"
query => "select deviceId, sensorId, sensorName, sensorUnit from rs_temp_device_sensor_t"
local_table => "localSensor"
}
]
local_db_objects => [
{
name => "localDevice"
index_columns => ["deviceId", "macAddr"]
columns => [
["deviceId", "varchar(10)"],
["deviceName", "varchar(20)"],
["spotId", "varchar(20)"],
["spotName", "varchar(20)"],
["locGbCode", "varchar(20)"],
["locGbName", "varchar(20)"],
["ipAddr", "varchar(20)"],
["macAddr", "varchar(20)"]
]
},
{
name => "localSensor"
index_columns => ["deviceId", "sensorId"]
columns => [
["deviceId", "varchar(10)"],
["sensorId", "varchar(20)"],
["sensorName", "varchar(20)"],
["sensorUnit", "varchar(20)"]
]
}
]
local_lookups => [
{
query => "select deviceId, deviceName, spotId, spotName, locGbCode, locGbName, ipAddr from localDevice where macAddr = :macAddr"
parameters => { macAddr => "[macAddr]" }
target => "device"
},
{
query => "select sensorName, sensorUnit from localSensor where sensorId = :sensorId"
parameters => { sensorId => "[ #sensors > sensor-id# ]"}
target => "sensor"
}
]
add_field => { deviceId => "%{[device][0][deviceid]}" }
add_field => { deviceName => "%{[device][0][devicename]}" }
add_field => { spotId => "%{[device][0][spotid]}" }
add_field => { spotName => "%{[device][0][spotname]}" }
add_field => { locGbCode => "%{[device][0][locgbcode]}" }
add_field => { locGbName => "%{[device][0][locgbname]}" }
add_field => { ipAddr => "%{[device][0][ipaddr]}" }
add_field => { sensorName => "%{[sensor][0][sensorname]}" }
add_field => { sensorUnit => "%{[sensor][0][sensorunit]}" }
remove_field => ["device", "sensor"]
# {jdbc_settings....}
}
can I lookup sensors(nested list) name and unit data from localSensor table with individual sensor-id?