Skip to content

pipeline: input: http: style #1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 61 additions & 47 deletions pipeline/inputs/http.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
---
description: The HTTP input plugin allows you to send custom records to an HTTP endpoint.
---

# HTTP

## Configuration Parameters
The _HTTP_ input plugin lets Fluent Bit open an HTTP port that you can then route data to in a dynamic way.

| **Key** | Description | default |
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|---------|
| listen | The address to listen on | 0.0.0.0 |
| port | The port for Fluent Bit to listen on | 9880 |
| tag_key | Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. | |
| buffer_max_size | Specify the maximum buffer size in KB to receive a JSON message. | 4M |
| buffer_chunk_size | This sets the chunk size for incoming JSON messages. These chunks are then stored/managed in the space available by buffer_max_size. | 512K |
| successful_response_code | It allows to set successful response code. `200`, `201` and `204` are supported. | 201 |
| success_header | Add an HTTP header key/value pair on success. Multiple headers can be set. Example: `X-Custom custom-answer` | |
| threaded | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` |
## Configuration parameters

| Key | Description | Default |
| --- | ----------- | ------- |
| `listen` | The address to listen on. | `0.0.0.0` |
| `port` | The port for Fluent Bit to listen on. | `9880` |
| `tag_key` | Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. | _none_ |
| `buffer_max_size` | Specify the maximum buffer size in KB to receive a JSON message. | `4M` |
| `buffer_chunk_size` | This sets the chunk size for incoming JSON messages. These chunks are then stored and managed in the space available by `buffer_max_size`. | `512K` |
| `successful_response_code` | Allows setting successful response code. Supported values: `200`, `201`, and `204` | `201` |
| `success_header` | Add an HTTP header key/value pair on success. Multiple headers can be set. For example, `X-Custom custom-answer` | _none_ |
| `threaded` | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` |

### TLS / SSL

HTTP input plugin supports TLS/SSL, for more details about the properties available and general configuration, please refer to the [Transport Security](../../administration/transport-security.md) section.
HTTP input plugin supports TLS/SSL. For more details about the properties available and general configuration, refer to [Transport Security](../../administration/transport-security.md).

### gzipped content

The HTTP input plugin will accept and automatically handle gzipped content as of v2.2.1 as long as the header `Content-Encoding: gzip` is set on the received data.
The HTTP input plugin will accept and automatically handle gzipped content in version 2.2.1 or later if the header `Content-Encoding: gzip` is set on the received data.

## Getting Started
## Get started

The http input plugin allows Fluent Bit to open up an HTTP port that you can then route data to in a dynamic way. This plugin supports dynamic tags which allow you to send data with different tags through the same input. An example video and curl message can be seen below
This plugin supports dynamic tags which let you send data with different tags through the same input. See the following for an example:

[Link to video](https://asciinema.org/a/375571)

#### How to set tag
### Set a tag

The tag for the HTTP input plugin is set by adding the tag to the end of the request URL. This tag is then used to route the event through the system.
For example, in the following curl message below the tag set is `app.log**. **` because the end path is `/app_log`:

### Curl request
For example, in the following curl message the tag set is `app.log**. **` because the end path is `/app_log`:

```
```shell
curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888/app.log
```

### Configuration File
### Configuration file

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

```python
[INPUT]
name http
listen 0.0.0.0
Expand All @@ -56,9 +55,11 @@ curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application
name stdout
match app.log
```

{% endtab %}

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

```yaml
pipeline:
inputs:
Expand All @@ -69,22 +70,22 @@ pipeline:
- name: stdout
match: app.log
```

{% endtab %}
{% endtabs %}

If you do not set the tag `http.0` is automatically used. If you have multiple HTTP inputs then they will follow a pattern of `http.N` where N is an integer representing the input.
### Configuration file `http.0` example

### Curl request
If you don't set the tag, `http.0` is automatically used. If you have multiple HTTP inputs then they will follow a pattern of `http.N` where `N` is an integer representing the input.

```
```shell
curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888
```

### Configuration File

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

```python
[INPUT]
name http
listen 0.0.0.0
Expand All @@ -94,9 +95,11 @@ curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application
name stdout
match http.0
```

{% endtab %}

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

```yaml
pipeline:
inputs:
Expand All @@ -107,25 +110,26 @@ pipeline:
- name: stdout
match: http.0
```

{% endtab %}
{% endtabs %}

#### How to set tag_key
#### Set `tag_key`

The tag_key configuration option allows to specify the key name that will be used to overwrite a tag. The tag's value will be replaced with the value associated with the specified key. For example, setting tag_key to "custom_tag" and the log event contains a json field with the key "custom_tag" Fluent Bit will use the value of that field as the new tag for routing the event through the system.
The `tag_key` configuration option lets you specify the key name that will be used to overwrite a tag. The tag's value will be replaced with the value associated with the specified key. For example, setting `tag_key` to `custom_tag` and the log event contains a JSON field with the key `custom_tag`. Fluent Bit will use the value of that field as the new tag for routing the event through the system.

### Curl request

```
```shell
curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888/app.log
```

### Configuration File

### Configuration file `tag_key` example

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

```python
[INPUT]
name http
listen 0.0.0.0
Expand All @@ -136,9 +140,11 @@ curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application
name stdout
match value1
```

{% endtab %}

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

```yaml
pipeline:
inputs:
Expand All @@ -150,45 +156,50 @@ pipeline:
- name: stdout
match: value1
```

{% endtab %}
{% endtabs %}

#### How to set multiple custom HTTP header on success
#### Set multiple custom HTTP headers on success

The `success_header` parameter allows to set multiple HTTP headers on success. The format is:
The `success_header` parameter lets you set multiple HTTP headers on success. The format is:

{% tabs %}
{% tab title="fluent-bit.conf" %}
```ini

```python
[INPUT]
name http
success_header X-Custom custom-answer
success_header X-Another another-answer
```

{% endtab %}

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

```yaml
inputs:
- name: http
success_header: X-Custom custom-answer
success_header: X-Another another-answer
```

{% endtab %}
{% endtabs %}

#### Example curl message

#### Example Curl message

```
```shell
curl -d @app.log -XPOST -H "content-type: application/json" http://localhost:8888/app.log
```

### Configuration File
### Configuration file example 3

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

```python
[INPUT]
name http
listen 0.0.0.0
Expand All @@ -198,9 +209,11 @@ curl -d @app.log -XPOST -H "content-type: application/json" http://localhost:888
name stdout
match *
```

{% endtab %}

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

```yaml
pipeline:
inputs:
Expand All @@ -212,11 +225,12 @@ pipeline:
- name: stdout
match: '*'
```

{% endtab %}
{% endtabs %}

### Command Line
### Command line

```
$> fluent-bit -i http -p port=8888 -o stdout
```shell
fluent-bit -i http -p port=8888 -o stdout
```