弹性云日志未出现在可观察性日志中

Elastic cloud logs not appearing in observability logs

当我转到 Analytics > Discover 部分时,这些日志出现在我的索引模式搜索中,但没有出现在 Observability > Logs 中。不确定我必须做什么才能让他们出现在那里。我已经在设置中添加了 application-* 前缀。

看起来用于弹性搜索的 Pino 记录器默认不再使用 ecs format 对其进行格式化。所以我必须启用它才能正常工作。

ECS support

If you want to use Elastic Common Schema, you should install @elastic/ecs-pino-format, as the ecs option of this module has been removed.

const pino = require('pino')
const ecsFormat = require('@elastic/ecs-pino-format')()
const pinoElastic = require('pino-elasticsearch')

const streamToElastic = pinoElastic({
  index: 'an-index',
  consistency: 'one',
  node: 'http://localhost:9200',
  'es-version': 7,
  'flush-bytes': 1000
})

const logger = pino({ level: 'info',  ...ecsFormat  }, streamToElastic)

logger.info('hello world')