ecs-schema v0.0.1
Elastic Common Schema Type Definitions for TypeScript
This project provides TypeScript type definitions covering ECS entities, generated from the ECS Schema Docs. Its purpose is to be used by other projects (like loggers) to enforce log and event schemas.
Usage
Import the project into your codebase:
npm i -D ecs-schema
Reference the schema in code:
import { ElasticCommonSchema } from 'ecs-schema';
logger.info({
labels: {
foo: 'bar',
},
} as ElasticCommonSchema, 'Here is my message');
It would probably be a good idea to create an abstraction for your logger. If you are using this, I would assume this was your intent already.
Contribution Guidelines
The goal is to derive as much of the schema as possible from source documentation provided by Elastic.co. If you want to make a change, it must include the logic necessary to render that change in the generateFromECSDocs.js
or ecs.partial.ts.template
files. Run the script and provide those changes, in addition to the changes to dist/index*
in a PR.