Shield blocking Watcher to query in Elasticsearch

I am using Elasticsearch with Shield. When I am trying to execute Watcher I am getting the below error.

ElasticsearchSecurityException[missing authentication token for REST request [/_cluster/health]]
at org.elasticsearch.shield.support.Exceptions.authenticationError(Exceptions.java:39)
at org.elasticsearch.shield.authc.DefaultAuthenticationFailureHandler.missingToken(DefaultAuthenticationFailureHandler.java:65)
at org.elasticsearch.shield.authc.InternalAuthenticationService.authenticate(InternalAuthenticationService.java:96)
at org.elasticsearch.shield.rest.ShieldRestFilter.process(ShieldRestFilter.java:71)
at org.elasticsearch.rest.RestController$ControllerFilterChain.continueProcessing(RestController.java:265)
at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:176)
at org.elasticsearch.http.HttpServer.internalDispatchRequest(HttpServer.java:128)

I am trying to create the Watcher with username and password which I was included in roles.yml.

I am using the below code to create Watcher

curl --user XXX:XXX -XPUT 'http://localhost:9200/_watcher/watch/cluster_health' -d '{
"trigger" : {
"schedule" : { "interval" : "10s" }
},
"input" : {
"http" : {
"request" : {
"host" : "localhost",
"port" : 9200,
"path" : "/_cluster/health"
}
}
},
"condition" : {
"compare" : {
"ctx.payload.status" : { "eq" : "Yellow" }
}
}

Do I need to include any properties in shield or elasticsearch.yml or in wtacher.

Thanks in advance!!!

Hey,

you need to supply authentication information, when executing the http request pointing to /_cluster/health.

See the auth setting for the HTTP input. See the http input documentation

--Alex

1 Like

Thank you so much. It resolved the issue.