Uploaded image for project: 'OpenShift Logging'
  1. OpenShift Logging
  2. LOG-4573

Add HTTP 1.1 protocol tracing to Vector

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Normal Normal
    • Logging 5.8.0
    • Logging 5.8.0
    • Log Collection
    • None
    • 1
    • False
    • None
    • False
    • NEW
    • NEW
    • If Release Note Needed, Set a Value
    • Log Collection - Sprint 243

      The `hyper` crate is the place to add HTTP protocol tracing in Vector. It is enabled with the trace log level in the hyper crate, with either 'hyper=trace' in the VECTOR_LOG environment variable, or setting VECTOR_LOG=trace. HTTP requests are traced just before they are put on the wire and HTTP responses are traced just after they are read off the wire. The contents of the HTTP requests and responses are placed on separate lines without the usual log line prefix and surrounded by chevrons: >>> and <<<.
      The `hyper` crate should underlie all the HTTP sources and sinks in vector, so adding HTTP tracing there should enable it for all the sources and sinks that use HTTP.

      Sources/sinks verified to work:

      • AWS CloudWatch
      • Elasticsearch
        ? Splunk

      For example, forwarding logs to AWS CloudWatch:

      LOG=vector=info,codec=info,vrl=info,buffers=info,hyper=trace ~/rust/vector/target/debug/vector -c ~/syslog/vector_cw.toml
      
      2023-10-02T22:05:49.181512Z TRACE encode_headers: hyper::proto::h1::role: Client::encode method=POST, body=Some(Known(43))
      2023-10-02T22:05:49.181885Z TRACE hyper::proto::h1::encode: sized write, len = 43
      2023-10-02T22:05:49.181959Z TRACE hyper::proto::h1::io: buffer.flatten self.len=611 buf.len=43
      2023-10-02T22:05:49.182188Z DEBUG hyper::proto::h1::io: flushed 654 bytes
      2023-10-02T22:05:49.182242Z TRACE hyper::proto::h1::io: WriteBuf { remaining: 654, strategy: Flatten, headers: Cursor { pos: 0, len: 654 } }
      >>>
      POST / HTTP/1.1
      content-type: application/x-amz-json-1.1
      x-amz-target: Logs_20140328.DescribeLogGroups
      content-length: 43
      user-agent: aws-sdk-rust/0.51.0 os/linux lang/rust/1.66.1
      x-amz-user-agent: aws-sdk-rust/0.51.0 api/cloudwatchlogs/0.21.0 os/linux lang/rust/1.66.1
      x-amz-date: 20231002T220548Z
      authorization: AWS4-HMAC-SHA256 Credential=####################/20231002/us-east-2/logs/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-target;x-amz-user-agent, Signature=################################################################
      host: logs.us-east-2.amazonaws.com
      
      {"logGroupNamePrefix":"MyGroupNamePrefix","limit":1}
      <<<
      2023-10-02T22:05:49.182407Z TRACE hyper::proto::h1::conn: flushed({role=client}): State { reading: Init, writing: KeepAlive, keep_alive: Busy }
      ...
      2023-10-02T22:05:49.254610Z TRACE hyper::proto::h1::conn: Conn::read_head
      2023-10-02T22:05:49.254848Z TRACE hyper::proto::h1::io: received 175 bytes
      2023-10-02T22:05:49.254899Z TRACE hyper::proto::h1::io: ReadBuf { filled: 175, initialized: 175, capacity: 8192 }
      >>>
      HTTP/1.1 200 OK
      x-amzn-RequestId: 2f128056-ed49-4a58-959c-25ebfb7e7877
      Content-Type: application/x-amz-json-1.1
      Content-Length: 175
      Date: Mon, 02 Oct 2023 22:05:49 GMT
      
      
      <<<
      ...
      2023-10-02T22:05:49.255175Z TRACE parse_headers: hyper::proto::h1::role: Response.parse bytes=175
      2023-10-02T22:05:49.255360Z TRACE parse_headers: hyper::proto::h1::role: Response.parse Complete(175)
      2023-10-02T22:05:49.255682Z DEBUG hyper::proto::h1::io: parsed 4 headers
      2023-10-02T22:05:49.255732Z DEBUG hyper::proto::h1::conn: incoming body is content-length (175 bytes)
      2023-10-02T22:05:49.255879Z TRACE hyper::proto::h1::decode: decode; state=Length(175)
      2023-10-02T22:05:49.256077Z TRACE hyper::proto::h1::io: received 175 bytes
      2023-10-02T22:05:49.256118Z TRACE hyper::proto::h1::io: ReadBuf { filled: 175, initialized: 175, capacity: 8192 }
      >>>
      {"logGroups":[{"arn":"arn:aws:logs:us-east-2:############:log-group:MyGroupNamePrefix:*","creationTime":1696261986343,"logGroupName":"MyGroupNamePrefix","metricFilterCount":0,"storedBytes":0}]}
      <<<
      

            syedriko_sub@redhat.com Sergey Yedrikov
            syedriko_sub@redhat.com Sergey Yedrikov
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: