You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Allow HTTP receiver to specify text payloads (#2931)
* spike out http receiver supporting text payloads
* newlines at EOF of test file inputs
* update golden with newline removal
* update to check header before trying to parse as JSON
* accomodate windows different line termination characters in test case
* for now just check for non-empty content type before treating as JSON
* use switch statement for content type and persist old behavior
* update readme based off recent changes
* chore(test): Split tests in ci (#2933)
* add raw config parameter
* normalize lines for windows in golden test
* remove test line expectation
* pr feedback; update comments and wording
* update content-type to always try to parse JSON even if not application/json
---------
Co-authored-by: Joseph Sirianni <joe.sirianni@observiq.com>
Copy file name to clipboardExpand all lines: receiver/httpreceiver/README.md
+54-2Lines changed: 54 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# HTTP Receiver
2
-
This receiver is capable of collecting logs for a variety of services, serving as a default HTTP log receiver. Anything that is able to send JSON structured logs to an endpoint using HTTP will be able to utilize this receiver.
2
+
This receiver is capable of collecting logs for a variety of services, serving as a default HTTP log receiver. Anything that is able to send logs to an endpoint using HTTP will be able to utilize this receiver.
-**JSON Array**: Multiple log entries as an array of JSON objects
27
+
```json
28
+
[
29
+
{"message": "first log", "level": "info"},
30
+
{"message": "second log", "level": "debug"}
31
+
]
32
+
```
33
+
34
+
### Text Payloads (`Content-Type: text/*`)
35
+
Plain text payloads with a `text/*` content type (e.g., `text/plain`) are automatically wrapped in a log structure with a `body` field:
36
+
```
37
+
This is a plain text log message
38
+
```
39
+
40
+
### No Content-Type Header
41
+
For backward compatibility, if no `Content-Type` header is provided, the receiver will attempt to parse the payload as JSON. If the payload is not valid JSON, the request will be rejected with a 422 status code.
42
+
43
+
### Important Notes
44
+
- If `Content-Type: application/json` is specified but the payload is not valid JSON, the request will be rejected with a 422 status code.
45
+
- Content types with `+json` suffix (e.g., `application/ld+json`) are treated as JSON.
46
+
- Any other content types not explicitly supported will be rejected with a 422 status code.
47
+
- When the `raw` configuration parameter is set to `true`, all content-type detection is bypassed and payloads are always treated as plain text.
17
48
18
49
## Configuration
19
50
| Field | Type | Default | Required | Description |
| endpoint | string ||`true`| The hostname and port the receiver should listen on for logs being sent as HTTP POST requests. |
22
53
| path | string ||`false`| Specifies a path the receiver should be listening to for logs. Useful when the log source also sends other data to the endpoint, such as metrics. |
54
+
| raw | bool |`false`|`false`| When set to `true`, all payloads will be treated as plain text regardless of the `Content-Type` header. The entire payload will be stored as a string in the log body. |
23
55
| tls.key_file | string ||`false`| Configure the receiver to use TLS. |
24
56
| tls.cert_file | string ||`false`| Configure the receiver to use TLS. |
25
57
@@ -59,3 +91,23 @@ service:
59
91
receivers: [http]
60
92
exporters: [googlecloud]
61
93
```
94
+
95
+
### Example Configuration With Raw Mode
96
+
Use `raw: true` to force all incoming payloads to be treated as plain text, regardless of `Content-Type` header. This is useful when you want to preserve the exact format of incoming logs without any JSON parsing.
0 commit comments