CentOS 7 搭建ELK 7.13.2 环境(二)- Beats使用

CentOS 7 搭建ELK 7.13.2 环境(二)- Beats使用

一、序言

本文主要补充介绍ELK Beats用法,ELK环境的搭建参照文章:
CentOS 7 搭建ELK 7.13.2 环境

二、metricbeat用法

1.监控elasticsearch

采集”es生产集群”的监控数据直接写入“es监控集群”
架构

  • 启用xpack.monitoring.collection.enabled
GET _cluster/settings

PUT _cluster/settings
{
  "persistent": {
    "xpack.monitoring.collection.enabled": true
  }
}
  • 启用es监控模块
metricbeat modules enable elasticsearch-xpack
  • 修改elasticsearch-xpack.yml
cd /etc/metricbeat
vim modules.d/elasticsearch-xpack.yml

# Module: elasticsearch
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.13/metricbeat-module-elasticsearch.html

- module: elasticsearch
  xpack.enabled: true
  period: 10s
  hosts: ["http://localhost:9200"]
  username: "elastic"
  password: "gAbEd5ViDusJgBF1p4GN"

  • 禁用system模块 (根据实际情况)
metricbeat modules disable system
  • 修改metricbeat.yml
cd /etc/metricbeat
vim metricbeat.yml
# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["localhost:9200"]

  # Protocol - either `http` (default) or `https`.
  #protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  username: "elastic"
  password: "gAbEd5ViDusJgBF1p4GN"

  • 可视化
    在这里插入图片描述
    在这里插入图片描述

  • 自动删除索引

通过修改metricbeat策略,实现自动删除索引
在这里插入图片描述

三、ILM 索引生命周期管理

1.ILM索引策略

PUT /_ilm/policy/my-ilm-policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_size": "1GB",
            "max_age": "1d",
            "max_docs": 1000
          }
        }
      },
      "warm": {
        "min_age": "30m",
        "actions": {
          "forcemerge": {
                "max_num_segments":1
              },
          "shrink": {
                "number_of_shards":1
              }
        }
      },
      "delete": {
        "min_age": "2h",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

2.索引模板

强烈建议rollover_alias别名和index_patterns保持统一,例如“metricbeat-7.13.3”对应"metricbeat-7.13.3-*"

PUT _index_template/my_index_template
{
  "index_patterns": ["metricbeat-7.13.3-*"],
  "template": {
    "settings": {
        "index.lifecycle.name": "my-ilm-policy", 
        "index.lifecycle.rollover_alias": "metricbeat-7.13.3"
    }
  },
  "priority": 0
}

3. 生命周期轮询间隔

生命周期轮询间隔 默认10分钟

PUT _cluster/settings
{
  "transient": {
    "indices.lifecycle.poll_interval":"1m"
  }
}

参考:
官网地址
冷热分离与索引生命周期管理
index-templates.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

搬山境KL攻城狮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值