Ubuntu 20.04 部署Prmoetheus+grafana+mysql+mysqld_exporter+node_exporter
Prometheus简介
Prometheus是一个功能强大的开源监控系统,可从您的服务中收集指标并将其存储在时间序列数据库中。它通过Grafana等工具提供多维数据模型,灵活的查询语言和多样化的可视化可能性。
默认情况下,Prometheus仅导出有关其自身的指标(例如,它收到的请求数,内存消耗等)。但是,您可以通过安装导出程序,生成其他指标的可选程序来大大扩展Prometheus 。
出口商 - Prometheus团队维护的官方出版物以及社区贡献的出口商 - 提供从基础设施,数据库和Web服务器到消息系统,API等所有内容的信息。
一些最受欢迎的选择包括:
node_exporter - 这将生成有关基础结构的度量标准,包括当前CPU,内存和磁盘使用情况,以及I / O和网络统计信息,例如从磁盘读取的字节数或服务器的平均负载。
blackbox_exporter - 这会生成从HTTP和HTTPS等探测协议派生的指标,以确定端点可用性,响应时间等。
mysqld_exporter - 收集与MySQL服务器相关的度量标准,例如执行的查询数,平均查询响应时间和集群复制状态。
rabbitmq_exporter - 输出有关RabbitMQ消息传递系统的指标,包括发布的消息数,准备发送的消息数以及队列中所有消息的大小。
nginx-vts-exporter - 提供有关使用Nginx VTS模块的Nginx Web服务器的指标,包括打开的连接数,发送的响应数(按响应代码分组)以及发送或接收的请求的总大小(以字节为单位) 。
一、prometheus
1、下载地址:https://prometheus.io/download/prometheus-2.35.0.linux-amd64.tar.gz
github下载地址:https://github.com/prometheus/prometheus/tags
tar xf prometheus-2.35.0.linux-amd64.tar.gz -C /usr/local/
mv prometheus-2.35.0.linux-amd64 prometheus
2、vim /etc/systemd/system/prometheus.service
[Unit]
Description=prometheus
Wants=network-online.target
After=network-online.target [Service]
Type=simple
ExecStart=/usr/local/prometheus/prometheus \
--config.file /usr/local/prometheus/prometheus.yml \
# --storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/usr/local/prometheus/consoles \
--web.console.libraries=/usr/local/prometheus/console_libraries [Install]
WantedBy=multi-user.target
3、修改prmoetheus.yml文件
在global设置中,定义抓取指标的默认时间间隔。请注意,除非单个导出器自己的设置覆盖全局变量,否则Prometheus会将这些设置应用于每个导出器。
scrape_interval值告诉Prometheus 每15秒从其出口商那里收集指标,这对于大多数出口商而言足够长。
使用scrape_configs指令将Prometheus本身添加到导出器列表中。
使用job_name在标签和图表上标记出口商,因此请务必在此处选择描述性内容。
使用static_configs和targets指令来确定导出器的运行位置。
sudo vim /usr/local/prometheus/prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s). # Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus' # metrics_path defaults to '/metrics'
# scheme defaults to 'http'. static_configs:
- targets: ['localhost:9090'] - job_name: 'node_exporter'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9100'] # - job_name: 'nm_mch-app_node'
# file_sd_configs:
#- files: ['/usr/local/prometheus/targets/node/node.yml']
#refresh_interval: 5s - job_name: 'mysqld_exporter'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9104']
注:安装哪个服务就在后面添加哪个服务,如上所示!
4、重载加载并启动服务
sudo systemctl daemon-reload
sudo systemctl start prometheus.service
sudo systemctl enable prometheus.service
sudo systemctl status prometheus.service
二、mysqld_exporter及安装mysql
1、下载地址:https://prometheus.io/download/mysqld_exporter-0.14.0.linux-amd64.tar.gz
tar xf mysqld_exporter-0.14.0.linux-amd64.tar.gz -C /usr/local/
mv mysqld_exporter-0.14.0.linux-amd64 mysqld_exporter
2、sudo vim /usr/local/mysqld_exporter/.my.cnf
[client]
user=mysqld_exporter
password=Password
3、sudo vim /etc/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf
Restart=on-failure
[Install]
WantedBy=multi-user.target
4、重载加载并启动服务
sudo systemctl daemon-reload
sudo systemctl start mysqld_exporter.service
sudo systemctl enable mysqld_exporter.service
sudo systemctl status mysqld_exporter.service
5、安装mysql
注:因为mysqld_exporter要从mysql中取数据
sudo apt install mysql-server
sudo apt install mysql-client
sudo apt-get install libmysqlclient-dev
6、sudo cat /etc/mysql/debian.cnf
[client]
host = localhost
user = debian-sys-maint >>> 用户名
password = lncvxxxxxxxx2Zrd >>> 密码
7、登录mysql
sudo mysql -u debian-sys-maint -p
CREATE USER 'mysqld_exporter'@'localhost' IDENTIFIED BY 'Password' WITH MAX_USER_CONNECTIONS 2; >>>创建用户
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysqld_exporter'@'localhost'; >>>赋权限
FLUSH PRIVILEGES; >>>刷新权限
8、重启mysql
sudo systemctl restart mysql
sudo systemctl status mysql
三、node_exporter
1、下载地址:https://prometheus.io/download/node_exporter-1.3.1.linux-amd64.tar.gz
tar xf node_exporter-1.3.1.linux-amd64.tar.gz -C /usr/local/
mv node_exporter-1.3.1.linux-amd64 node_exporter
2、sudo vim /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target [Service]
Type=simple
ExecStart=/usr/local/node_exporter/node_exporter [Install]
WantedBy=multi-user.target
3、重载加载并启动服务
sudo systemctl daemon-reload
sudo systemctl start node_exporter.service
sudo systemctl enable node_exporter.service
sudo systemctl status node_exporter.service
四、grafana-server
1、下载地址:https://grafana.com/grafana/download?edition=oss
wget https://dl.grafana.com/oss/release/grafana-8.0.4.linux-amd64.tar.gz
tar xf grafana-8.0.4.linux-amd64.tar.gz -C /usr/local/
2、sudo vim /lib/systemd/system/grafana-server.service
[Unit]
Description=Grafana
After=network-online.target [Service]
User=root
group=root
Type=simple
Restart=on-failure
WorkingDirectory=/usr/local/grafana-8.0.4/bin/
ExecStart=/usr/local/grafana-8.0.4/bin/grafana-server --config=/usr/local/grafana-8.0.4/conf/defaults.ini [Install]
WantedBy=multi-user.target
3、重新加载并启动服务
sudo systemctl daemon-reload
sudo systemctl start grafana-server.service
sudo systemctl enable grafana-server.service
sudo systemctl status grafana-server.service
五、登录grafana查看效果
登录地址:http://本机IP:3000
1、添加Prometheus来源
2、添加node_porter模板
3、Copy ID to Clipboard 至Grafana.com dashboard URL or ID ,如输入:11074,点击Load,选择prometheus
地址:https://grafana.com/grafana/dashboards/
3、即可显示node_exporter主机信息。
4、添加mysqld_exporter模板
需要从Grafana的存储库中填写仪表板的URL。将链接粘贴到“ URL”部分,https://grafana.com/grafana/dashboards/7362
将Prometheus数据源名称更改为“ Prometheus ”,然后单击“ 导入 ”,即可查看MySQL相关监控信息!
5、Prometheus访问
访问地址:本地IP:9090
至此,部署完成!
Ubuntu 20.04 部署Prmoetheus+grafana+mysql+mysqld_exporter+node_exporter的更多相关文章
- Ubuntu 20.04上安装MySQL教程,ubuntu安装mysql
在Ubuntu 20.04上安装MySQL教程 先决条件 确保您以具有sudo特权的用户身份登录. 在Ubuntu上安装MySQL 在撰写本文时,Ubuntu存储库中可用的MySQL的最新版本是MyS ...
- 安装MySQL到Ubuntu 20.04
本文的内容主要来自对How To Install MySQL on Ubuntu 20.04的翻译.在根据该文的指导下,我在自己的Ubuntu 20.04.3 LTS版本中安装了MySQL 8. St ...
- Ubuntu 20.04安装Docker
Docker学习系列文章 入门必备:十本你不容错过的Docker入门到精通书籍推荐 day1.全面的Docker快速入门教程 day2.CentOS 8.4安装Docker day3.Windows1 ...
- Ubuntu 20.04下源码编译安装ROS 2 Foxy Fitzroy
ROS 2 Foxy Fitzroy(以下简称Foxy)于2020年6月5日正式发布了,是LTS版本,支持到2023年5月.本文主要根据官方的编译安装教程[1]完成,并记录编译过程中遇到的问题. 1. ...
- win10 + Ubuntu 20.04 LTS 双系统 引导界面美化
版权声明:本文为CSDN博主「ZChen1996」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明. 原文链接:https://blog.csdn.net/ZChen1 ...
- Windows10 + Ubuntu 20.04 LTS 双系统安装 (UEFI + GPT)(图文,多图预警)
版权声明:本文为CSDN博主「ZChen1996」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明. 原文链接:https://blog.csdn.net/ZChen1 ...
- Ubuntu 20.04.1 安装软件和系统配置脚本
#!/bin/bash # https://launchpad.net/ubuntu # https://www.easyicon.net # https://download-chromium.ap ...
- Ubuntu 20.04 手动安装 sublime_text 并建立搜索栏图标(解决 Ubuntu 20.04 桌面图标无法双击打开问题)
下载sublime_text_3离线程序包 wget https://download.sublimetext.com/sublime_text_3_build_3211_x64.tar.bz2 #x ...
- Ubuntu 20.04上通过Wine 安装微信
没有想过会在一个手机软件上花这么多心思,好在今天总算安装成功,觉得可以记录下这个过程,方便他人方便自己. 首先介绍下我使用过的其他方法,希望可以节省大家一些时间: Rambox Pro:因为原理是网页 ...
- 树莓派安装 Ubuntu 20.04 LTS 碰壁指南
树莓派安装 Ubuntu 20.04 LTS 碰壁指南 设备 Raspberry 4B 4+32G 系统 Ubuntu 20.04 LTS 1.镜像下载与烧录 镜像下载地址:https://cdima ...
随机推荐
- 题解[LuoguP5591]小猪佩奇学数学
题解[LuoguP5591]小猪佩奇学数学 前置知识 基本数论推式子能力,如分配律结合律等 等比数列求和 \(\sum_{i=a}^bx^i=\dfrac{x^{b+1}-x^a}{x-1}\) 二项 ...
- 096_mulesoft with salesforce _01
https://docs.mulesoft.com/mule-runtime/3.5/connect-with-salesforce-example https://www.youtube.com/w ...
- vue去除富文本的标签和样式
vue利用正则去除富文本的标签和样式 ts: const removeHtmlStyle =(html :any)=> { let relStyle = /style\s*?=\s*?(['&q ...
- 错误:[ERROR] 不再支持源选项 5。请使用 6 或更高版本。 [ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。
解决方案 pom.xml文件中增加maven编译的java.version jdk版本设置,以及maven.compiler.source 资源编译jdk版本设置和maven.compiler.tar ...
- go1.8-泛型
基本思想: Parametric Polymorphism(形式)参数多态 基本语法 package main import "fmt" func printSlice[T any ...
- windows 链接 MySQL8.0.28 报错: SSL connection error: unknown error number 解决办法
找到 My.ini文件,以管理员身份打开并在 [mysqld] 节点下 增加 skip_ssl 选项并保存,重启 MySQL 服务 执行SQL语句 SHOW VARIABLES L ...
- 雪花算法-Java分布式系统自增id
1.雪花算法的用途 分布式系统中ID生成方案,比较简单的是UUID(Universally Unique Identifier,通用唯一识别码),但是其存在两个明显的弊端: 一.UUID是128位的, ...
- [SSH-1]publickey,gssapi-keyex,gssapi-with-mic
实际上,是有两个不同的原因的,它们都会造成这个报错. 原因1)client端私钥文件权限太大 解决方法:chmod 400 ~/.ssh/id_rsa #如果是RSA算法的话,私钥生成时默认叫id_ ...
- java 之 UncaughtExceptionHandler异常处理机制
1.java 1.5版本出现的 UncaughtExceptionHandler 当线程由于未捕获异常突然终止时调用的处理程序的接口. 当一个线程由于未捕获异常即将终止时,Java虚拟机将使用thre ...
- 在platformio自动上传esp8266固件
不想每次上传固件的时候手工点按钮,修改这个文件:C:\Users\你的登录名.platformio\platforms\espressif8266\builder\main.py 在319行UPLOA ...