Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@elastic/ecs-helpers
Advanced tools
A set of helpers for the ECS logging libraries. You should not directly used this package, but the ECS logging libraries instead.
npm i @elastic/ecs-helpers
version
The currently supported version of Elastic Common Schema.
stringify
Function that serializes (very quickly!) an ECS-format log record object.
const { stringify } = require('@elastic/ecs-helpers')
const ecs = {
'@timestamp': new Date().toISOString(),
'log.level': 'info',
message: 'hello world',
log: {
logger: 'test'
},
ecs: {
version: '1.4.0'
}
}
console.log(stringify(ecs))
Note: This uses fast-json-stringify for serialization. By design this chooses speed over supporting serialization of objects with circular references. This generally means that ecs-logging-js libraries will throw a "Converting circular structure to JSON" exception if an attempt is made to log an object with circular references.
formatHttpRequest
Function that enhances an ECS object with http request data. The request object should be Node.js's core request object.
const { formatHttpRequest } = require('@elastic/ecs-helpers')
const ecs = {
'@timestamp': new Date().toISOString(),
'log.level': 'info',
message: 'hello world',
log: {
logger: 'test'
},
ecs: {
version: '1.4.0'
}
}
formatHttpRequest(ecs, request)
console.log(ecs)
formatHttpResponse
Function that enhances an ECS object with http response data. The response object should be Node.js's core response object.
const { formatHttpResponse } = require('@elastic/ecs-helpers')
const ecs = {
'@timestamp': new Date().toISOString(),
'log.level': 'info',
message: 'hello world',
log: {
logger: 'test'
},
ecs: {
version: '1.4.0'
}
}
formatHttpResponse(ecs, request)
console.log(ecs)
This software is licensed under the Apache 2 license.
FAQs
ecs-logging-nodejs helpers
The npm package @elastic/ecs-helpers receives a total of 321,627 weekly downloads. As such, @elastic/ecs-helpers popularity was classified as popular.
We found that @elastic/ecs-helpers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 57 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.