-
Bump dep to
@elastic/ecs-helpers@2
which removes the dep on the oldfast-safe-stringify
lib that resulted in a maintenance warning about thestring-similarity
transitive dep. -
Set
http.request.id
field (see ecs-helpers CHANGELOG). -
Changed to a named export. The preferred way to import is now:
const { ecsFormat } = require('@elastic/ecs-pino-format'); // CommonJS import { ecsFormat } from '@elastic/ecs-pino-format'; // ESM
The old way will be deprecated and removed in the future:
const ecsFormat = require('@elastic/ecs-pino-format'); // OLD
-
Add support for default import in TypeScript, with or without the
esModuleInterop
setting:import ecsFormat from '@elastic/ecs-pino-format';
However, note that using named imports is now preferred.
-
Add
service.version
,service.environment
, andservice.node.name
log correlation fields, automatically inferred from an active APM agent. As well, the followingecsFormat
configuration options have been added for overriding these and existing correlation fields:serviceName
,serviceVersion
,serviceEnvironment
,serviceNodeName
. (elastic/apm-agent-nodejs#3195, elastic#121, elastic#87) -
Change to adding dotted field names (
"ecs.version": "1.6.0"
), rather than namespaced fields ("ecs": {"version": "1.6.0"}
) for most fields. This is supported by the ecs-logging spec, and arguably preferred in the ECS logging docs. It is also what the ecs-logging-java libraries do. The resulting output is slightly shorter, and accidental collisions with user fields is less likely. -
Stop adding ".log" suffix to
event.dataset
field. (#95)
- TypeScript types. (#82)
- Add an internal testing-only option (
opts._elasticApm
) to pass in the current loaded "elastic-apm-node" module for use in APM tracing integration. This option will be used by tests in the APM agent where the current agent import name is a local path rather than "elastic-apm-node" that this code normally uses.
- Fix a circular-require for code that uses both this package and 'elastic-apm-node'. (#79)
- The ecs-logging spec was updated to allow "message" to be
optional. This allows the
change to fallback to an empty string message
to be removed -- which is cleaner and fixes a
side-effect bug
where usage of pino's
prettyPrint: true
was broken. (#75)
-
Fix a "TypeError: Cannot read property 'host' of undefined" crash when using
convertReqRes: true
and logging areq
field that is not an HTTP request object. (#71) -
Set the "message" to the empty string for logger calls that provide no message, e.g.
log.info({foo: 'bar'})
. In this case pino will not add a message field, which breaks ecs-logging spec. (#64) -
Fix handling when the
base
option is used to the pino constructor. (#63)Before this change, using, for example: const log = pino({base: {foo: "bar"}, ...ecsFormat()}) would result in two issues:
- The log records would not include the "foo" field.
- The log records would include
"process": {}, "host": {}
for the expected process.pid and os.hostname.
Further, if the following is used: const log = pino({base: null, ...ecsFormat()}) pino does not call
formatters.bindings()
at all, resulting in log records that were missing "ecs.version" (making them invalid ecs-logging records) and part of the APM integration. -
Add
apmIntegration: false
option to all ecs-logging formatters to enable explicitly disabling Elastic APM integration. (#62) -
Fix "elasticApm.isStarted is not a function" crash on startup. (#60)
-
Update to @elastic/ecs-helpers@1.0.0: ecs.version is now "1.6.0", http.request.method is no longer lower-cased, improvements to HTTP serialization.
-
Add error logging feature. By default if an Error instance is passed as the
err
field, then it will be converted to ECS Error fields, e.g.:log.info({ err: new Error('boom') }, 'oops')
yields:
{ "log.level": "info", "@timestamp": "2021-01-26T17:02:23.697Z", ... "error": { "type": "Error", "message": "boom", "stack_trace": "Error: boom\n at Object.<anonymous> (..." }, "message": "oops" }
This special handling of the
err
field can be disabled via theconvertErr: false
formatter option. -
Set "service.name" and "event.dataset" log fields if Elastic APM is started. This helps to filter for different log streams in the same pod and the latter is required for log anomaly detection. (#41)
-
Add support for ECS tracing fields. If it is detected that Elastic APM is in use and there is an active trace, then tracing fields will be added to log records. This enables linking between traces and log records in Kibana. (#35)
-
BREAKING CHANGE: Conversion of HTTP request and response objects is no longer done by default. One must use the new
convertReqRes: true
formatter option. As well, only the meta keysreq
andres
will be handled. Before this change the meta keysreq
,res
,request
, andresponse
would all be handled. (#32)Before (no longer works):
const log = pino({ ...ecsFormat() }) http.createServer(function handler (request, response) { // ... log.info({ request, response }, 'handled request') })
After:
const log = pino({ ...ecsFormat({ convertReqRes: true }) }) // <-- specify convertReqRes option http.createServer(function handler (req, res) { // ... log.info({ req, res }, 'handled request') // <-- only `req` and `res` are special })
- Serialize "log.level" as a top-level dotted field per elastic/ecs-logging#33 and set "log.logger" to the logger "name" if given. (#23)
Initial release.