Linux-Metricbeat 系统监控

官网:https://www.elastic.co/cn/beats/metricbeat

 

一、安装Metricbeat 

curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.5.0-amd64.deb
sudo dpkg -i metricbeat-7.5.0-amd64.deb

deb用于Debian/Ubuntu

 

二、修改Metricbeat配置文件

sudo vim /etc/metricbeat/metricbeat.yml
#==========================  Modules configuration ============================
metricbeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: true

  # Period on which files under path should be checked for changes
  #reload.period: 20s

#自定义ES的索引需要把ilm设置为false
setup.ilm.enabled: false
setup.template.name: "meng"
setup.template.pattern: "meng-*"

#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here or by using the `setup` command.
setup.dashboards.enabled: true
setup.dashboards.index: "meng-*"

#============================== Kibana =====================================
# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:
  host: "IP:5601"

#================================ 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: ["IP:9200"]
  index: "meng-%{[agent.version]}-%{+yyyy.MM.dd}"

 

三、启用 system 模块

sudo metricbeat modules enable system

 

四、相关命令

#启动
sudo systemctl start metricbeat
#重启
sudo systemctl restart metricbeat
#停止
sudo systemctl stop metricbeat

#开机自启
sudo systemctl enable metricbeat

 

五、开启或关闭mysql模块

metricbeat  modules enable mysql
metricbeat modules disable mysql
vim /etc/metricbeat/modules.d/mysql.yml
# Module: mysql
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.5/metricbeat-module-mysql.html

- module: mysql
  metricsets:
    - status
  #  - galera_status
  period: 10s

  # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/"
  # or "unix(/var/lib/mysql/mysql.sock)/",
  # or another DSN format supported by <https://github.com/Go-SQL-Driver/MySQL/>.
  # The username and password can either be set in the DSN or using the username
  # and password config options. Those specified in the DSN take precedence.
  hosts: ["数据库用户名:数据库密码@tcp(IP:3306)/"]

  # Username of hosts. Empty by default.
  #username: root

  # Password of hosts. Empty by default.
  #password: secret

 

六、访问 Kibana

服务器:

 

Mysql:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值