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
curl -X POST -d "$ndjson" http://localhost:9880/app.log
45
+
```
46
+
47
+
Example: post MessagePack data with the tag "app.log":
48
+
49
+
```bash
50
+
msgpack=`echo -e "msgpack=\x81\xa3foo\xa3bar"`
51
+
curl -X POST -d "$msgpack" http://localhost:9880/app.log
52
+
```
53
+
54
+
Some `Content-Type` other than `application/x-www-form-urlencoded` support specific formats.
55
+
In that case, the format type specification as `json=` in the data is not necessary.
56
+
57
+
Example: Post JSON data with `Content-Type: application/json`:
58
+
59
+
```bash
60
+
curl -X POST -d '{"foo":"bar"}' -H 'Content-Type: application/json' \
61
+
http://localhost:9880/app.log
30
62
```
31
63
32
64
**For more details regarding the message body syntax and `Content-Type` see [How to use HTTP Content-Type Header](http.md#how-to-use-http-content-type-header)**
`in_http` plugin recognizes HTTP `Content-Type` header in the incoming requests.
232
264
233
-
By default `curl` uses `-H "Content-Type: application/x-www-form-urlencoded"`, which allows the use of the syntax `json=` and `msgpack=` as seen on the previous examples.
234
-
265
+
If you use the default `<parse>` setting, the data format depends on the `Content-Type`.
266
+
(If you set the `<parse>` directive to use a specific Parser, the `Content-Type` is not used).
235
267
236
-
However, you can send a JSON payload without the `json=` prefix by setting the content type `application/json`:
268
+
By default `curl` uses `-H "Content-Type: application/x-www-form-urlencoded"`, which allows the use of the prefix `json=`, `ndjson=`, and `msgpack=` as seen on the previous examples.
237
269
238
-
```text
239
-
$ curl -X POST -d '{"foo":"bar"}' -H 'Content-Type: application/json' \
270
+
On the other hand, some `Content-Type` other than `application/x-www-form-urlencoded` support specific formats.
271
+
In that case, the prefix such as `json=` in the data is not necessary.
272
+
273
+
Here is the list of supported `Content-Type`:
274
+
275
+
|`Content-Type`| data format | version |
276
+
| :--- | :--- | :--- |
277
+
|`application/json`| JSON | - |
278
+
|`application/csp-report`| JSON | 1.17.0 |
279
+
|`application/msgpack`| MessagePack | - |
280
+
|`application/x-ndjson`| NDJSON | 1.14.5 |
281
+
282
+
Examples:
283
+
284
+
```bash
285
+
curl -X POST -d '{"foo":"bar"}' -H 'Content-Type: application/json' \
240
286
http://localhost:9880/app.log
241
287
```
242
288
243
-
To use MessagePack, set the content type to `application/msgpack`:
244
-
245
-
```text
246
-
$ msgpack=`echo -e "\x81\xa3foo\xa3bar"`
247
-
$ curl -X POST -d "$msgpack" -H 'Content-Type: application/msgpack' \
289
+
```bash
290
+
msgpack=`echo -e "\x81\xa3foo\xa3bar"`
291
+
curl -X POST -d "$msgpack" -H 'Content-Type: application/msgpack' \
248
292
http://localhost:9880/app.log
249
293
```
250
294
295
+
Also, you can use `multipart/form-data`.
296
+
For more details about `multipart/form-data`, please see [Why `in_http` removes '+' from my log](http.md#why-in_http-removes--from-my-log).
297
+
251
298
### Handle Other Formats using Parser Plugins
252
299
253
300
You can handle various input formats by using the `<parse>` directive. For example, add the following settings to the configuration file:
0 commit comments