“没有合格的黑夜,也就无所谓真正的黎明。”
Metricbeat+Filebeats 基本监控机器运行一举一动。
01
—
简介
Metricbeat是一种轻量级的托运人,您可以将其安装在服务器上,以定期从操作系统和服务器上运行的服务收集指标。Metricbeat会收集它收集的度量标准和统计信息,并将其运送到您指定的输出,例如Elasticsearch或LogstashMetricbeat是一种轻量级的托运人,您可以将其安装在服务器上,以定期从操作系统和服务器上运行的服务收集指标。Metricbeat会收集它收集的度量标准和统计信息,并将其运送到您指定的输出,例如Elasticsearch或Logstash。
Metricbeat通过从服务器上运行的系统和服务收集指标来帮助您监视服务器,例如:
Apache
HAPorxy
MongoDB
MySQL
Nginx
PostgreSQL
Redis
System
Zookerper
02
—
安装
Windows:
#浏览器下载https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.3.0-windows-x86_64.zip#解压后存放在c:\Program Files\并把解压出来的目录名字重命名为Metricbeat,如下c:\Program Files\Metricbeat#进入目录cd C:\Program Files\Metricbeat#注册系统服务powershell -c "Get-Location"powershell -c ".\install-service-metricbeat.ps1"#开启监控模块powershell -c ".\metricbeat.exe modules enable windows"#关闭监控模块powershell -c ".\metricbeat.exe modules disable windows"#启动系统服务timeout /T 10powershell -c "Start-Service metricbeat"
Linux:
wget https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.3.0-linux-x86_64.tar.gztar -xf metricbeat-7.3.0-linux-x86_64.tar.gzmv metricbeat-7.3.0-linux-x86_64 metricbeat
#配置metricbeat.config.modules:path: ${path.config}/modules.d/*.ymlreload.enabled: falsesetup.template.settings:index.number_of_shards: 1index.codec: best_compressionsetup.kibana:host: "http://10.0.0.1:5601"output.elasticsearch:hosts: ["http://10.0.0.2:80"]processors:- add_host_metadata:netinfo.enabled : true- add_cloud_metadata: ~
#开启仪表盘./metricbeat setup --dashboards#开启监控模块./metricbeat modules enable system mysql redis nginx php_fpm
#支持监控的模块(disabled是没开启的模块)aerospike.yml.disabledbeat.yml.disabledcoredns.yml.disableddropwizard.yml.disabledetcd.yml.disabledhttp.yml.disabledkibana.yml.disabledlogstash.yml.disabledmunin.yml.disabledoracle.yml.disabledrabbitmq.yml.disableduwsgi.yml.disabledapache.yml.disabledceph.yml.disabledcouchbase.yml.disabledelasticsearch-xpack.yml.disabledgolang.yml.disabledjolokia.yml.disabledkubernetes.yml.disabledmemcached.yml.disabledmysql.ymlphp_fpm.ymlredis.ymlvsphere.yml.disabledaws.yml.disabledcockroachdb.yml.disabledcouchdb.yml.disabledelasticsearch.yml.disabledgraphite.yml.disabledkafka.yml.disabledkvm.yml.disabledmongodb.yml.disablednats.yml.disabledpostgresql.yml.disabledsystem.ymlwindows.yml.disabledbeat-xpack.yml.disabledconsul.yml.disableddocker.yml.disabledenvoyproxy.yml.disabledhaproxy.yml.disabledkibana-xpack.yml.disabledlogstash-xpack.yml.disabledmssql.yml.disablednginx.ymlprometheus.yml.disabledtraefik.yml.disabledzookeeper.yml.disabled
system.yml
# Module: system# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-system.html- module: systemperiod: 10smetricsets:- cpu- load- memory- network- process- process_summary- socket_summary- entropy- core- diskio#- socketprocess.include_top_n:by_cpu: 5 # include top 5 processes by CPUby_memory: 5 # include top 5 processes by memory- module: systemperiod: 10smetricsets:- filesystem- fsstatprocessors:- drop_event.when.regexp:system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'- module: systemperiod: 15mmetricsets:- uptime#- module: system# period: 5m# metricsets:# - raid# raid.mount_point: '/'
nginx.yml
# Module: nginx# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-nginx.html- module: nginx#metricsets:# - stubstatusperiod: 10s# Nginx hostshosts: ["http://127.0.0.1:9080"]# Path to server status. Default server-statusserver_status_path: "status"#username: "user"#password: "secret"
mysql.yml
# Module: mysql# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-mysql.html- module: mysql#metricsets:# - status# - galera_statusperiod: 10s# Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/"# 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: ["mysql_exporter:mysql_exporter_2020@tcp(localhost:3306)/"]# Username of hosts. Empty by default.#username: root# Password of hosts. Empty by default.#password: secret
redis.yml
[root@Lan-Kvm-20058-GuangSql modules.d]# vim redis.yml.disabled# Module: redis# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-redis.html- module: redis#metricsets:# - info# - keyspaceperiod: 10s# Redis hostshosts: ["127.0.0.1:6379"]# Network type to be used for redis connection. Default: tcp#network: tcp# Max number of concurrent connections. Default: 10#maxconn: 10# Redis AUTH password. Empty by default.#password: foobared
php_fpm.yml
# Module: php_fpm# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.3/metricbeat-module-php_fpm.html- module: php_fpm#metricsets:# - pool# - processperiod: 10shosts: ["127.0.0.1:9080"]status_path: "/dalan-status"#username: "user"#password: "secret
#配置系统服务化[Unit]Description=Node ExporterWants=network-online.targetAfter=network-online.target[Service]User=rootExecStart=/metricbeat/metricbeat --path.config /metricbeat[Install]WantedBy=default.target
#启动systemctl daemon-reloadsystemctl start metricbeat

文章转载自运维技术经验分享,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




