无法将日志从Hapi-Pino发送到Elasticsearch

时间:2020-05-19 07:19:17

标签: node.js elasticsearch hapijs pinojs

  • 我正在为网站构建服务器,并使用hapihapi-pino进行日志记录。
  • 我想出于某些业务目的分析日志(关于状态码,路由,时间戳)。我使用elasticsearchkibana来完成
  • hapi-pinoElasticsearch之间,我尝试使用pino-elasticsearch发送日志。但是,它没有用,elasticsearch没有得到任何东西 这是我注册hapi-pino的代码:
const streamToElastic = PinoElasticsearch({
    index: 'api',
    type: 'log',
    consistency: 'one',
    node: 'http://elastic:changeme@localhost:9200',
    'es-version': 6,
    'bulk-size': 200,
    ecs: true
});

await server.register({
    plugin: HapiPino,
    options: {
        logPayload: true,
        prettyPrint: process.env.NODE_ENV !== 'production',
        redact: {
            paths: ['req.headers', 'payload.user.password', 'payload.file'],
            remove: true
        },
        stream: streamToElastic
    }
});

感谢您的帮助,对我英语不好的情况感到抱歉!

0 个答案:

没有答案