Upload log file in elasticsearch using logstash

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.

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.

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
1 Like
{"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.

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

curl -s -XPOST localhost:9200/_bulk --data @/home/system/Documents/LOG Data File/app2.log

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.

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

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

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

Thank you. it's work now,

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