Hey elastic team, ive been trying to write a filter for json files so that it gets indexed into elasticsearch but its not creating an index in elastic search. There is no error in the logstash config file.
This is a sample of json file :
{"asctime": "2019-08-13 06:17:45,132", "filename": "taskinstance.py", "lineno": 616, "levelname": "INFO", "message": "Dependencies all met for <TaskInstance: tutorial.print_date 2019-08-13T06:17:05.595788+00:00 [queued]>", "dag_id": "tutorial", "task_id": "print_date", "execution_date": "2019_08_13T06_06_05_595788", "try_number": "1"}
{"asctime": "2019-08-13 06:17:45,132", "filename": "taskinstance.py", "lineno": 834, "levelname": "INFO", "message": "\n--------------------------------------------------------------------------------", "dag_id": "tutorial", "task_id": "print_date", "execution_date": "2019_08_13T06_06_05_595788", "try_number": "1"}
{"asctime": "2019-08-13 06:17:45,132", "filename": "taskinstance.py", "lineno": 835, "levelname": "INFO", "message": "Starting attempt 1 of 2", "dag_id": "tutorial", "task_id": "print_date", "execution_date": "2019_08_13T06_06_05_595788", "try_number": "1"}
{"asctime": "2019-08-13 06:17:45,132", "filename": "taskinstance.py", "lineno": 836, "levelname": "INFO", "message": "\n--------------------------------------------------------------------------------", "dag_id": "tutorial", "task_id": "print_date", "execution_date": "2019_08_13T06_06_05_595788", "try_number": "1"}
There are multiple json files that has the same format.
This is my config file:
input
{
file
{
codec => multiline
{
pattern => '^{'
negate => true
what => previous
}
path => [“/Users/raks/Documents/test.json"]
start_position => "beginning"
sincedb_path => "/dev/null"
exclude => "*.gz"
}
}
filter
{
mutate
{
replace => [ "message", "%{message}}" ]
gsub => [ 'message','\n','']
}
if [message] =~ /^{.*}$/
{
json { source => message }
}
}
output {
elasticsearch {
hosts => [ “elasticsearch:9200" ]
index => "rakstest"
}
}
Any help would be really appreciated. Thanks!!