当您要面对成百上千、甚至成千上万的服务器、虚拟机和容器生成的日志时,请告别 SSH 吧。Filebeat 将为您提供一种轻量型方法,用于转发和汇总日志与文件,让简单的事情不再繁杂。

  1,安装filebeat

rpm -ivh /nas/nas/softs/elk/6.5.4/filebeat-6.5.4-x86_64.rpm

  查看模块

[root@prd-elk-kafka-01 ~]# filebeat modules list
Enabled:
kafka
system Disabled:
apache2
auditd
elasticsearch
haproxy
icinga
iis
kibana
logstash
mongodb
mysql
nginx
osquery
postgresql
redis
suricata
traefik

  如需要启用某个模块使用命令

filebeat modules enable system

  修改配置文件把filebeat输出至elasticsearch和kibana

/etc/filebeat/filebeat.yml

  

filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
setup.template.settings:
index.number_of_shards: 3
output.elasticsearch:
hosts: ["172.16.90.24:9200"]
# username: "admin"
# password: "admin"
setup.kibana:
host: "172.16.90.24:5601"
processors:
- add_host_metadata:
- add_cloud_metadata:
# - drop_fields:
# fields: ["beat", "input", "source", "offset", "prospector","host"]

  模块路径为/etc/filebeat/modules.d/

  2,设置系统模块system

  启用系统模块

/etc/filebeat/filebeat.yml

  编辑系统模块配置文件,这里使用默认

/etc/filebeat/modules.d/system.yml

  

- module: system
# Syslog
syslog:
enabled: true # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
#var.paths: # Convert the timestamp to UTC. Requires Elasticsearch >= 6.1.
#var.convert_timezone: false # Authorization logs
auth:
enabled: true # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
#var.paths: # Convert the timestamp to UTC. Requires Elasticsearch >= 6.1.
#var.convert_timezone: false

  系统模块每一台主机都需要安装,启用后查看kibana

  3,设置nginx模块

  启动nginx模块

filebeat modules enable nginx

  修改配置文档

/etc/filebeat/modules.d/nginx.yml

  输入access日志及error日志路径

- module: nginx
# Access logs
access:
enabled: true # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths:
- "/opt/log/wwwaccess.log"
- "/opt/log/workaccess.log"
- "/opt/log/datavaccess.log" # Error logs
error:
enabled: true # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths:
- "/opt/log/wwwerror.log"
- "/opt/log/workerror.log"
- "/opt/log/dataverror.log"

  kibana查看

  要显示客户端城市及浏览器信息需要安装elasticsearch插件

bin/elasticsearch-plugin install ingest-geoip
bin/elasticsearch-plugin install ingest-user-agent

  

  4,设置redis模块

  启用redis模块

filebeat modules enable redis

  修改redis配置文件

 /etc/filebeat/modules.d/redis.yml

  

- module: redis
# Main logs
log:
enabled: true # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/nas/nas/logs/redis/redis-server.log"] # Slow logs, retrieved via the Redis API (SLOWLOG)
slowlog:
enabled: true # The Redis hosts to connect to.
var.hosts: ["localhost:6379"] # Optional, the password to use when connecting to Redis.
var.password: "password"

  kibana页面查看

  

  5,设置kafka模块

  启用kafka模块

filebeat modules enable kafka

  修改配置文件

/etc/filebeat/modules.d/kafka.yml

  

- module: kafka
# All logs
log:
enabled: true # Set custom paths for Kafka. If left empty,
# Filebeat will look under /opt.
#var.kafka_home: # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths:
- "/usr/local/kafka/logs/controller.log*"
- "/usr/local/kafka/logs/server.log*"
- "/usr/local/kafka/logs/state-change.log*"
- "/usr/local/kafka/logs/kafka-*.log*"
# Convert the timestamp to UTC. Requires Elasticsearch >= 6.1.
#var.convert_timezone: false

  kibana查看

  

  6,设置MySQL模块

  开启mysql模块

filebeat modules enable mysql

  修改配置文件

/etc/filebeat/modules.d/mysql.yml

  输入日志及慢查询日志文件路径

- module: mysql
# Error logs
error:
enabled: true # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/var/log/mysql3306.log"] # Slow logs
slowlog:
enabled: true # Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/nas/nas/logs/mysql/slow3306.log"]

  kibana查看

  更多模块查看官方文档https://www.elastic.co/guide/en/beats/filebeat/6.5/filebeat-modules.html

ELK之使用filebeat收集系统数据及其他程序并生成可视化图表的更多相关文章

  1. ELK之使用metricbeat收集系统数据及其他程序并生成可视化图表

    将 Metricbeat 部署到您所有的 Linux.Windows 和 Mac 主机,并将它连接到 Elasticsearch 就大功告成啦:您可以获取系统级的 CPU 使用率.内存.文件系统.磁盘 ...

  2. ELK+kafka构建日志收集系统

    ELK+kafka构建日志收集系统   原文  http://lx.wxqrcode.com/index.php/post/101.html   背景: 最近线上上了ELK,但是只用了一台Redis在 ...

  3. Kubernetes部署ELK并使用Filebeat收集容器日志

    本文的试验环境为CentOS 7.3,Kubernetes集群为1.11.2,安装步骤参见kubeadm安装kubernetes V1.11.1 集群 1. 环境准备 Elasticsearch运行时 ...

  4. ELK之使用filebeat收集java运行日志

    安装filebeat修改配置文件/etc/filebeat/filebeat.yml filebeat.prospectors: - type: log enabled: true #日志路径 pat ...

  5. filebeat收集日志到elsticsearch中并使用ingest node的pipeline处理

    filebeat收集日志到elsticsearch中 一.需求 二.实现 1.filebeat.yml 配置文件的编写 2.创建自定义的索引模板 3.加密连接到es用户的密码 1.创建keystore ...

  6. nGrinder对监控机器收集自定义数据及源码分析

    转载:https://blog.csdn.net/neven7/article/details/50782451 0.背景 性能测试工具nGrinder支持在无需修改源码的情况下,对目标服务器收集自定 ...

  7. [Xcode 实际操作]七、文件与数据-(1)获取程序沙箱结构中常用的几个目录

    目录:[Swift]Xcode实际操作 本文将演示如何获取程序沙箱结构中,常见的几个目录. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit ...

  8. 使用VS2017 编写Linux系统上的Opencv程序

    背景 之前写图像算法的程序都是在window10下使用VS编写,VS这个IDE结合“ImageWatch.vsix“插件,用于调试opencv相关的图像算法程序十分方便.后因项目需要,需将相关程序移植 ...

  9. Kafka+Zookeeper+Filebeat+ELK 搭建日志收集系统

    ELK ELK目前主流的一种日志系统,过多的就不多介绍了 Filebeat收集日志,将收集的日志输出到kafka,避免网络问题丢失信息 kafka接收到日志消息后直接消费到Logstash Logst ...

随机推荐

  1. IntelliJ IDEA给Serializable类加上自动的serialVersionUID

    如题 见下图 设置以后,点击类,按Alt + Enter 自动加入的代码如下图

  2. SpringBoot项目获取ApplicationContext来GetBean的方法

    一.简介 我们开发时,经常遇到有些实例需要动态创建,比如有构造函数的组件等.这时候,Spring时我们有ClassPathXmlApplicationContext,但是在Spring Boot时,我 ...

  3. vim配置go语法高亮

    操作系统 : CentOS7.3.1611_x64 go 版本 : go1.8.3 linux/amd64 vim版本 :version 7.4.160 vim配置go语言语法高亮的问题已经遇到过好几 ...

  4. 全面解决.Net与Java互通时的RSA加解密问题,使用PEM格式的密钥文件

    作者: zyl910 一.缘由 RSA是一种常用的非对称加密算法.所以有时需要在不用编程语言中分别使用RSA的加密.解密.例如用Java做后台服务端,用C#开发桌面的客户端软件时. 由于 .Net.J ...

  5. 【MVP时间】5节课助你破解物联网硬件接入难点

    视频播放链接:https://mvp.aliyun.com/topic/10?spm=5176.8961170.detail.18.31a3yK4zyK4zUc 1.会上网的鸡,有啥不一样? http ...

  6. 【翻译】Nginx的反向代理

    本文为翻译文,原文地址:https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ 本文描述代理服务器的基本配置.你能学到如何 ...

  7. Roslyn如何实现简单的代码提示

    假如需要实现一个代码编辑器,其中一个很重要的功能是实现代码提示,类似VS的代码智能提示.下面用Roslyn编译器来实现一个简单的代码提示功能. 代码提示,首先必须需要知道对象的类型信息,然后通过迭代获 ...

  8. 基于jQuery发展历程时间轴特效代码

    分享一款基于jQuery发展历程时间轴特效代码,带左右箭头,数字时间轴选项卡切换特效下载.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div id="time ...

  9. SparkStreaming:关于checkpoint的弊端

    当使用sparkstreaming处理流式数据的时候,它的数据源搭档大部分都是Kafka,尤其是在互联网公司颇为常见. 当他们集成的时候我们需要重点考虑就是如果程序发生故障,或者升级重启,或者集群宕机 ...

  10. vector 使用 c++11 Lambda 表达式 排序

    struct SIndexDataNew { 1 optional short shtMarket; 2 optional string sCode; 3 optional int iDate; 4 ...