Field reference failed in logstash-input-redis


(赵振华) #1

My logstash version is logstash-5.3.2;I use the following config:
input {
redis {
batch_count => 1
data_type => "list"
key => "monitor_info_queue"
host => "192.168.154.135"
port => 6379
threads => 5
codec => "json"
}
}
output {
stdout {codec => rubydebug { metadata => true }}
if [key] == 'monitor_info_queue' {
elasticsearch {
index => "monitor_info"
document_type => "item"
hosts => ["http://es.service.ucloud.cn"]
}
}

Then, when I rpush info into redis list with name monitor_info_queue, I can get output in stdout.But I can't find info in es. what's the problem lies?


(Magnus Bäck) #2

Do the events have a key field? Have a look in the output from stdout {codec => rubydebug { metadata => true }}.


(赵振华) #3

No.The key field is from setting in logstash-input-redis, key => "monitor_info_queue".
From official documents, logstash-input-file, with field "path", can be used as field reference in conditional judgement.

https://www.elastic.co/guide/en/logstash/current/config-examples.html#_processing_apache_logs
input {
file {
path => "/tmp/access_log"
start_position => "beginning"
}
}

filter {
if [path] =~ "access" {
mutate { replace => { "type" => "apache_access" } }
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}

output {
elasticsearch {
hosts => ["localhost:9200"]
}
stdout { codec => rubydebug }
}

In redis, this does not work, is this logstash-input-redis plugin's fault?


(Magnus Bäck) #4

The redis input doesn't store the key in the events it emits, but since the key is static and known beforehand you can add it yourself with a add_field option in your redis input configuration.


(赵振华) #5

Perfect answer!
Would you please tell me,how can you confirm redis input does not emits event with key? Very follish question, haha

And another question, Logstash in docker start failed
would you please do me a favour.


(Magnus Bäck) #6

how can you confirm redis input does not emits event with key?

Fire up a Logstash configuration with a redis input and inspect the output?


(赵振华) #7

Smart,thank you very much


(system) #8

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