Socket
Socket
Sign inDemoInstall

@elastic/ecs-helpers

Package Overview
Dependencies
Maintainers
74
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic/ecs-helpers

ECS loggers helpers


Version published
Weekly downloads
387K
increased by0.81%
Maintainers
74
Weekly downloads
 
Created
Source

@elastic/ecs-helpers

Build Status js-standard-style

A set of helpers for the ECS logging libraries. You should not directly used this package, but the ECS logging libraries instead.

Install

npm i @elastic/ecs-helpers

API

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))

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)

License

This software is licensed under the Apache 2 license.

FAQs

Package last updated on 05 Jan 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc