Skip to content

[Packetbeat] HTTP: Improve support for 100-continue #15830

@adriansr

Description

@adriansr

Packetbeat lacks support for 100-continue request/response, which looks like:

  1. Client: sends request headers including Expect: 100-continue.
  2. Server: responds with 100 status code (or an error, which terminates the request).
  3. Client: sends the request body.
  4. Server: Answers with a full response.

Currently this is causing Packetbeat to:

  1. Output an error document with "unmatched response" for the 100-continue response(2).
  2. Output a correct document for the rest (1,3,4).

Example with Packetbeat monitoring port 9200 for http:

curl -H 'Expect: 100-continue' -H 'Content-Type: application/json' -XPOST 'http://localhost:9200/filebeat/_doc/mydoc' --data '{}'

Produces:

{
  "error": {
    "message": "Unmatched response"
  },
  "status": "Error",
  "type": "http",
  "http": {
    "response": {
      "status_code": 100,
      "bytes": 25,
      "headers": {
        "content-length": 0
      },
      "status_phrase": "continue"
    }
  },
  [...]
}

and

{
  "type": "http",
  "query": "POST /filebeat/_doc/mydoc",
  "status": "OK",
  "user_agent": {
    "original": "curl/7.54.0"
  },
  "method": "post",
  "http": {
    "version": "1.1",
    "request": {
      "method": "post",
      "bytes": 173,
      "body": {
        "bytes": 2
      },
      "headers": {
        "content-type": "application/json",
        "content-length": 2
      }
    },
    "response": {
      "headers": {
        "content-type": "application/json; charset=UTF-8",
        "content-length": 160
      },
      "status_phrase": "ok",
      "status_code": 200,
      "bytes": 247,
      "body": {
        "bytes": 160
      }
    }
  },
  "url": {
    "port": 9200,
    "path": "/filebeat/_doc/mydoc",
    "full": "http://localhost:9200/filebeat/_doc/mydoc",
    "scheme": "http",
    "domain": "localhost"
  }
  [...]
}

A simple workaround is to drop the events which contain this error:

processors:
  - drop_event.when:
     and:
     - equals.http.response.status_code: 100
     - equals.error.message: 'Unmatched response'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions