Connecting to logstash with Basic Authentication

Hello,
I am using HTTP input plugin in logstash config. I have been always sending data to logstash over HTTP POST method by using logstash API like this;

curl -XPOST http://<logstashIP>:9605 -d '{"my": "data"}'

also my config like this;

input {
  http {
    port => 9605
    codec => "json"
  }
}
filter {
  json {
     source => "messages"
  }
}
output {
  stdout { codec => rubydebug }
}

But is there a way to send data to logstash with basic authentication like this;
curl -XPOST -u 'user:password' http://<logstashIP>:9605 -d '{"my": "data"}'

The purpose is to send data to logstash securely.

Many thanks

Yes. The documentation covers that.

Thanks @Badger now i can send data with basic auth. But logstash returns error when i use keystore for password.
I have added the LS_PWD for password;

/usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash list
Using bundled JDK: /usr/share/logstash/jdk
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Warning: Nashorn engine is planned to be removed from a future JDK release
Warning: Nashorn engine is planned to be removed from a future JDK release
Warning: Nashorn engine is planned to be removed from a future JDK release
2021-03-12 19:54:18,516 main ERROR Unable to locate appender "${sys:ls.log.format}_console" for logger config "root"
2021-03-12 19:54:18,518 main ERROR Unable to locate appender "${sys:ls.log.format}_rolling" for logger config "root"
2021-03-12 19:54:18,519 main ERROR Unable to locate appender "${sys:ls.log.format}_rolling_slowlog" for logger config "slowlog"
2021-03-12 19:54:18,519 main ERROR Unable to locate appender "${sys:ls.log.format}_console_slowlog" for logger config "slowlog"
ERROR: Failed to load settings file from "path.settings". Aborting... path.setting=/etc/logstash, exception=NameError, message=>uninitialized constant LogStash::Util::Password

es_pwd
es_usr
ls_pwd

Then i passed in input section;

input {
  http {
    user => "alican"
    password => "${LS_PWD}"
    port => 9605
    type => "north"
    codec => "json"
  }
}

ERROR;

[ERROR] 2021-03-12 19:53:54.570 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"Java::JavaLang::IllegalStateException", :message=>"Unable to configure plugins: Cannot evaluate `${ls_pwd}`. Replacement variable `ls_pwd` is not defined in a Logstash secret store or an environment entry and there is no default value given."

I think the input section does not support secret store but its works with environment variable export LS_PWD="mypassword"

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