Beats—Metricbeat-system采集、Nginx-status指标采集

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-t9P6I9Ia-1594638042892)(C:\Users\86156\Pictures\devops\ELK\批注 2020-07-11 082304.png)]

一、定义

Metricbeat是一种轻量级的托运人,您可以将其安装在服务器上,以定期从操作系统和服务器上运行的服务收集指标。Metricbeat会收集它收集的度量标准和统计信息,并将其运送到您指定的输出中,例如Elasticsearch或Logstash。

Metricbeat通过从服务器上运行的系统和服务收集指标来帮助您监视服务器。


二、组成

Metricbeat 由两部分组成,Module 和 Metricset

  • Module

    • 收集的对象,如:mysql、redis、nginx、操作系统等
  • Metricset

    • 收集指标的集合,如:CPU、memory、network 等


三、部署、运行

安装:
[root@localhost ~]# tar -zxvf metricbeat-7.6.2-linux-x86_64.tar.gz 
[root@localhost ~]# mv metricbeat-7.6.2-linux-x86_64 /usr/local/metricbeat
运行

{path}/metricbeat -e -c metricbeat.yml

{path}/metricbeat modules enable nginx

{path}/metricbeat modules list


〇、Module - system指标采集

{path}/metricbeat modules enable system 默认就是开启状态
{path}/metricbeat modules list 查看是否开启

修改配置文件:

vim {path}/metricbeat.yml

metricbeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/system.yml		#指定使用哪个 Module 模板收集对象数据
--------------------------------------------------

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["192.168.168.4:9200"]				#指定 elasticseaerch主机地址


Ⅰ、Module - Nginx 模块

开启 nginx.conf 的 status 页面

        location /nginx-status {
                stub_status on;
                access_log  off;
        }

CURL -XGET 192.168.168.13/status

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-P1CT0Qis-1594638042895)(C:\Users\86156\Pictures\devops\ELK\批注 2020-07-11 091115.png)]

  • Active connections:正在处理的活动连接数

  • server accepts handled requests

    • 第一个 server 表示Nginx 启动到现在共处理了 7 个连接
    • 第二个 accetps 表示 Nginx启动到现在共创建 7 次握手
    • 第三个 Handled requests 表示总共处理了 7次请求
  • Reading:0 Writing:1 Waiting:1

    • Reading:Nginx 读取到客户端的 Header 信息数
    • Writing:Nginx 返回给客户端 Header 信息数
    • Waiting:Nginx 已经处理完正在等候下一次请求指令的驻留链接(开启 Keep-alive ,Waiting值:Active - (Reading+Writing))

配置 Nginx Module

{path}/metricbeat modules enable nginx 启动Nginx

vim {path}/modules.d/nginx.yml

- module: nginx
  #metricsets:
  #  - stubstatus
  period: 10s		#采集间隔 10秒

  # Nginx hosts
  hosts: ["http://192.168.168.13"]

  # Path to server status. Default server-status
  server_status_path: "status"		#与 nginx.conf 里配置要相同

  #username: "user"     		#如果有用户密码,则在此处填写
  #password: "secret"

[root@localhost metricbeat]# ./metricbeat 启动


Ⅱ、Modules - System (系统指标) 仪表板

​ 如果你的 Metricbeat 开了多个 Modules(Nginx、redis、mysql)等等,那么都可以通过仪表板显示出来。在 dashboard 搜索相对应软件名即可。

修改配置文件

vim {path}/metricbeat.yml

setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "192.168.168.4:5601"	#指定 kibana 的地址

将仪表盘的数据 安装到 Kibana

[root@localhost metricbeat]# ./metricbeat setup --dashboards
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards

启动 Metricbeat

{path}/metricbeat -e -c metricbeat.yml

Kibanba 页面操作

找到 Dashboard ,搜索 System,找到安装的仪表板 “ [Metricbeat System] Host overview ECS”

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9RqbqM00-1594638042896)(C:\Users\86156\Pictures\devops\ELK\批注 2020-07-11 122132.png)]


Ⅲ、Filebeat - Modules - Nginx - 日志仪表板

编辑收集日志的配置文件

vim itcast-nginx.yml

filebeat.inputs:
setup.template.settings:
  index.number_of_shards: 3
output.elasticsearch:
  hosts: ["192.168.168.4:9200"]
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: true
setup.kibana:
  host: "192.168.168.4:5601"

安装仪表板

./filebeat -c itcast-nginx.yml setup

启动 filebeat

./filebeat -e -c itcast-nginx.yml

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值