|
| 1 | +# Output Formats |
| 2 | + |
| 3 | +Some of the output plugin's has a config field called `formats`, with a limited |
| 4 | +amount of options are available (`json`, `json_stream`, `json_lines`, `msgpack`, `gelf`). |
| 5 | + |
| 6 | +The specifications, or reference to external documentation of the formats, is |
| 7 | +available in this page. |
| 8 | + |
| 9 | +## JSON Formats |
| 10 | + |
| 11 | +The most custom format options are the JSON types, these are three quite |
| 12 | +common variants of sending JSON encoded data over various API's. |
| 13 | + |
| 14 | +The example payloads below, are all "prettified" for readability. |
| 15 | + |
| 16 | +_Records shown in example payloads, are the three first commits of the fluent-bit repository_ |
| 17 | + |
| 18 | +### json |
| 19 | + |
| 20 | +Queued records encoded as a single JSON array of JSON encoded fluent-bit records. |
| 21 | + |
| 22 | +#### Example payload |
| 23 | + |
| 24 | +```json |
| 25 | +[ |
| 26 | + { |
| 27 | + "timestamp": 1398282091.000, |
| 28 | + "log": "Core: initialization and 32 bit fixes.", |
| 29 | + "commit": "b327996bfcbc0f1f47e62c862c6f303592dfacea", |
| 30 | + "author": "Eduardo Silva" |
| 31 | + }, |
| 32 | + { |
| 33 | + "timestamp": 1422350608.000, |
| 34 | + "log": "Initial import.", |
| 35 | + "commit": "49269c5ec3c74411943e362cfef85052665ae97f", |
| 36 | + "author": "Eduardo Silva" |
| 37 | + }, |
| 38 | + { |
| 39 | + "timestamp": 1422418113.000, |
| 40 | + "log": "Doc: add reference to Apache License v2.0", |
| 41 | + "commit": "6e09478733e8273ec216328dfc921e622740695d", |
| 42 | + "author": "Eduardo Silva" |
| 43 | + } |
| 44 | +] |
| 45 | +``` |
| 46 | + |
| 47 | +### json_stream |
| 48 | + |
| 49 | +_a.k.a. Concatenated JSON_ |
| 50 | + |
| 51 | +Queued JSON-encoded fluent-bit records, with no separator between records. |
| 52 | + |
| 53 | +#### Example payload |
| 54 | + |
| 55 | +```json |
| 56 | +{ |
| 57 | + "timestamp": 1398282091.000, |
| 58 | + "log": "Core: initialization and 32 bit fixes.", |
| 59 | + "commit": "b327996bfcbc0f1f47e62c862c6f303592dfacea", |
| 60 | + "author": "Eduardo Silva" |
| 61 | +}{ |
| 62 | + "timestamp": 1422350608.000, |
| 63 | + "log": "Initial import.", |
| 64 | + "commit": "49269c5ec3c74411943e362cfef85052665ae97f", |
| 65 | + "author": "Eduardo Silva" |
| 66 | +}{ |
| 67 | + "timestamp": 1422418113.000, |
| 68 | + "log": "Doc: add reference to Apache License v2.0", |
| 69 | + "commit": "6e09478733e8273ec216328dfc921e622740695d", |
| 70 | + "author": "Eduardo Silva" |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +### json_lines |
| 75 | + |
| 76 | +_a.k.a. Newline-Delimited JSON_ |
| 77 | + |
| 78 | +Queued JSON-encoded fluent-bit records, separated by line-breaks (`\n`). |
| 79 | + |
| 80 | +#### Example payload |
| 81 | + |
| 82 | +```json |
| 83 | +{ |
| 84 | + "timestamp": 1398282091.000, |
| 85 | + "log": "Core: initialization and 32 bit fixes.", |
| 86 | + "commit": "b327996bfcbc0f1f47e62c862c6f303592dfacea", |
| 87 | + "author": "Eduardo Silva" |
| 88 | +} |
| 89 | +{ |
| 90 | + "timestamp": 1422350608.000, |
| 91 | + "log": "Initial import.", |
| 92 | + "commit": "49269c5ec3c74411943e362cfef85052665ae97f", |
| 93 | + "author": "Eduardo Silva" |
| 94 | +} |
| 95 | +{ |
| 96 | + "timestamp": 1422418113.000, |
| 97 | + "log": "Doc: add reference to Apache License v2.0", |
| 98 | + "commit": "6e09478733e8273ec216328dfc921e622740695d", |
| 99 | + "author": "Eduardo Silva" |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +## msgpack |
| 104 | + |
| 105 | +MessagePack is a binary format for serializing objects. |
| 106 | + |
| 107 | +Please refer to the official MessagePack format specification, found here: |
| 108 | +https://github.com/msgpack/msgpack/blob/master/spec.md |
| 109 | + |
| 110 | +## GELF |
| 111 | + |
| 112 | +**G**raylog **E**xtended **L**og **F**ormat is a JSON based log format which is |
| 113 | +designed to avoid the shortcomings of classic plain syslog. |
| 114 | + |
| 115 | +The official documentation for the GELF format can be found here: |
| 116 | +https://archivedocs.graylog.org/en/latest/pages/gelf.html |
| 117 | + |
| 118 | +It uses a fixed set of keys, with the addition of adding custom keys prefixed |
| 119 | +by one single underscore character. |
| 120 | + |
| 121 | +### Example payload |
| 122 | + |
| 123 | +Here is an example payload, copied directly from the official docs (linked above) |
| 124 | + |
| 125 | +```json |
| 126 | +{ |
| 127 | + "version": "1.1", |
| 128 | + "host": "example.org", |
| 129 | + "short_message": "A short message that helps you identify what is going on", |
| 130 | + "full_message": "Backtrace here\n\nmore stuff", |
| 131 | + "timestamp": 1385053862.3072, |
| 132 | + "level": 1, |
| 133 | + "_user_id": 9001, |
| 134 | + "_some_info": "foo", |
| 135 | + "_some_env_var": "bar" |
| 136 | +} |
| 137 | +``` |
0 commit comments