模版配置说明
主要是关于索引和生命周期的配置 其他的在网上很多
#==================== Elasticsearch template setting ==========================
setup.template.settings:
index.number_of_shards: 1
# 允许自动生成index模板
setup.template.enabled: true
# # 生成index模板时字段配置文件
setup.template.fields: fields.yml
# # 如果存在模块则覆盖
setup.template.overwrite: true
# # 生成index模板的名称
setup.template.name: "park-ssm"
# # 生成index模板匹配的index格式
setup.template.pattern: "park-ssm-"
setup.ilm.enabled: auto
# 这里一定要注意 会在alias后面自动添加-*
setup.ilm.rollover_alias: "park-ssm"
setup.ilm.pattern: "{now/d}"
# # 生成kibana中的index pattern,便于检索日志
setup.dashboards.index: myfilebeat-7.0.0-*
#filebeat默认值为auto,创建的elasticsearch索引生命周期为50GB+30天。如果不改,可以不用设置
setup.ilm.enabled: true
## 连接kibana后会看到
setup.ilm.rollover_alias: "myfilebeat"
## Configure rollover index pattern.
setup.ilm.pattern: "{now/d}-000001"
setup.ilm.policy_name: myfilebeat-ilm-policy-7.0.0
#设置elasticsearch索引生命周期的配置文件
setup.ilm.policy_file: myfilebeat-ilm-policy-7.0.0.json
需要注意的是 索引的配置文件一定要正确 否则是不会生成新索引的 也就是按照日期生成日志索引的话 将不会在es中生成
比如 setup.ilm.rollover_alias: "park-ssm" 会自动在后面添加_*
则elastic的index 要设置成"park-ssm-{now/d}"
es的配置
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["yourip:9200"]
##一定要与上面的pattern对应
index: "park-ssm-{now/d}"
# Optional protocol and basic auth credentials.
#protocol: "https"
#username: "elastic"
#password: "changeme"
myfilebeat-ilm-policy-7.0.0.json :(与filebeat.yml在同一个目录即可)
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_age": "15d",
"max_size": "10gb"
}
}
},
"delete": {
"min_age": "15d",
"actions": {
"delete": {}
}
}
}
}
}