Kibana 不显示从 Node.js Winston Logger 发送到 Elasticsearch 的日志

尼西尼克斯

我使用winstonwinston-elasticsearch将日志从 Node.js 应用程序直接发送到 Elasticsearch Elasticsearch 7.5.1、Logstash 和 Kibana 7.5.1 使用 Docker Compose 部署在远程服务器上。

问题一:运行发送2条日志消息到Elasticsearch的node.js文件后,程序没有自动退出返回终端。在 Mac OS X Mojave 10.14.6 上使用 Node.js v12.6.0。

问题 2:将这 2 条日志消息发送到 Elasticsearch 后,可以使用 Web 浏览器在http://<example.com>:9200/logs-2020.02.01/_search.

{"took":5,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":2,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"logs-2020.02.01","_type":"_doc","_id":"85GgA3ABiaPPk4as1pEc","_score":1.0,"_source":{"@timestamp":"2020-02-02T02:00:35.789Z","message":"a debug message","severity":"debug","fields":{}}},{"_index":"logs-2020.02.01","_type":"_doc","_id":"9JGgA3ABiaPPk4as1pEc","_score":1.0,"_source":{"@timestamp":"2020-02-02T02:00:35.791Z","message":"an info log","severity":"info","fields":{}}}]}}

但是,这些日志不会显示在 Kibana 上,例如https://<example.com>/app/infra#/logs/stream?_g=().

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

知道如何让日志也显示在 Kibana 上吗?另外,为什么 Node.js 应用程序在发送日志消息后没有退出?

谢谢!

Node.js 应用程序

const winston = require('winston');
const ElasticsearchWinston = require('winston-elasticsearch');
const options = {
    console: {
        level: 'debug',
        handleExceptions: true,
        json: false,
        colorize: true
    },
    elasticsearch: {
        level: 'debug',
        clientOpts: {
            node: 'http://user:[email protected]:9200',
            log: 'debug',
            maxRetries: 2,
            requestTimeout: 10000,
            sniffOnStart: false,
        }
    }
}

var logger = winston.createLogger({
    exitOnError: false,
    transports: [
        new winston.transports.Console(options.console),
        new ElasticsearchWinston(options.elasticsearch)
    ]
});

logger.debug('a debug message');
logger.info('an info log');
apt-get_install_skill

我不是 node.js 专家,所以我只会关注 kibana 问题。日志应用程序并不适用于像您这样的“自定义”日志/索引。

如文档中所述(https://www.elastic.co/guide/en/kibana/current/xpack-logs.html):

Kibana 中的 Logs 应用程序使您能够探索常见服务器、容器和服务的日志

日志应用程序用于监控您的基础设施和 ELK 服务,例如通过某些 Beats 模块(例如 Filebeat 的 Elasticsearch、Kibana 和 Logstash 模块)。

同样来自文档(https://www.elastic.co/guide/en/kibana/current/xpack-logs-configuring.html):

日志的默认源配置在 Kibana 配置文件的日志应用程序设置中指定。默认配置使用filebeat-* 索引模式来查询数据。

这解释了为什么您在日志应用程序中看不到任何数据,因为您的索引使用 'logs-*' 索引模式。

长话短说:

要查看 log-* 索引中的文档,您需要打开 Discovery(Kibana 左侧边栏上的第一个图标)并选择您已经设置的索引模式。这是在 Kibana 中搜索应用程序数据的合适方式。

我希望我能帮助你。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用filebeat,logstash和elasticsearch将json格式的日志发送到kibana?

Node.js Winston日志记录-exitOnError

如何通过Node.js中的winston-loggly将主机和应用程序信息发送到Loggly

Node.js / Winston-我可以追加日志吗?

将Kubernetes集群日志发送到AWS Elasticsearch

将日志从ECS Fargate发送到Elasticsearch的最佳方法

使用 Winston 3.0 和 Nodejs 的 Json 格式日志未在 Kibana 中显示

Winston Logger-NodeJs调试控制台日志未显示在VSCode中

发送到 Kinesis Firehose 的记录延迟显示在 Kibana 中

发送到日志并在控制台上显示

将Logstash日志发送到Kibana远程服务器

将信息从 Angular 发送到 Java 以使用 LOGGER.info 进行日志记录

如何将数组从html发送到node.js,然后发送到mongodb?

容器化WebApp的日志不会通过Serilog.Sinks.Elasticsearch发送到Elasticsearch

如何在Node.JS中使用Winston格式化错误日志?

如何在 Node.js 中使用 express-winston 将日志存储到 mysql db

使用Winston Node js库未创建任何日志文件

如何在进程退出之前强制将Node.js Winston日志记录到文件

如何使用 Winston 库在 Node.js 中每天将日志分离到单独的文件中

将值从PHP发送到Node JS以执行

将 AJAX 数据发送到 Node.js

将图像从html发送到node.js

将参数从玉发送到js / node

将 Node.js Grunt 作业发送到后台

将文件从Angular发送到Node.js

将数据从JavaScript发送到node.js

Node.js将变量发送到EJS页面

无法将参数发送到函数 Node.js

将edittextfield的数据从Android发送到node.js