Bug 1600171

Summary: Rsyslog omelasticsearch does not work with ES 6.x strict headers
Product: Red Hat Enterprise Linux 7 Reporter: Lukas Zapletal <lzap>
Component: rsyslogAssignee: Jiří Vymazal <jvymazal>
Status: CLOSED ERRATA QA Contact: Dalibor Pospíšil <dapospis>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.5CC: dapospis, dkopecek, emarcus, jherrman, jonassteinberg1, jvymazal, lvlcek, mmagr, pportant, rmeggins, sradco, tjaros
Target Milestone: rcKeywords: AutoVerified, Patch, Reopened, Triaged
Target Release: 7.8   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rsyslog-8.24.0-48.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 19:10:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1649308    
Attachments:
Description Flags
set content-type: application/json; charset=utf-8 none

Description Lukas Zapletal 2018-07-11 15:06:38 UTC
Hey,

# rpm -q rsyslog rsyslog-elasticsearch
rsyslog-8.24.0-16.el7_5.4.x86_64
rsyslog-elasticsearch-8.24.0-16.el7_5.4.x86_64

Rsyslog in RHEL 7.5 is not able to push data into Elastic 6.x due to breaking API change - https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests

It used to be opt-out, now in 6.x series this can't be configured anymore:

# curl -i -H "Content-Type: xxx" -XGET 'http://localhost:9200/' -d '{}\n'
HTTP/1.1 200 OK
Warning: 299 Elasticsearch-5.4.3-eed30a8 "Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header." "Wed, 26 Jul 2017 14:33:28 GMT"

Now in 6.x:

# curl -i -H "Content-Type: xxx" -XGET 'http://localhost:9200/' -d '{}\n'
HTTP/1.1 406 Not Acceptable
content-type: application/json; charset=UTF-8
content-length: 74

{"error":"Content-Type header [xxx] is not supported","status":406}

Upstream does seem to send the header correctly, I request backport of this into RHEL7 please.

https://github.com/rsyslog/rsyslog/commit/462be8b2ee4747a5317930d11018ce5ccb3726e0
https://github.com/rsyslog/rsyslog/commit/50d8e5cb391d8e0b984c725066a688da8b723b61

Thanks!

Comment 2 Lukas Zapletal 2018-07-11 15:09:53 UTC
REPRODUCER:

Install RHEL 7.5 and:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-6.3.1.rpm
rpm -i elasticsearch-oss-6.3.1.rpm
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch.service

Create config:
module(load="omelasticsearch")
template(name="viaq_template" type="list") {
    property(name="$!all-json-plain")
}
action(
    type="omelasticsearch"
    server="localhost"
    serverport="9200"
    template="viaq_template"
    searchIndex="template1"
    errorfile="/var/lib/rsyslog/es-errors.log"
)

And see es-errors.log:

        "request":      {
                "url":  "http://localhost:9200/project.foreman-2018-11-07/events",
                "postdata":     "{\"message\":\"Completed 200 OK in 20ms (Views: 1.3ms | ActiveRecord: 8.4ms)\\n\",\"level\":\"info\",\"hostname\":\"next\",\"@timestamp\":\"2018-07-11T16:08:47.980943+01:00\",\"systemd\":{\"t\":{\"MACHINE_ID\":\"ce37bff78932646b63dbb85e691a3808\",\"BOOT_ID\":\"0b261792c25849a4b028268ada1ae861\",\"CAP_EFFECTIVE\":\"0\",\"CMDLINE\":\"Passenger RackApp: \\/usr\\/share\\/foreman                                      \",\"COMM\":\"ruby\",\"EXE\":\"\\/opt\\/rh\\/rh-ruby24\\/root\\/usr\\/bin\\/ruby\",\"GID\":\"991\",\"HOSTNAME\":\"next.nat.lan\",\"PID\":\"2630\",\"SELINUX_CONTEXT\":\"system_u:system_r:passenger_t:s0\",\"SOURCE_REALTIME_TIMESTAMP\":\"1531321727980804\",\"SYSTEMD_CGROUP\":\"\\/system.slice\\/httpd.service\",\"SYSTEMD_SLICE\":\"system.slice\",\"SYSTEMD_UNIT\":\"httpd.service\",\"TRANSPORT\":\"journal\",\"UID\":\"993\"},\"u\":{\"SYSLOG_FACILITY\":\"176\",\"SYSLOG_IDENTIFIER\":\"foreman\"}},\"MESSAGE\":\"Completed 200 OK in 20ms (Views: 1.3ms | ActiveRecord: 8.4ms)\\n\",\"msg\":\"Completed 200 OK in 20ms (Views: 1.3ms | ActiveRecord: 8.4ms)\",\"foreman\":{\"logger\":\"app\",\"user_login\":\"admin\",\"remote_ip\":\"192.168.199.1\",\"request\":\"6c3cbb4b-e731-4481-9060-63d57d719dbb\",\"session\":\"61feb0a7-479a-40cd-a4f2-50a365258734\"}}"
        },
        "reply":        {
                "error":        "Content-Type header [text/json; charset=utf-8] is not supported",
                "status":       406
        }

Comment 3 Lukas Vlcek 2018-07-11 15:15:23 UTC
I think we already have ticket for it here: https://github.com/openshift/origin-aggregated-logging/issues/625

This will be implemented once we upgrade to ES 6.x I would not expect us to implement it before we finish upgrade to ES 5.x

Comment 4 Rich Megginson 2018-07-16 21:58:54 UTC
Created attachment 1459274 [details]
set content-type: application/json; charset=utf-8

Comment 7 Jonas Steinberg 2018-11-02 19:30:13 UTC
Is there any update on this?  It's effecting my ES 6 infrastructure.  I'd be happy to help in any way that I can.

Comment 8 Jiří Vymazal 2019-03-26 09:23:27 UTC
This issue was not selected to be included either in Red Hat Enterprise Linux 7.7 because it is seen either as low or moderate impact to a small amount of use-cases. The next release will be in Maintenance Support 1 Phase, which means that qualified Critical and Important Security errata advisories (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be released as they become available. We will now close this issue, but if you believe that it qualifies for the Maintenance Support 1 Phase, please re-open; otherwise we recommend moving the request to Red Hat Enterprise Linux 8 if applicable.

Comment 10 Rich Megginson 2019-08-05 21:50:17 UTC
Shirly, Martin - FYI

Comment 45 errata-xmlrpc 2020-03-31 19:10:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:1000