-
Bug
-
Resolution: Done
-
Normal
-
Logging 5.5.5
-
False
-
None
-
False
-
NEW
-
Impediment
-
NEW
-
-
-
-
Log Collection - Sprint 233
-
Moderate
-
Customer Escalated
RHOL version: current latest 5.5.5
Log forwarding to an Elasticsearch when using username and password is not working with error:
$ oc logs <collector> -c collector -n openshift-logging 2022-12-26 10:29:34 +0000 [warn]: [elasticsearch] failed to flush the buffer. retry_times=6 next_retry_time=2022-12-26 10:30:28 +0000 chunk="5f0b5b13770faab407f0596dbbb6aace" error_class=Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure error="could not push logs to Elasticsearch cluster ({:host=>\"elasticsearch.example.com\", :port=>9200, :scheme=>\"http\", :user=>\"<elastic username>\\n\", :password=>\"obfuscated\"}): [401] {\"error\":{\"root_cause\":[{\"type\":\"security_exception\",\"reason\":\"unable to authenticate user [<elastic username>\\n] for REST request [/_bulk]\",\"header\":{\"WWW-Authenticate\":[\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\",\"Bearer realm=\\\"security\\\"\",\"ApiKey\"]}}],\"type\":\"security_exception\",\"reason\":\"unable to authenticate user [<elastic username>\\n] for REST request [/_bulk]\",\"header\":{\"WWW-Authenticate\":[\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\",\"Bearer realm=\\\"security\\\"\",\"ApiKey\"]}},\"status\":401}"
The username and the password are valid, for two reasons:
- Using curl works
$ oc -n openshift-logging rsh <collector pod> sh-4.4# curl -u $(cat /var/run/ocp-collector/secrets/external-elasticsearch/username):$(cat /var/run/ocp-collector/secrets/external-elasticsearch/password) http://elasticsearch.example.com:9200/_cat/nodes 10.88.0.5 59 87 10 0.77 0.82 0.95 mdi * m8Ua3d5
2. When using for workarounding it, fluentd starts to deliver the logs. The WORKAROUND is:
Move to Unmanaged the CLO for not modifying the configurations
$ oc project openshift-logging
$ oc -n openshift-logging patch clusterlogging/instance -p '\{"spec":{"managementState": "Unmanaged"}}' --type=merge
Backup the collector cm
$ oc -n openshift-logging get cm collector > cm_collector.yml $ oc -n openshift-logging edit cm collector
Needed to change in the 2 sections below:
<match retry_elasticsearch> @type elasticsearch @id retry_elasticsearch host elasticsearch.example.com ... user "#\{File.exists?('/var/run/ocp-collector/secrets/external-elasticsearch/username') ? open('/var/run/ocp-collector/secrets/external-elasticsearch/username','r') do |f|f.read end : ''}" password "#\{File.exists?('/var/run/ocp-collector/secrets/external-elasticsearch/password') ? open('/var/run/ocp-collector/secrets/external-elasticsearch/password','r') do |f|f.read end : ''}"
And this:
<match **> @type elasticsearch @id elasticsearch host elasticsearch.example.com ... user "#\{File.exists?('/var/run/ocp-collector/secrets/external-elasticsearch/username') ? open('/var/run/ocp-collector/secrets/external-elasticsearch/username','r') do |f|f.read end : ''}" password "#\{File.exists?('/var/run/ocp-collector/secrets/external-elasticsearch/password') ? open('/var/run/ocp-collector/secrets/external-elasticsearch/password','r') do |f|f.read end : ''}"
Modify the lines below in the previous entries:
user "#\{File.exists?('/var/run/ocp-collector/secrets/external-elasticsearch/username') ? open('/var/run/ocp-collector/secrets/external-elasticsearch/username','r') do |f|f.read end : ''}" password "#\{File.exists?('/var/run/ocp-collector/secrets/external-elasticsearch/password') ? open('/var/run/ocp-collector/secrets/external-elasticsearch/password','r') do |f|f.read end : ''}"
By:
user "<username>" password "<password>"
Restart the collectors to take the new configuration:
$ oc -n openshift-logging delete pods -l component=collector