Ingress access logging content is missing due to the maximum length 1024 bytes in OpenShift Container Platform 4

Solution Verified - Updated -

Issue

  • Ingress access logging content is missing due to the default HAProxy maximum length 1024 bytes in OpenShift Container Platform 4 when using
    Configuring Ingress access logging with the httpLogFormat option to output the self-specific json format.

If the access logging content length is more than the default HAProxy maximum length 1024 bytes, it will be an incomplete json log and cannot be read by the backend log system.

Here is a sample for configuring the ingress access logging as the json format(if the customized json format is too long that will be over 1024 bytes):

# oc edit ingresscontroller -n openshift-ingress-operator
spec:
  logging:
    access:
      destination:
        syslog:
          address: 192.168.14.10
          port: 514
        type: Syslog
      httpLogFormat: '{"type":"router-log","log_format":"http","nodename":"%H","timestamp":"%[date,ltime(%Y/%m/%d %T)]","http_method":"%HM","url":"http://%[capture.req.hdr(0)]%HU","user-agent":"%[capture.req.hdr(1)]","x-forwarded-for":"%ci","x-forwarded-proto":"%[capture.req.hdr(3)]","response_time":%Tr,"status_code":%ST,"client_ip":"%ci","client_port":%cp,"bytes_uploaded":%U,"server_ip":"%si","server_port":"%sp","backend_name":"%b","backend_server":"%s","retries":%rc,"bytes_read":%B,"upstream_connect_time":%Tc,"session_duration":%Tt,"termination_state":"%ts"}'

Use wc -c to print access logging byte counts for the self-specific json format.

# echo '{"type":"router-log","log_format":"http","nodename":"worker-2.ocp4.example.com","timestamp":"2021/07/27 13:58:28","http_method":"GET","url":"http://-/","user-agent":"-","x-forwarded-for":"192.168.14.10","x-forwarded-proto":"-","response_time":5,"status_code":200,"client_ip":"192.168.14.10","client_port":36182,"bytes_uploaded":93,"server_ip":"10.131.0.34","server_port":"8080","backend_name":"be_http:httpecho:example","backend_server":"pod:http-https-echo-79664f4f97-jgp8w:http-https-echo:8080-tcp:10.131.0.34:8080","retries":0,"bytes_read":975,"upstream_connect_time":1,"session_duration":6,"termination_state":"--"}' | wc -c
620

Environment

  • Openshift Container Platform (OCP)
    • 4.5 and above

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content