ELK I created is filebeat - > KAFKA -> logstash -> ES &Kibana (AWS elastic search)
the logs are generated in json format and it is pushed to kafka with below config:
=========================
filebeat.prospectors:
- input_type: log
paths:- /srv/my_app/src/logs/*.log
document_type: my_app
path.home: /opt/filebeat-5.4.2-linux-x86_64/
path.config: {path.home} path.data: {path.home}/data
filebeat.registry_file: ${path.data}/registry
logging.level: debug
logging.to_files: true
logging.to_syslog: false
logging.files:
path: /var/log/mybeat
name: mybeat.log
keepfiles: 7
output.kafka:
enabled: true
hosts: ["myhost.kafka1","myhostkafka2","myhostkafka3"]
topic: my_app
version: 0.9.0.0
worker: 2
compression: gzip
logging.to_files: true
logging.files: /tmp/filebeat_kafka.log
============================================
- /srv/my_app/src/logs/*.log
Logstash config is below
input {
kafka {
bootstrap_servers => "myhost.kafka1","myhostkafka2","myhostkafka3"
topics => ["my_app"]
codec => json
}
output {
if [type_name] == "my_app" {
elasticsearch {
hosts => ["eshost1"]
index => "%{[type_name]}-%{+YYYY.MM.dd}"
document_type => "%{[type_name]}"
}
}
}
filter {
mutate {
add_field => {"index_name" => '%{type}'}
add_field => {"type_name" => '%{type}'}
}
if [@metadata][type] == "my_app" {
json {
source => "message"
}
date {
match => [time ,"ISO8601" ]
}
}
}
The issue here is the message field is in json format and it is stored in es as string (I can see that through kibana) image attached below
Sample format of message:
{"name":"xxxx","vertical":"xxxx","clusterid":50,"hostname":"xxxx","pid":7833,"route":"xxxxx","uuid":"xxxx","level":30,"opened_from":"xxx","osVersion":"5.1.1","imei":"xxxxxx","networkType":"4G","language":"en","long":"81.4510731","lat":"25.748469","playStore":"true","version":"5.9.1","client":"androidapp","deviceName":"vivo_V3","deviceManufacturer":"vivo","deviceIdentifier":"vivo-vivoV3-862738034446452","sso_token":"fa7e30a5-28b3-44fd-b528-7ee465817cd7","client_ip":"xxxxxxxx","user_agent":"Dalvik/2.1.0 (Linux; U; Android 5.1.1; vivo V3 Build/LMY47V)","path":"xxxxxxxx","url":"xxxxx","verb":"GET","operation":"xxxxx","point":"exit","api_method":"xxxx","response_code":"xxxxx","response_time":9,"status_code":xxxx,"msg":"xxxx","time":"2017-07-13T16:52:16.156Z","src":{"file":"xxxxx","line":xxxxx},"v":0}
Please help me in figuring this out.