#elasticsearch #mapping #schema #timestamp #type #documentation #ecs

ecs_types

Rust types mapping to the elasticsearch common schema

2 unstable releases

0.2.0 Nov 30, 2022
0.1.0 Nov 29, 2022

#2864 in Database interfaces

Apache-2.0

1.5MB
14K SLoC

AsciiDoc 9K SLoC // 0.1% comments Python 4.5K SLoC // 0.2% comments Rust 462 SLoC // 0.0% comments Jinja2 215 SLoC // 0.1% comments

ecs_types

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

Usage example

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


lib.rs:

Usage example

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": []
}

Dependencies

~2.2–4MB
~69K SLoC