GELF
GELF is Graylog Extended Log Format. The GELF output plugin allows to send logs in GELF format directly to a Graylog input using TLS, TCP or UDP protocols.
The following instructions assumes that you have a fully operational Graylog server running in your environment.
Configuration Parameters
According to GELF Payload Specification, there are some mandatory and optional fields which are used by Graylog in GELF format. These fields are determined with Gelf\*_Key_ key in this plugin.
Key | Description | default |
---|---|---|
Match | Pattern to match which tags of logs to be outputted by this plugin | |
Host | IP address or hostname of the target Graylog server | 127.0.0.1 |
Port | The port that your Graylog GELF input is listening on | 12201 |
Mode | The protocol to use ( | udp |
Gelf_Tag_Key | Key to be used for tag. (Optional in GELF) | |
Gelf_Short_Message_Key | A short descriptive message (MUST be set in GELF) | short_message |
Gelf_Timestamp_Key | Your log timestamp (SHOULD be set in GELF) | timestamp |
Gelf_Host_Key | Key which its value is used as the name of the host, source or application that sent this message. (MUST be set in GELF) | host |
Gelf_Full_Message_Key | Key to use as the long message that can i.e. contain a backtrace. (Optional in GELF) | full_message |
Gelf_Level_Key | level | |
Packet_Size | If transport protocol is | 1420 |
Compress | If transport protocol is | true |
Workers |
|
TLS / SSL
GELF output plugin supports TLS/SSL, for more details about the properties available and general configuration, please refer to the TLS/SSL section.
Notes
If you're using Fluent Bit to collect Docker logs, note that Docker places your log in JSON under key
log
. So you can setlog
as yourGelf_Short_Message_Key
to send everything in Docker logs to Graylog. In this case, you need yourlog
value to be a string; so don't parse it using JSON parser.The order of looking up the timestamp in this plugin is as follows:
Value of
Gelf_Timestamp_Key
provided in configurationValue of
timestamp
keyIf you're using Docker JSON parser, this parser can parse time and use it as timestamp of message. If all above fail, Fluent Bit tries to get timestamp extracted by your parser.
Timestamp does not set by Fluent Bit. In this case, your Graylog server will set it to the current timestamp (now).
Your log timestamp has to be in UNIX Epoch Timestamp format. If the
Gelf_Timestamp_Key
value of your log is not in this format, your Graylog server will ignore it.If you're using Fluent Bit in Kubernetes and you're using Kubernetes Filter Plugin, this plugin adds
host
value to your log by default, and you don't need to add it by your own.The
version
of GELF message is also mandatory and Fluent Bit sets it to 1.1 which is the current latest version of GELF.If you use
udp
as transport protocol and setCompress
totrue
, Fluent Bit compresses your packets in GZIP format, which is the default compression that Graylog offers. This can be used to trade more CPU load for saving network bandwidth.
Configuration File Example
If you're using Fluent Bit for shipping Kubernetes logs, you can use something like this as your configuration file:
By default, GELF tcp uses port 12201 and Docker places your logs in /var/log/containers
directory. The logs are placed in value of the log
key. For example, this is a log saved by Docker:
If you use Tail Input and use a Parser like the docker
parser shown above, it decodes your message and extracts data
(and any other present) field. This is how this log in stdout looks like after decoding:
Now, this is what happens to this log:
Fluent Bit GELF plugin adds
"version": "1.1"
to it.The Nest Filter, unnests fields inside
log
key. In our example, it putsdata
alongsidestream
andtime
.We used this
data
key asGelf_Short_Message_Key
; so GELF plugin changes it toshort_message
.Kubernetes Filter adds
host
name.Timestamp is generated.
Any custom field (not present in GELF Payload Specification.) is prefixed by an underline.
Finally, this is what our Graylog server input sees:
Last updated