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 (or JSON) format.

Configuration Parameters

Key Description default
host IP address or hostname of the target HTTP Server 127.0.0.1
http_User Basic Auth Username
http_Passwd Basic Auth Password. Requires HTTP_User to be set
port TCP port of the target HTTP Server 80
Proxy Specify an HTTP Proxy. The expected format of this value is http://host:port. Note that https is not supported yet. Please consider not setting this and use HTTP_PROXY environment variable instead, which supports both http and https.
uri Specify an optional HTTP URI for the target web server, e.g: /something /
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
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
json_date_format Specify the format of the date. Supported formats are double, epoch and iso8601 (eg: 2018-05-30T09:39:52.000681Z) double
gelf_timestamp_key Specify the key to use for timestamp in gelf format
gelf_host_key Specify the key to use for the host in gelf format
gelf_short_message_key Specify the key to use as the short message in gelf format
gelf_full_message_key Specify the key to use for the full message in gelf format
gelf_level_key Specify the key to use for the level in gelf format

TLS / SSL

HTTP output plugin supports TTL/SSL, for more details about the properties available and general configuration, please refer to the TLS/SSL section.

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:

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:

  1. http://host:port/something

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

  1. $ 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:

  1. [INPUT]
  2. Name cpu
  3. Tag cpu
  4. [OUTPUT]
  5. Name http
  6. Match *
  7. Host 192.168.2.3
  8. Port 80
  9. URI /something

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

Another approach we also support is the sending the original message tag in a configurable header. It’s up to the receiver to do what it wants with that header field: parse it and use it as the tag for example.

To configure this behaviour, add this config:

  1. [OUTPUT]
  2. Name http
  3. Match *
  4. Host 192.168.2.3
  5. Port 80
  6. URI /something
  7. Format json
  8. header_tag FLUENT-TAG

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.

  1. <source>
  2. @type http
  3. add_http_headers true
  4. </source>
  5. <match something>
  6. @type rewrite_tag_filter
  7. <rule>
  8. key HTTP_FLUENT_TAG
  9. pattern /^(.*)$/
  10. tag $1
  11. </rule>
  12. </match>

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

Example : Add a header

  1. [OUTPUT]
  2. Name http
  3. Match *
  4. Host 127.0.0.1
  5. Port 9000
  6. Header X-Key-A Value_A
  7. Header X-Key-B Value_B
  8. URI /something

Example : Sumo Logic HTTP Collector

Suggested configuration for Sumo Logic using json_lines with iso8601 timestamps. The PrivateKey is specific to a configured HTTP collector.

  1. [OUTPUT]
  2. Name http
  3. Match *
  4. Host collectors.au.sumologic.com
  5. Port 443
  6. URI /receiver/v1/http/[PrivateKey]
  7. Format json_lines
  8. Json_date_key timestamp
  9. Json_date_format iso8601

A sample Sumo Logic query for the CPU input. (Requires json_lines format with iso8601 date format for the timestamp field).

  1. _sourcecategory="my_fluent_bit"
  2. | json "cpu_p" as cpu
  3. | timeslice 1m
  4. | max(cpu) as cpu group by _timeslice