github.com/dscottboggs/elastic-common-schema-adapter
master / published May 23, 2020 / repository
Automatically generated Crystal types matching the Elastic Common Schema
Elastic Common Schema Adapter
Automatically generated Crystal types matching the Elastic Common Schema. This library is intended to support a formatter for logging in Crystal, but because it is automatically generated from the ecs definition document, it doesn't do anything except store those generated types.
Installation
-
Add the dependency to your
shard.yml:dependencies: ecs: github: dscottboggs/ecs -
Run
shards install
Usage
require "ecs"
event = ECS::LogEntry.new
.timestamp(Time.utc)
.http(&.version("1.1")
.request(&.method("GET").bytes(1234))
.response(&.status_code(200)
.bytes(1234)
.body(&.content("OK."))))
puts event.to_json
The above snippet prints out
{"@timestamp":"2020-05-23T11:55:28Z","http":{"version":"1.1","request":{"bytes":1234,"method":"GET"},"response":{"bytes":1234,"status_code":200,"body":{"content":"OK."}}}}
Development
DO NOT make changes to ecs.cr. It is automatically generated from section.ecr. See the Makefile for more details. If you have a recommendation, please make changes to parser.cr or section.ecr and run make before committing to regenerate ecs.cr.
Contributing
- Fork it (https://github.com/dscottboggs/ecs/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- D. Scott Boggs - creator and maintainer