Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redis 多个日志存储实例导致行重复_Redis_Duplicates_Jruby_Logstash - Fatal编程技术网

Redis 多个日志存储实例导致行重复

Redis 多个日志存储实例导致行重复,redis,duplicates,jruby,logstash,Redis,Duplicates,Jruby,Logstash,我们正在使用具有以下配置的Logstash接收日志: input { udp { type => "logs" port => 12203 } } filter { grok { type => "tracker" pattern => '%{GREEDYDATA:message}' } date { type => "tracker" match => [ "timestamp", "y

我们正在使用具有以下配置的Logstash接收日志:

input {
  udp {
    type => "logs"
    port => 12203
  }
}

filter {
  grok {
    type => "tracker"
     pattern => '%{GREEDYDATA:message}'
  }
  date {
    type => "tracker"
    match => [ "timestamp", "yyyy-MM-dd HH:mm:ss,SSS" ]
  }
}

output{
    tcp{
         type => "logs"
         host => "host"
         port => 12203
    }
}
然后,我们将使用以下设置在计算机上拾取日志
“主机”

input {
      tcp {
                      type => "logs"
                      port => 12203
                        }
}


output {
    pipe {
        command => "python /usr/lib/piperedis.py"
    }
}
从这里开始,我们对这些行进行解析,并将它们放入Redis数据库中。然而,我们发现了一个有趣的问题

Logstash将日志消息“包装”在JSON样式的包中,即:

{\"@source\":\"source/\",\"@tags\":[],\"@fields\":{\"timestamp\":[\"2013-09-16 15:50:47,440\"],\"thread\":[\"ajp-8009-7\"],\"level\":[\"INFO\"],\"classname\":[\"classname\"],\"message\":[\"message"\]}}
然后,当我们接收到它并将其传递到下一台机器上时,将其作为消息并将其放入另一个包装器中!我们只关心实际的日志消息,而不关心其他内容(源路径、源、标记、字段、时间戳e.t.c.)

有没有一种方法可以使用过滤器或其他东西来做到这一点?我们已经查看了文档,但找不到任何方法在Logstash实例之间传递原始日志行

谢谢


Matt

日志存储文档是错误的-它表明默认的“编解码器”是,但实际上它没有使用编解码器-它使用一个输出

要获得更简单的输出,请将输出更改为

output {
    pipe {
        command => "python /usr/lib/piperedis.py"
        message_format =>  "%{message}"
    }
}

为什么不直接从stdout中提取这些消息呢

line = sys.stdin.readline()
line_json = json.loads(line)
line_json['message'] # will be your @message