Crates.io | ecs_types |
lib.rs | ecs_types |
version | 0.2.0 |
source | src |
created_at | 2022-11-29 16:22:57.304637 |
updated_at | 2022-11-30 15:30:50.907332 |
description | Rust types mapping to the elasticsearch common schema |
homepage | https://www.github.com/janstarke/ecs_types |
repository | https://www.github.com/janstarke/ecs_types |
max_upload_size | |
id | 725491 |
size | 8,817,512 |
Rust types mapping to the elasticsearch common schema
This crate provides basic type to be used when importing data to elasticsearch. It is generated from the type definitions in https://github.com/elastic/ecs.
The crates documentation can be found at https://docs.rs/crate/ecs_types.# ecs_types
use ecs_types::types::Timestamp;
use ecs_types::*;
use serde_json::json;
let now: Timestamp = chrono::offset::Local::now().into();
let mut base = Base::new(now.clone());
let mut file = File::default();
file.set_name("readme.txt".into());
file.set_mtime(now);
base.with_file(file);
println!("{}", serde_json::to_string_pretty(&json!(base)).unwrap() );
creates the following result:
{
"@timestamp": 1669822098181,
"file": {
"attributes": [],
"mtime": 1669822098181,
"name": "readme.txt"
},
"tags": []
}
License: Apache-2.0