我有一个成功存储消息的rabbitmq但是我的logstash读取队列时忽略了我的大部分消息。
RabbitMQ没问题 ,我有一个小的python脚本来显示所有消息
import pika
i=0
def on_message(channel, method_frame, header_frame, body):
global i
print i
print("Message body", body)
channel.basic_ack(delivery_tag=method_frame.delivery_tag)
i+=1
credentials = pika.PlainCredentials('***', '***')
parameters = pika.ConnectionParameters('***',5672,'logstash', credentials=credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.exchange_declare(exchange="logstash", exchange_type="topic", passive=False, durable=True, auto_delete=False)
channel.queue_declare(queue="hbbtv", auto_delete=False, durable=True)
channel.queue_bind(queue="hbbtv", exchange="logstash", routing_key="hbbtv")
channel.basic_qos(prefetch_count=1)
channel.basic_consume(on_message, 'hbbtv')
try:
channel.start_consuming()
except KeyboardInterrupt:
channel.stop_consuming()
connection.close()
我可以看到我的所有消息
12('留言机构',' {"留言":" 212.95.70.118 - - [25 / Feb / 2016:11:19:53 +0100] \" GET /services/web/index.php/OPA/categories/ARTEPLUS7/fr HTTP / 1.1 \" 200 348 \" http://www.arte.tv/hbbtvv2/notv/cehtml/index.cehtml?lang=de_DE&page=PLUS7&tv=false\" \#34; Opera / 9.80(Linux armv7l; HbbTV / 1.1.1(; Philips ;;; PhilipsTV;) CE-HTML / 1.0 NETTV / 4.3.1 PhilipsTV / 2.1.1固件/ 003.015.000.001 (PhilipsTV,2.1.1,)en)Presto / 2.12.362版本/ 12.11 \" hbbtvdyn.arte.tv"" @版本":" 1"" @时间戳":" 2016-02-25T10:19: 53.000Z""路径":" /数据/日志/接入""主机":" ARTE-hbbtvdyn-web1.sdv。 FR""类型":" apache的访问""应用":" HBBTV"" clientip&#34 ;:" 212.95.70.118"" IDENT":" - "" AUTH":" - &#34 ;," timestamp":" 25 / Feb / 2016:11:19:53 + 0100","动词":" GET", "请求":" /services/web/index.php/OPA/categories/ARTEPLUS7/fr"," httpversion":" 1.1&#34 ;,"响应":" 200""字节":" 348""引荐":&#34 ; \" http://www.arte.tv/hbbtvv2/notv/cehtml/index.cehtml?lang=de_DE&page=PLUS7&tv=false\"""试剂":" \"歌剧院/ 9.80 (Linux armv7l; HbbTV / 1.1.1(; Philips ;;; PhilipsTV;)CE-HTML / 1.0 NETTV / 4.3.1 PhilipsTV / 2.1.1固件/ 003.015.000.001(PhilipsTV, 2.1.1,)en)Presto / 2.12.362版本/ 12.11 \""," targethost":" hbbtvdyn.arte.tv",&#34 ; geoip的" {" IP":" 212.95.70.118"" country_code2":" FR"" country_code3":" FRA"" COUNTRY_NAME":"法国"" continent_code":" EU&#34 ;, " REGION_NAME":" C1"" CITY_NAME":"斯特拉斯堡""纬度":48.60040000000001,&#34 ;经度":7.787399999999991"时区":"欧/巴黎"" real_region_name":"阿尔萨斯""位置":[7.787399999999991,48.60040000000001]}}') 13('消息正文',' {"消息":" 212.95.70.118 - - [25 / Feb / 2016:11:19:53 +0100] \" GET /services/web/index.php/OPA/videos/highlights/6/ARTEPLUS7/de/GE HTTP / 1.1 \" 500 4519 \" http://www.arte.tv/hbbtvv2/notv/cehtml/index.cehtml?lang=de_DE&page=PLUS7&tv=false\" \#34; Opera / 9.80(Linux armv7l; HbbTV / 1.1.1(; Philips ;;; PhilipsTV;) CE-HTML / 1.0 NETTV / 4.3.1 PhilipsTV / 2.1.1固件/ 003.015.000.001 (PhilipsTV,2.1.1,)en)Presto / 2.12.362版本/ 12.11 \" hbbtvdyn.arte.tv"" @版本":" 1"" @时间戳":" 2016-02-25T10:19: 53.000Z""路径":" /数据/日志/接入""主机":" ARTE-hbbtvdyn-web1.sdv。 FR""类型":" apache的访问""应用":" HBBTV"" clientip&#34 ;:" 212.95.70.118"" IDENT":" - "" AUTH":" - &#34 ;," timestamp":" 25 / Feb / 2016:11:19:53 + 0100","动词":" GET", "请求":" /services/web/index.php/OPA/videos/highlights/6/ARTEPLUS7/de/GE"," httpversion":&# 34; 1.1""响应":" 500""字节":" 4519""引荐&# 34;:" \" http://www.arte.tv/hbbtvv2/notv/cehtml/index.cehtml?lang=de_DE&page=PLUS7&tv=false\"""试剂":" \"歌剧院/ 9.80 (Linux armv7l; HbbTV / 1.1.1(; Philips ;;; PhilipsTV;)CE-HTML / 1.0 NETTV / 4.3.1 PhilipsTV / 2.1.1固件/ 003.015.000.001(PhilipsTV, 2.1.1,)en)Presto / 2.12.362版本/ 12.11 \""," targethost":" hbbtvdyn.arte.tv",&#34 ; geoip的" {" IP":" 212.95.70.118"" country_code2":" FR"" country_code3":" FRA"" COUNTRY_NAME":"法国"" continent_code":" EU&#34 ;, " REGION_NAME":" C1"" CITY_NAME":"斯特拉斯堡""纬度":48.60040000000001,&#34 ;经度":7.787399999999991"时区":"欧/巴黎"" real_region_name":"阿尔萨斯""位置":[7.787399999999991,48.60040000000001]}}') 14('消息正文',' {"消息":" 212.95.70.119 - - [25 / Feb / 2016:11:19:53 +0100] \" GET /OPA/getOPAData.php?url=videoStreams%3Flanguage%3Dfr%26protocol%3DHTTP%26mediaType%3Dmp4%26quality%3DEQ%2CSQ%2CHQ%26profileAmm%3D%24nin%3AAMM-YTFR-HAB%2CAMM-YTFR%2CAMM-DT %26kind%3DSHOW%26availableScreens%3DTV%26fields%3DprogramId%2Curl%2Cquality%2CaudioSlot%2CaudioCode%2CaudioLabel%2CaudioShortLabel%2Cchannel%26programId%3D048353-033-A%26platform%3DARTEPLUS7&安培;文件名= PLUS7_stream_048353-033-A_fr_FR.json HTTP / 1.1 \" 200 5508 \" - \" \#34; Mozilla / 5.0(Linux; Tizen 2.3; SmartHub;智能电视;智能电视; U; Maple2012)AppleWebKit / 538.1 +(KHTML, 像Gecko)TV Safari / 538.1 + \" hbbtvdyn.arte.tv"" @版本":" 1"" @时间戳":" 2016-02-25T10:19: 53.000Z""路径":" /数据/日志/接入""主机":" ARTE-hbbtvdyn-web1.sdv。 FR""类型":" apache的访问""应用":" HBBTV"" clientip&#34 ;:" 212.95.70.119"" IDENT":" - "" AUTH":" - &#34 ;," timestamp":" 25 / Feb / 2016:11:19:53 + 0100","动词":" GET", "请求":" /OPA/getOPAData.php URL = videoStreams%3Flanguage%3Dfr%26protocol%3DHTTP%26mediaType%3Dmp4%26quality%3DEQ%2CSQ%2CHQ%26profileAmm%3D%24nin% 3AAMM-YTFR-HAB%2CAMM-YTFR%2CAMM-DT%26kind%3DSHOW%26availableScreens%3DTV%26fields%3DprogramId%2Curl%2Cquality%2CaudioSlot%2CaudioCode%2CaudioLabel%2CaudioShortLabel%2Cchannel%26programId%3D048353-033-A%26platform% 3DARTEPLUS7&安培;文件名= PLUS7_stream_048353-033-A_fr_FR.json"" httpversion":" 1.1""响应":" 200&#34 ;,"字节":" 5508&#3 4;,"引荐":" \" - \"""试剂":" \" Mozilla的/ 5.0 (Linux; Tizen 2.3; SmartHub; SMART-TV; SmartTV; U; Maple2012) AppleWebKit / 538.1 +(KHTML,像Gecko)TV Safari / 538.1 + \""" targethost":" hbbtvdyn.arte.tv"" geoip的" {" IP" :" 212.95.70.119"" country_code2":" FR"" country_code3":" FRA",& #34; COUNTRY_NAME":"法国"" continent_code":" EU"" REGION_NAME":" C1&# 34;," CITY_NAME":"斯特拉斯堡""纬度":48.60040000000001,"经度":7.787399999999991"时区&#34 ;:"欧/巴黎"" real_region_name":"阿尔萨斯""位置":[7.787399999999991,48.60040000000001]}}&#39 ;)
带有良好的速率信息(每秒几个),我绝对不会解析失败。
因此,在logstash读取消息时会出现问题。问题是
logstash的输入部分是
rabbitmq {
host=>"arte-elasticlog.sdv.fr"
user=>"***"
password=>"***"
queue=>"hbbtv"
vhost=>"logstash"
port=>5672
auto_delete=>false
durable=>true
type => "rabbit_hbbtv"
}
答案 0 :(得分:2)
_grokparsefailure表示无法解析消息。意味着消息已成功从队列中读取,但您的grok表达式存在问题或无法应用于您的消息内容。
另外一件事是rabbitmq输入的默认编解码器是" json",如果你的rabbitmq消息内容不是json,你应该设置输入的编解码器,例如:
codec =>普通{}
答案 1 :(得分:1)
问题是由于我的logstash过滤器, 我有两个apache访问但具有不同的模式,所以当logstash试图解析一条消息时,有时他有好的模式 - >在ES中,有时不是 - >没有消息。
现在,对于我所有的不同日志,我添加(添加字段)
application-->"my application name"
在我的输入中,我的所有grok过滤器都取决于应用程序。
现在一切都很好,谢谢你的帮助。