Skip to content

Possible incorrect JSON representation of log.level for Pino log format #91

@hectcastro

Description

@hectcastro

Using v1.3.0 of ecs-pino-format, I get the following output for a message:

{
  "log.level": "info",
  "@timestamp": "2021-08-26T14:45:06.489Z",
  "labels": {
    "env": "prod",
    "app": "test"
  },
  "service": {
    "name": "test"
  },
  "tags": [
    "audit"
  ],
  "ecs": {
    "version": "1.6.0"
  },
  "message": "Hello world"
}

But, it seems like log.level should be an Object instead of a string key, like:

{
  "log": {
    "level": "info"
  },
  "@timestamp": "2021-08-26T14:46:10.475Z",
  "labels": {
    "env": "prod",
    "app": "test"
  },
  "service": {
    "name": "test"
  },
  "tags": [
    "audit"
  ],
  "ecs": {
    "version": "1.6.0"
  },
  "message": "Hello world"
}

Below is the example program in TypeScript I was using to test:

import ecsFormat from "@elastic/ecs-pino-format";
import pino from "pino";

const log = pino({
  base: {
    labels: {
      env: "prod",
      app: "test",
    },
    service: {
      name: "test",
    },
    tags: ["audit"],
  },
  ...ecsFormat(),
});

log.info("Hello world");

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-nodejsMake available for APM Agents project planning.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions