Skip to content
Merged
206 changes: 112 additions & 94 deletions pipeline/outputs/http.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HTTP

The **http** output plugin allows to flush your records into a HTTP endpoint. For now the functionality is pretty basic and it issues a POST request with the data records in [MessagePack](http://msgpack.org) (or JSON) format.
The **http** output plugin allows to flush your records into an HTTP endpoint. For now the functionality is pretty basic, and it issues a POST request with the data records in [MessagePack](http://msgpack.org) (or JSON) format.

## Configuration Parameters

Expand All @@ -21,7 +21,7 @@ The **http** output plugin allows to flush your records into a HTTP endpoint. Fo
| compress | Set payload compression mechanism. Option available is 'gzip' | |
| format | Specify the data format to be used in the HTTP request body, by default it uses _msgpack_. Other supported formats are _json_, _json\_stream_ and _json\_lines_ and _gelf_. | msgpack |
| allow\_duplicated\_headers | Specify if duplicated headers are allowed. If a duplicated header is found, the latest key/value set is preserved. | true |
| log\_response\_payload | Specify if the response paylod should be logged or not. | true |
| log\_response\_payload | Specify if the response payload should be logged or not. | true |
| header\_tag | Specify an optional HTTP header field for the original message tag. | |
| header | Add a HTTP header key/value pair. Multiple headers can be set. | |
| json\_date\_key | Specify the name of the time key in the output record. To disable the time key just set the value to `false`. | date |
Expand All @@ -42,55 +42,58 @@ For more details about the properties available and general configuration, see [

## Getting Started

In order to insert records into a HTTP server, you can run the plugin from the command line or through the configuration file:
In order to insert records into an HTTP server, you can run the plugin from the command line or through the configuration file:

### Command Line

The **http** plugin, can read the parameters from the command line in two ways, through the **-p** argument (property) or setting them directly through the service URI. The URI format is the following:

```
```text
http://host:port/something
```

Using the format specified, you could start Fluent Bit through:

```
```shell
fluent-bit -i cpu -t cpu -o http://192.168.2.3:80/something -m '*'
```

### Configuration File

In your main configuration file, append the following _Input_ & _Output_ sections:
In your main configuration file append the following:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
inputs:
- name: cpu
tag: cpu
outputs:
- name: http
match: '*'
host: 192.168.2.3
port: 80
uri: /something
```

{% endtab %}
{% tab title="fluent-bit.conf" %}
```python

```text
[INPUT]
Name cpu
Tag cpu
Name cpu
Tag cpu

[OUTPUT]
Name http
Match *
Host 192.168.2.3
Port 80
URI /something
Name http
Match *
Host 192.168.2.3
Port 80
URI /something
```
{% endtab %}

{% tab title="fluent-bit.yaml" %}
```yaml
pipeline:
inputs:
- name: cpu
tag: cpu
outputs:
- name: http
match: '*'
host: 192.168.2.3
port: 80
URI: /something
```
{% endtab %}
{% endtabs %}

Expand All @@ -101,37 +104,42 @@ Another approach we also support is the sending the original message tag in a co
To configure this behaviour, add this config:

{% tabs %}
{% tab title="fluent-bit.conf" %}
```
[OUTPUT]
Name http
Match *
Host 192.168.2.3
Port 80
URI /something
Format json
header_tag FLUENT-TAG
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:

outputs:
- name: http
match: '*'
host: 192.168.2.3
port: 80
uri: /something
format: json
header_tag: FLUENT-TAG
```

{% endtab %}
{% tab title="fluent-bit.conf" %}

{% tab title="fluent-bit.yaml" %}
```yaml
outputs:
- name: http
match: '*'
host: 192.168.2.3
port: 80
URI: /something
format: json
header_tag: FLUENT-TAG
```text
[OUTPUT]
Name http
Match *
Host 192.168.2.3
Port 80
URI /something
Format json
header_tag FLUENT-TAG
```

{% endtab %}
{% endtabs %}


Provided you are using Fluentd as data receiver, you can combine `in_http` and `out_rewrite_tag_filter` to make use of this HTTP header.

```
```text
<source>
@type http
add_http_headers true
Expand All @@ -152,31 +160,36 @@ Notice how we override the tag, which is from URI path, with our custom header
#### Example : Add a header

{% tabs %}
{% tab title="fluent-bit.conf" %}
```
[OUTPUT]
Name http
Match *
Host 127.0.0.1
Port 9000
Header X-Key-A Value_A
Header X-Key-B Value_B
URI /something
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:

outputs:
- name: http
match: '*'
host: 127.0.0.1
port: 9000
header:
- X-Key-A Value_A
- X-Key-B Value_B
uri: /something
```

{% endtab %}
{% tab title="fluent-bit.conf" %}

{% tab title="fluent-bit.yaml" %}
```yaml
outputs:
- name: http
match: '*'
host: 127.0.0.1
port: 9000
header:
- X-Key-A Value_A
- X-Key-B Value_B
URI: /something
```text
[OUTPUT]
Name http
Match *
Host 127.0.0.1
Port 9000
Header X-Key-A Value_A
Header X-Key-B Value_B
URI /something
```

{% endtab %}
{% endtabs %}

Expand All @@ -185,40 +198,45 @@ Notice how we override the tag, which is from URI path, with our custom header
Suggested configuration for Sumo Logic using `json_lines` with `iso8601` timestamps. The `PrivateKey` is specific to a configured HTTP collector.

{% tabs %}
{% tab title="fluent-bit.conf" %}
```
[OUTPUT]
Name http
Match *
Host collectors.au.sumologic.com
Port 443
URI /receiver/v1/http/[PrivateKey]
Format json_lines
Json_date_key timestamp
Json_date_format iso8601
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:

outputs:
- name: http
match: '*'
host: collectors.au.sumologic.com
port: 443
uri: /receiver/v1/http/[PrivateKey]
format: json_lines
json_date_key: timestamp
json_date_format: iso8601
```

{% endtab %}
{% tab title="fluent-bit.conf" %}

{% tab title="fluent-bit.yaml" %}
```yaml
outputs:
- name: http
match: '*'
host: collectors.au.sumologic.com
port: 443
URI: /receiver/v1/http/[PrivateKey]
format: json_lines
json_date_key: timestamp
json_date_format: iso8601
```text
[OUTPUT]
Name http
Match *
Host collectors.au.sumologic.com
Port 443
URI /receiver/v1/http/[PrivateKey]
Format json_lines
Json_date_key timestamp
Json_date_format iso8601
```

{% endtab %}
{% endtabs %}

A sample Sumo Logic query for the [CPU](../inputs/cpu-metrics.md) input. \(Requires `json_lines` format with `iso8601` date format for the `timestamp` field\).

```
```text
_sourcecategory="my_fluent_bit"
| json "cpu_p" as cpu
| timeslice 1m
| max(cpu) as cpu group by _timeslice
```
```
Loading