elastic / elasticsearch-metrics-reporter-java

Metrics reporter, which reports to elasticsearch
Apache License 2.0
230 stars 103 forks source link

Unable to connect to elasticsearch when shield plugin is used. #43

Closed psbalaji closed 8 years ago

psbalaji commented 8 years ago

I am getting the following error while connecting to elasticsearch.

Reporting returned code 401 Unauthorized: {}

I am using shield plugin with elasticsearch and how do I pass the username and password?

psbalaji commented 8 years ago

We should send the username and password for authentication before posting any data. The following code worked. Authenticator.setDefault (new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication ("username", "password".toCharArray()); } });