Exporter + Prometheus + Grafana进行监控

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
可观测可视化 Grafana 版,10个用户账号 1个月
简介: Exporter + Prometheus + Grafana进行监控

上次我们介绍了在压测端使用JMeter集群+Influxdb存储+Grafana实时数据展示进行监控,今天我们来介绍下在被测端使用JMeter集群+Influxdb存储+Grafana实时数据展示Exporter + Prometheus +Grafana来进行监控。

1.  Exporter


在压测端,Linux系统Exporternode_exporter。可通过以下几个命令进行和下载和安装。

Windows 使用windows_exporter.exe

  • 下载windows_exporter.exe或者windows_exporter.msi
  • 安装完毕后,默认在C:\ProgramFiles\windows_exporter\
  • 运行windows_exporter.exe
  • 打开浏览器,输入127.0.0.1:9182


注意node_exporter端口为9100,而windows_exporter9182

image.png


点击Metrics可以显示收集到的操作系统信息

# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE  go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"}  0
go_gc_duration_seconds{quantile="0.25"}  0
go_gc_duration_seconds{quantile="0.5"}  0
go_gc_duration_seconds{quantile="0.75"}  0
go_gc_duration_seconds{quantile="1"}  0.0022913
go_gc_duration_seconds_sum  0.0043842
go_gc_duration_seconds_count  34


HELP是解释下面指标的含义,相当于协助文档;其中:

  • TYPE用于解释指标的数据类型;
  • 下面的信息是具体的统计信息。


2.Prometheus


prometheus-2.27.1.windows-amd64或者Liunx下通过以下命令安装。

  • wget -chttps://github.com/prometheus/prometheus/releases/download/v2.15.1/prometheus-2.15.1.linux-amd64.tar.gz
  • tar zxvf prometheus-2.15.1.linux-amd64.tar.gz

修改:prometheus.yml

scrape_configs:

# The job name is added as  a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'OS'
    # metrics_path defaults  to '/metrics'
    # scheme defaults to  'http'.
    static_configs:
    - targets: ['127.0.0.1:9182']


  • 简单介绍一下这个文件。在这里Windows下使用- targets: ['127.0.0.1:9182'],而Linux下使用- targets:['127.0.0.1:9100']


  • global:为全局配置,比如每次数据收集的间隔、规则地扫描数据的间隔。
  • alerting:这里可以设置告警的插件,比如 alertmanager 插件。
  • rule_files:这里为具体的报警规则设置,比如基于什么指标进行报警,相当于触发器。
  • scrape_configs:采集数据的对象,job_nametarget 以及 job_name 是配置主机的名称,target 是为安装的 Exporter 地址。


运行prometheus.exe,打开浏览器输入,http://127.0.0.1:9090/targets

image.png


3 Grafana


Grafana的安装我们在上一文章中讲过,现在让我们来看一下如何对Prometheus进行集成。

启动Grafana

打开浏览器输入,http://127.0.0.1:3000/datasources/new,按下图输入:


image.png


验证测试通过

image.png


接下来import数据。

image.png


windows_exporter.exeID10467node_exporter ID8919。可以通过:

https://grafana.com/grafana/dashboards/10467

https://grafana.com/grafana/dashboards/8919来查看信息。点击【Load】。最后选择以下Prometheus就可以了。


image.png

image.png


4 配置MySQL监控


另外我们也可以来监控MySQL信息。通过https://prometheus.io/download/来下载。

image.png


建立my.cnf,配置MySQL连接信息。

[client]
host=127.0.0.1
port=3306
user=root
password=123456


通过运行mysqld_exporter.exe--config.my-cnf=my.cnf启动,在浏览器送输入http://127.0.0.1:9104/


image.png


prometheus.yml进行如下配置。


scrape_configs:
  # The job name is added as a label  `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'OS'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['127.0.0.1:9182']
  - job_name: 'MySql'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['127.0.0.1:9104']


重新启动prometheus.exe,在浏览器送输入http://127.0.0.1:9090/targets


image.png


启动Grafana

image.png


注意:mysql_exporter节点为11323,点击【Load】。最后仍旧选择Prometheus就可以了。


image.png


参考:

https://www.bookstack.cn/read/prometheus-book/README.md

目录
相关文章
|
2月前
|
Prometheus 监控 Kubernetes
如何用 Prometheus Operator 监控 K8s 集群外服务?
如何用 Prometheus Operator 监控 K8s 集群外服务?
|
2月前
|
Prometheus 监控 Kubernetes
Prometheus Operator 与 kube-prometheus 之二 - 如何监控 1.23+ kubeadm 集群
Prometheus Operator 与 kube-prometheus 之二 - 如何监控 1.23+ kubeadm 集群
|
1月前
|
数据采集 监控 数据库
请问OceanBase社区版能否通过zabbix监控,然后将报错信息展现到grafana?
【2月更文挑战第25天】请问OceanBase社区版能否通过zabbix监控,然后将报错信息展现到grafana?
25 2
|
2月前
|
存储 Prometheus Cloud Native
Grafana 系列 - 统一展示 -2-Prometheus 数据源
Grafana 系列 - 统一展示 -2-Prometheus 数据源
|
2月前
|
JSON Prometheus Cloud Native
Grafana 系列 - 统一展示 -3-Prometheus 仪表板
Grafana 系列 - 统一展示 -3-Prometheus 仪表板
|
2月前
|
监控 Cloud Native 关系型数据库
使用 Grafana 统一监控展示 - 对接 Zabbix
使用 Grafana 统一监控展示 - 对接 Zabbix
|
2月前
|
Prometheus 监控 Cloud Native
使用 Prometheus 配置 SLO 监控和告警
使用 Prometheus 配置 SLO 监控和告警
|
2月前
|
Prometheus Kubernetes Cloud Native
「译文」使用 Prometheus 和 Grafana 实现 SLO
「译文」使用 Prometheus 和 Grafana 实现 SLO
|
3月前
|
编解码 Prometheus 运维
Prometheus 的监控方法论
【1月更文挑战第24天】
|
3月前
|
存储 Prometheus 监控
Prometheus vs. ELK Stack:容器监控与日志管理工具的较量
随着容器化技术的广泛应用,容器监控与日志管理成为了关键任务。本文将对两种常用工具进行比较与选择,分别是Prometheus和ELK Stack。Prometheus是一款开源的监控系统,专注于时序数据的收集和告警。而ELK Stack则是一套完整的日志管理解决方案,由Elasticsearch、Logstash和Kibana三个组件组成。通过比较它们的特点、优势和适用场景,读者可以更好地了解如何选择适合自己需求的工具。