栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Metricbeat入门案例

Metricbeat入门案例

1.介绍

Metricbeat是一款轻量型指标采集器,用于收集操作系统及应用服务的指标数据。

2.安装
  1. 使用rz工具将Metricbeat压缩文件上传到Linux虚拟机
  2. 解压:
tar -zxvf metricbeat-7.12.1-linux-x86_64.tar.gz -C /opt/app/
3.采集系统指标
  1. 修改Metricbeat默认配置文件
cd /usr/local/metricbeat-7.12.1-linux-x86_64/ 
vim metricbeat.yml
# 模板文件的位置 
metricbeat.config.modules: path: ${path.config}/modules.d/*.yml 
# 采集到的数据输出到ES的路径 
output.elasticsearch: hosts: 
["node0:9200"]
  1. 查看系统指标采集模板
# 进入模板文件目录 
cd /usr/local/metricbeat-7.12.1-linux-x86_64/modules.d/
# 查看系统指标采集模板 
cat system.yml
  1. 开启Metricbeat,开始采集系统指标
cd /usr/local/metricbeat-7.12.1-linux-x86_64 
./metricbeat -e

-e 代表启动时使用默认配置文件

4. 采集Nginx指标
  1. nginx必须开启状态查询,才能查询到指标数据。
# 重新安装nginx 
cd /usr/local/nginx-1.21.1/
./configure --prefix=/usr/local/nginx --with-http_stub_status_module 
make 
make install

# 配置nginx 
cd /usr/local/nginx/conf 
vim nginx.conf 
# 在server内加入以下内容 
location /status { 
	stub_status on; 
	access_log off; 
}

# 重启nginx 
cd /usr/local/nginx/sbin 
./nginx -s stop 
./nginx
  1. 访问http://虚拟机IP/status,查看nginx指标数据:

    Active connections:目前活跃的连接数
    server:总共处理的连接数
    accepts :成功创建的握手数
    server - accepts = 0,证明所有的连接均成功握手,没有失败连接。
    handled requests:总共处理的请求数
    Reading:Nginx读取到客户端的Header信息数
    Writing:Nginx返回给客户端Header信息数
    Waiting:Nginx已经等待请求的驻留链接
  2. Metricbeat采集nginx指标
    配置nginx指标采集模板:
#启用ngnix模板 
./metricbeat modules enable nginx
#修改ngnix模板配置 
cd /usr/local/metricbeat-7.12.1-linux-x86_64/ 
vim modules.d/nginx.yml
# 加入如下配置:
- module: nginx 
  period: 10s 
  hosts: ["http://node0"] 
  server_status_path: "status"
#重启Metricbeat:
./metricbeat -e
  1. kibana查看采集到的nginx指标
GET /metricbeat索引/_search
{
  "query": {
    "term": {
      "service.type": {
        "value": "nginx"
      }
    }
  }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/632794.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号