windows系统安装运行filebeat

下载安装包 下载地址:https://www.elastic.co/downloads/beats/filebeat
解压到指定目录
打开解压后的目录,打开filebeat.yml进行配置。

1:配置 Filebeat prospectors->path 这里的路径是所要收集日志的路径
2:配置 enabled: true 这个配置很重要,只有配置为true之后配置才可生效,否则不起作用。
3:配置Outputs ,这里的Outputs有elasticsearch,logstash。按照配置文件下面的示例配置即可。
4:filebeat template设置:

setup.template.settings:
index.number_of_shards: 1
setup.ilm.enabled: false
setup.template.enabled: true
setup.template.overwrite: true
setup.template.name: "ci"
setup.template.pattern: "ci-"
setup.dashboards.index: "ci"

通过命令行运行 Filebeat 非常简单,只需将 Filebeat 文件解压到某个目录后,通过以下命令运行:(打开刚才解压目录 按住ctrl+shift 并同时鼠标右键打开cmd窗口执行命令 )

.\filebeat -e -c filebeat.yml

 

示例:

日志输入配置

Filebeat 使用了安装目录下的 filebeat.yml 文件进行相关配置。此处我们主要会用到以下的配置:

filebeat.prospectors:

- type: log
# 此处需特别注意,官方默认配置为 false,需要修改为 true
enabled: true
paths:
# 此处配置的是需要收集的日志所在的位置,可使用通配符进行配置
- D:/tmp/filebeat-input/*.log

日志输出配置

因为我们使用的是 logstash 收集日志,所以得注释掉默认的 elasticsearch 配置,并取消 logstash 的注释,最终的效果为:

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

 

2.2 运行所需要的环境
es运行

es-head运行

 

kibana运行

运行filebeat

这时候我们查看es-head界面发现什么都没有


这个index使我们原本有的,wjb-2018.03.02

我猜应该是filebeat读取日志文件最新的,你需要添加日志,于是我在SecureCRT中执行了几个ls命令

 

D:/tmp/filebeat-input/文件下日志大小变大了,但是任然没有在es中有索引新建立

查看file-beat发现有一行日志

2018/03/07 01:10:15.648001 client.go:465: WARN Can not index event (status=404): {"type":"index_not_found_exception","reason
*,.watches,.triggered_watches,.watcher-history*]) doesn't match","index_uuid":"_na_","index":"filebeat-6.1.0-2018.03.07"}

找不到index名字为filebeat-6.1.0-2018.03.07(这个要根据你当前时间运行)
然后我们在kibana中创建这个index

put filebeat-6.1.0-2018.03.07
{
}

然后查询

GET /filebeat-6.1.0-2018.03.07/_search
{
"query": {
"match_all": {}
}
}

 

发现信息为空

然后我继续在SecureCRT中执行了几个ls命令,再次查询结果如下,有许多数据了,都是日志中的

{
"_index": "filebeat-6.1.0-2018.03.07",
"_type": "doc",
"_id": "nUgF_mEBoynl0riLX-Vh",
"_score": 1,
"_source": {
"@timestamp": "2018-03-07T01:13:39.444Z",
"offset": 285,
"message": """[05, 1.log base,VERSIONS img_align_celeba.zip index.html.1 index.html.3 lib.tar.gz nohup.out Python-2.7.13.tar.gz tomcat zookeeper.out""",
"prospector": {
"type": "log"
},
"beat": {
"version": "6.1.0",
"name": "XTZ-01802051417",
"hostname": "XTZ-01802051417"
},
"source": """D:\00-SourceCRT\log\《192.168.10.84》-03-07-09.log"""
}
},
{
"_index": "filebeat-6.1.0-2018.03.07",
"_type": "doc",
"_id": "pEgF_mEBoynl0riLY-Vg",
"_score": 1,
"_source": {
"@timestamp": "2018-03-07T01:13:40.452Z",
"source": """D:\00-SourceCRT\log\《192.168.10.84》-03-07-09.log""",
"offset": 748,
"message": "-rw-r--r-- 1 root root 16050745 Oct 26 10:11 2.txt",
"prospector": {
"type": "log"
},
"beat": {
"version": "6.1.0",
"name": "XTZ-01802051417",
"hostname": "XTZ-01802051417"
}
}
},

 

而且在kibana中查看到

 

你有可能看不到这些,需要看提示去掉action.auto_create_index配置

posted on 2012-07-24 11:02  duanxz  阅读(3609)  评论(0编辑  收藏  举报