Skip to content

Commit

Permalink
Merge pull request #184 from cosmo0920/1.0-out_http-json_array
Browse files Browse the repository at this point in the history
out_http: json_array documentation
  • Loading branch information
repeatedly authored Jun 9, 2020
2 parents 3fd5e5f + e2d21f1 commit 191f733
Showing 1 changed file with 84 additions and 1 deletion.
85 changes: 84 additions & 1 deletion plugins/output/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,22 @@ The proxy for HTTP request

Content-Type for HTTP request. `out_http` automatically set `Content-Type` for built-in formatters when this parameter is not specified. Here is a table:

* `json`: `application/x-ndjson`
* `json(json_array: false)`: `application/x-ndjson`
* `json(json_array: true)`: `application/json`
* `csv`: `text/csv`
* `tsv`, `ltsv`: `text/tab-separated-values`
* `msgpack`: `application/x-msgpack`
* `out_file`, `single_value`, `stdout`, `hash`: `text/plain`

### json_array

| type | default | version |
|:-------|:--------|:--------|
| bool | false | 1.10.4 |

Using array format of JSON. This parameter is used and valid only for json format.
When `json_array` as true, Content-Type should be `application/json` and be able to use JSON data for the HTTP request body.

### <format> directive

The format of the payload. The default `@type` is `json`. Here is `single_value` example:
Expand Down Expand Up @@ -282,6 +292,79 @@ log line4\n
...
```

## Troubleshooting

### 400 Bad request between out\_http and in\_http

When getting the following error:

```
#0 got unrecoverable error in primary and no secondary error_class=Fluent::UnrecoverableError error="400 Bad Request 400 Bad Request\n'json' or 'msgpack' parameter is required\n"
#0 bad chunk is moved to /tmp/fluent/backup/worker0/object_3ff8a73edae8/5a71a08ca19b1b343c8dce1b74c9a963.log
```

Users should be specify `json` format with `json_array` as true for out\_http configuration:

```
<match **>
@type http
endpoint http://some.your.http.endpoint:9811/your-awesome-path
<format>
@type json
</format>
json_array true
<buffer>
flush_interval 2s
</buffer>
</match>
```

And receiver in\_http configuration should be:

```
<source>
@type http
port 9811
bind 0.0.0.0
<parse>
@type json
</parse>
</source>
```

Or specify msgpack format:

```
<match **>
@type http
endpoint http://some.your.http.endpoint:9882/your-awesome-path
<format>
@type msgpack
</format>
<buffer>
flush_interval 2s
</buffer>
</match>
```

And receiver in\_http configuration should be:

```
<source>
@type http
port 9882
bind 0.0.0.0
<parse>
@type msgpack
</parse>
<format>
@type json
</format>
</source>
```

But, we recommend to use in/out [`forward`](forward.md) plugin to communicate with two Fluentds due to at-most-once and at-least-once semantics for rigidty.

------------------------------------------------------------------------

If this article is incorrect or outdated, or omits critical information, please [let us know](https://github.com/fluent/fluentd-docs-gitbook/issues?state=open).
Expand Down

0 comments on commit 191f733

Please sign in to comment.