serde_gelf
The Graylog Extended Log Format (GELF) is a structured log format representation which can be sent over network as a JSON string.
Quickstart
Add in your Cargo.toml
:
[]
= "0.6"
= "1.0"
= "0.1"
= "1.0"
Create a structure which implement the Serialize
trait:
extern crate serde_derive;
extern crate serde_gelf;
extern crate serde_json;
extern crate serde_value;
use BTreeMap;
Output:
OVH Logs Data Platform (LDP)
To send special type like number or boolean, LDP uses suffixes as naming convention to force ES type:
Suffix | ES Type | About |
---|---|---|
_double | double | Unsigned number |
_float | double | Floating value in double in java representation : double-precision 64-bit IEEE 754 floating point |
_long | long | 64 bit signed long type,which has a minimum value of -263 and a maximum value of 263-1 |
_bool | boolean | Expected values: "true" or "false".WARNING : GELF does not support boolean types you will have to send "true" or "false" in String |
Everything else | String | Anything else will be considered a string |
To enable suffixes, update Cargo.toml
and set the ovh-ldp feature:
= { = "0.1", = ["ovh-ldp"] }
# or
[]
= "0.1"
= ["ovh-ldp"]
Now the output of the previous example will be:
Macros
This library provides a macro gelf_record!
to create a gelf record according
to the GELF Payload Specification.
To enable macros, just activate the macros on crate import:
extern crate serde_gelf;
extern crate serde_json;
Output:
License
Licensed under BSD 3-Clause License or (https://opensource.org/licenses/BSD-3-Clause)