0415关于通过FILEBEAT,LOGSTASH,ES,KIBNA实现数据的采集

如何通过FILEBEAT,LOGSTASH,ES,KIBNA实现数据的采集
总体参考网址:https://www.olinux.org.cn/elk/1157.html
官方网址:https://www.elastic.co/guide/en/beats/filebeat/6.2/filebeat-getting-started.html

第一步 启动ES,ES的安装请自行百度
第二步 启动LOGSTASH,LOGSTASH的安装请自行百度
启动命令../bin/logstash -f logstash.slowquery.conf
配置logstash.slowquery.conf文件
input {
beats {
host => "192.168.2.105"
port => 5044
}
}
filter {

grok {
match => [ "message", "(?m)^# [email protected]: %{USER:query_user}\[[^\]]+\] @ (?:(?<query_host>\S*) )?\[(?:%{IP:query_ip})?\]\s*Id: %{NUMBER:id:int}\s+# Query_time: %{NUMBER:query_time:float}\s+Lock_time: %{NUMBER:lock_time:float}\s+Rows_sent: %{NUMBER:rows_sent:int}\s+Rows_examined: %{NUMBER:rows_examined:int}\s*(?:use %{DATA:database};\s*)?SET timestamp=%{NUMBER:timestamp};\s*(?<query>(?<action>\w+)\s+.*)" ]
}
grok {
match => { "message" => "# Time: " }
add_tag => [ "drop" ]
tag_on_failure =>[]
}
if "drop" in [tags] {
drop {}
}
date {
match => [ "timestamp", "UNIX", "YYYY-MM-dd HH:mm:ss"]
remove_field => [ "timestamp" ]
}

}
output {
elasticsearch {
hosts => "192.168.2.105:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{[type]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"

第三步 启动filebeat 启动命令./filebeat -e -c filebeat.yml -d "publish"
编辑filebeat.yml,比较重要的是type为log,enabled必须为true,document_type: mysqlslowquerylog
-- filebeat.prospectors安装下面的进行配置
filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- type: log

# Change to true to enable this prospector configuration.
enabled: true

# Paths that should be crawled and fetched. Glob based paths.
paths:
- /var/lib/mysql/*.log
#- c:\programdata\elasticsearch\logs\*
document_type: mysqlslowquerylog
# Exclude lines. A list of regular expressions to match. It drops the lines that are
# matching any regular expression from the list.
#exclude_lines: [‘^DBG‘]

# Include lines. A list of regular expressions to match. It exports the lines that are
# matching any regular expression from the list.
#include_lines: [‘^ERR‘, ‘^WARN‘]

# Exclude files. A list of regular expressions to match. Filebeat drops the files that
# are matching any regular expression from the list. By default, no files are dropped.
#exclude_files: [‘.gz$‘]

# Optional additional fields. These fields can be freely picked
# to add additional information to the crawled log files for filtering
#fields:
# level: debug
# review: 1

### Multiline options

# Mutiline can be used for log messages spanning multiple lines. This is common
# for Java Stack Traces or C-Line Continuation

# The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
#multiline.pattern: ^\[

multiline.pattern: "^# [email protected]: "

# Defines if the pattern set under pattern should be negated or not. Default is false.
multiline.negate: true

# Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
# that was (not) matched before or after or as long as a pattern is not matched based on negate.
# Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
multiline.match: after

-- Output安装下面配置
#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
#output.elasticsearch:
# Array of hosts to connect to.
# hosts: ["localhost:9200"]

# Optional protocol and basic auth credentials.
#protocol: "https"
#username: "elastic"
#password: "changeme"

#----------------------------- Logstash output --------------------------------
output.logstash:
# The Logstash hosts
hosts: ["192.168.2.105:5044"]

# Optional SSL. By default is off.
# List of root certificates for HTTPS server verifications
#ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

# Certificate for SSL client authentication
#ssl.certificate: "/etc/pki/client/cert.pem"

# Client Certificate Key
#ssl.key: "/etc/pki/client/cert.key"

第四步 启动kibana,执行命令 ./kibana

第五步 正常的使用浏览器192.168.2.105:5602进行访问,进行页面配置。

原文地址:https://www.cnblogs.com/qcfeng/p/8846804.html

时间: 2024-07-30 21:25:40

0415关于通过FILEBEAT,LOGSTASH,ES,KIBNA实现数据的采集的相关文章

filebeat+logstash+elasticsearch收集haproxy日志

filebeat用于是日志收集,感觉和 flume相同,但是用go开发,性能比较好 在2.4版本中, 客户机部署logstash收集匹配日志,传输到 kafka,在用logstash 从消息队列中抓取日志存储到elasticsearch中. 但是在 5.5版本中,使用filebeat 收集日志,减少对客户机的性能影响, filebeat 收集日志 传输到 logstash的 5044端口, logstash接收日志,然后传输到es中 实验 filebeat ---- kafka ------lo

filebeat + logstash + elasticsearch + granfa

filebeat + logstash + elasticsearch + granfa https://www.cnblogs.com/wenchengxiaopenyou/p/9034213.html 一.背景 前端web服务器为nginx,采用filebeat + logstash + elasticsearch + granfa 进行数据采集与展示,对客户端ip进行地域统计,监控服务器响应时间等. 二.业务整体架构: nginx日志落地-->filebear-->logstash--&

ELK 之数据收集传输过滤 Filebeat+Logstash 部署

本文与前文是有关联的,之前的两篇文章客官可以抬腿出门右转 导读,ELK 之前端,ELK 之分布式发#前端和消息队列搞定之后,我们需要安装数据采集工具filebeats和数据过滤机运输工具Logstash,一般情况我们都使用filebeats 用来收集日志文件,我自定义了一个log文件,文件内容如下:55.3.244.1 GET /index.html 15824 0.04355.3.244.1 GET /index.html 15824 0.043文件位置放到/tmp/test.log cd /

生产环境filebeat logstash配置模板

filebeat logstash配置模板说明 为了让不同类型的日志记录到不同index,实现日志分类,需要更改默认的配置文件,ELK更新迭代速度很快,网上以前的文档适用于之前的版本 filebeat的docment_type配置项已经在6版本中弃用,请使用本文配置 filebeat配置模板 [email protected]:~$ cat /etc/filebeat/filebeat.yml filebeat.prospectors: - type: log   enabled: true  

海量日志下的日志架构优化:filebeat+logstash+kafka+ELK

前言: 实验需求说明 在前面的日志收集中,都是使用的filebeat+ELK的日志架构.但是如果业务每天会产生海量的日志,就有可能引发logstash和elasticsearch的性能瓶颈问题.因此改善这一问题的方法就是filebeat+logstash+kafka+ELK,也就是将存储从elasticsearch转移给消息中间件,减少海量数据引起的宕机,降低elasticsearch的压力,这里的elasticsearch主要进行数据的分析处理,然后交给kibana进行界面展示 实验架构图:

Logstash过滤分析日志数据/kibanaGUI调试

[Logstash] [[email protected] ~]# wget https://artifacts.elastic.co/downloads/logstash/logstash-6.3.2.tar.gz [[email protected] ~]# tar zxvf logstash-6.3.2.tar.gz -C /usr/local/ [[email protected] ~]# mv /usr/local/logstash-6.3.2/ /usr/local/logstash

logstash无法读取redis数据

今天搭建logsatsh+redis+elasticsearch时出现了问题,经过近一小时排查,终于解决.记录一下. 环境是这样,一台客户端发送数据到位于服务器的redis,服务器端的logstash读redis的数据,存储到elasticsearch中. 初步问题是这样的:在服务器端,没有收到客户端发送过来的日志. 这样就可能有两种问题:一是客户端的logstash没有成功发送数据到redis,二是服务器端的logstash无法从redis读取数据. 排查问题一 为了避免redis中原有数据影

es实战之数据导出成csv文件

从es将数据导出分两步: 查询大量数据 将数据生成文件并下载 本篇主要是将第二步,第一步在<es实战之查询大量数据>中已讲述. csv vs excel excel2003不能超过65536, excel2007及以上版本支持1048576条数据.excel支持的数据量有限,并且生生成文件的速度比较慢. csv具有支持写入量大,文件较小的优点. 故选择csv作为导出文件类型. 导出文件的几种方式: 将数据从es中查询出来,在这个大前提下,对比导出文件的速度. 由前端处理 直接将数据返回给前端,

(原)关于OpenSL ES播放音频数据的一个奇怪的问题

关于OpenSL ES播放音频数据的一个奇怪的问题 Author:[email protected] 最近用业余时间做了一个android平台的播放器sdk,其中视频用的opengl es,音频用的opensl es 做渲染,其中整个播放器在音视频同步的过程中,使用的视频同步到音频的方式,以音频作为主时钟. 今天在测试的过程中发现一个奇怪的问题,我音频数据的填充,使用了单独的音频线程,这其中的实现,主要参考ijk的实现代码和方式. 整个流程方式:我在音频播放的过程中设置的200ms的播放缓冲区给