Skip to content
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

Add docs for http output to send tag in header #55

Merged
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
37 changes: 37 additions & 0 deletions output/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The __http__ output plugin, allows to flush your records into an HTTP end point.
| Proxy | Specify an HTTP Proxy. The expected format of this value is _http:https://host:port_. Note that _https_ is __not__ supported yet. ||
| URI | Specify an optional HTTP URI for the target web server, e.g: /something | / |
| Format | Specify the data format to be used in the HTTP request body, by default it uses _msgpack_. Other supported formats are _json_ and _json_stream_. | msgpack |
| header_tag | Specify an optional HTTP header field for the original message tag. | |

### TLS / SSL

Expand Down Expand Up @@ -54,3 +55,39 @@ In your main configuration file append the following _Input_ & _Output_ sections
Port 80
URI /something
```

By default, the URI becomes tag of the message, the original tag is ignore. To
retain the tag, multiple configuration sections has to be made based and flush
to different URIs.

Another approach we also support is the sending the original message tag
in a configurabled header. It's up to the receiver to do what it want with that
header field: parse it and use it as the tag for example. With fluend
http plugin, it's straightforward.

To configure this behaviour, add this config:

```
[OUTPUT]
Name http
Match *
Host 192.168.2.3
Port 80
URI /something
header_tag FLUENT-TAG
```

Given the default http input fluentd plugin: https://github.com/fluent/fluentd/blob/1afbfb17c833b05757122a53ea14b17af659fd75/lib/fluent/plugin/in_http.rb#L212-L215

We can easily parse the tag like this:

```ruby
@@ -153,6 +153,7 @@ module Fluent::Plugin
begin
path = path_info[1..-1] # remove /
tag = path.split('/').join('.')
+ tag = params["HTTP_FLUENT_TAG"] if params["HTTP_FLUENT_TAG"]
record_time, record = parse_params(params)
```

Notice how we override the tag, which is from URI path, with our custom header