Upload log file in elasticsearch using logstash


(Bhavesh Padharia) #1

Hello Everyone ,
i am new in elasticsearch

I try to upload log file in elasticsearch using logstash
i use this curl command

system@system-VirtualBox:~/Downloads/logstash-6.5.4$  curl -s -XPOST localhost:9200/_bulk --data @/home/system/Documents/LOG Data File/app2.log

But it seen this error

{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}

what i do to solve this error? Anyone suggest me.


#2

Well, you are not really using Logstash. You are in a Logstash folder using curl trying to post a log file directly to Elasticsearch.

I suggest you actually run Logstash :wink:

There are plenty of examples of simple Logstash configs to accomplish this.


#3

Thah was not necessarily very helpful, sorry... Try this (I don't really use file inputs so it might not be 100% correct). Put the below in a file e.g. logstash.conf

input {
  file {
    path => "/home/system/Documents/LOG Data File/app2.log"
    start_position => "beginning"
  }

}

filter {}

output {
  elasticsearch {
    hosts => "["127.0.0.1:9200"]"
  }
}

Start Logstash with

logstash-6.5.4/bin/logstash -f logstash.conf

(Bhavesh Padharia) #4
{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}

it again seen this error.


#5

That still looks like a curl error message to me... What command did you run?


(Bhavesh Padharia) #6
curl -s -XPOST localhost:9200/_bulk --data @/home/system/Documents/LOG Data File/app2.log

#7

You are still not using Logstash.

At least in the subject you say you want to use Logstash.

If you take my suggested Logstash configuration from above and start Logstash with

logstash-6.5.4/bin/logstash -f logstash.conf

That is all that is needed. You do not need to manually run curl commands after that. Logstash will read the log file and send the data to Elasticsearch.


(Bhavesh Padharia) #8

My logstash successfully started but i can't upload log file using curl command.


(Bhavesh Padharia) #9

please help how to upload log file in elasticsearch using logstash or any other source to upload log file.


#10

You have to set the path to the Logstash config file correctly.

Put this in a file e.g. /path/to/config/logstash.conf

input {
  file {
    path => "/home/system/Documents/LOG Data File/app2.log"
    start_position => "beginning"
  }

}

filter {}

output {
  elasticsearch {
    hosts => "["127.0.0.1:9200"]"
  }
}

Start Logstash with

logstash-6.5.4/bin/logstash -f /path/to/config/logstash.conf

(Bhavesh Padharia) #11

Thank you. it's work now,


(system) closed #12

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