filebeat7.8版本创建自定义索引名称、更改配置不生效、以及kibana展示java报错多行输出解决办法
创始人
2024-06-02 23:26:46
1、首先是filebeat配置自定义索引名称配置

vim filebeat.yml

filebeat.inputs:

- type: log

enabled: true

paths:

- /var/log/nginx/access.log 修改为需要读取的日志路径

tags: ["nginx"] #标签名自定义

output.elasticsearch:

hosts: ["192.168.11.139:9200"]

indices:

- index: "filebeat-nginx-%{+yyyy.MM.dd}" #filebeat-nginx替换为你想要的索引名称。%{+yyyy.MM.dd}是年月日的标识方便分辨索引日期

when.contains:

tags: "nginx" #标签名和上面一直

nohup ./filebeat -e -c filebeat.yml > filebeat.log & 修改完配置运行filebeat

vim filebeat.log 查看一下运行日志

提示启动和输入完成 1 那么索引就已经生成了

2、还有要说的就说在使用过程用遇到的坑,我使用的是filebeat7.8版本

遇到的问题有索引删除后重启filebeat后当天不在生成新的索引

还有就是更新filebeat配置文件后重启filebeat配置没有生效

如果大家也遇到这样的问题不要慌可能是版本的问题

ps -ef |grep filebeat

kill -9 13482

rm -rf filebeat/data/registry/filebeat

停掉filebeat服务 然后删除filebeat工作目录 最后在启动即可

nohup ./filebeat -e -c filebeat.yml > filebeat.log & 运行filebeat

3、采集error日志时开发经常会看java的报错,但是java报错一般都很长使用默认配置的话filebeat采集出来的日志是一行一行的,看起来非常的不方便

根据需求我们重新配置一下filebeat即可

vim filebeat.yml

filebeat.inputs:

- type: log

enabled: true

paths:

- /data/log/error.log

multiline.pattern: '^20' #正则表达式是以20 开头的行

multiline.negate: true #参数将匹配结果取反,表示将非匹配行合并到上一行中

multiline.match: after #参数来指定合并行的位置,这里我们使用 after 表示合并到下一行

tags: ["error"]

output.elasticsearch:

hosts: ["192.168.197.136:9200"]

indices:

- index: "nginx-1-error-%{+yyyy.MM.dd}"

when.contains:

tags: "error"

ps -ef |grep filebeat kill -9 进程号

rm -rf filebeat/data/registry/filebeat 删除filebeat工作目录

nohup ./filebeat -e -c filebeat.yml > filebeat.log & 运行filebeat

然后来到kibana在看一下展示的内容就会发现整段报错都展示出来了。

相关内容

热门资讯

原创 恋... 2026年刚刚开始,娱乐圈的吃瓜新闻便接连不断。先是司晓迪爆料某男明星的私事,紧接着是刘一诺与檀健次...
为何近期污染范围较大?成都市生... 1月12日,红星新闻记者了解到,根据省级生态环境和气象部门空气质量前期联合会商结果,1月8日起,四川...
最新或2023(历届)四川美术... 最新或2023(历届)四川美术联考/统考色彩考试题目  考题:食堂今日菜品  一、必备内容:  以食...
最新或2023(历届)四川美术... 明日素描、速写考试  素描 最新或2023(历届)12月6日上午09:00-12:00(满分100分...
最新或2023(历届)福建高考... 福建最新或2023(历届)高考招生艺体类统考12月中旬开考 福建省最新或2023(历届)高招艺术类、...