*Prometheus* 是一个开源的服务监控系统和时间序列数据库

官方网站:prometheus.io

一、安装prometheus

cd /usr/local/        #进入安装目录

wget https://github.com/prometheus/prometheus/releases/download/v2.27.1/prometheus-2.27.1.linux-amd64.tar.gz        #wget下载prometheus安装包

tar xf prometheus-2.27.1.linux-amd64.tar.gz        #解压

ln -s prometheus-2.27.1.linux-amd64 prometheus        #建立软链接

chown -R root.root prometheus-2.27.1.linux-amd64        #授予root权限

普罗米修斯默认前台启动,构建启动脚本完成后台启动:
vim /lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus server daemon
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart="/usr/local/prometheus/prometheus" --config.file="/usr/local/prometheus/prometheus.yml" --storage.tsdb.path="/usr/local/prometheus/data" --storage.tsdb.retention=5d --web.console.
templates="/usr/local/prometheus/consoles" --web.console.libraries="/usr/local/prometheus/console_libraries" --web.max-connections=512 --web.external-url="http://192.168.149.133:9090" --web.listen-address="0.0.0.0:9090"Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl restart prometheus.service
systemctl status prometheus.service
启动完成可访问页面 默认为9090端口

二、添加监控服务器选项(监控主机)

在配置文件中加入监控配置信息,比如要监控xxx.xxx.xxx.134服务器,如下配置

在xxx.xxx.xxx.134安装node_exporter插件,在普罗米修斯官网就可下载

xxx.xxx.xxx.134主机进行以下操作:
cd /usr/local        #进入安装插件目录

wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz        #wget下载插件安装包

tar xf node_exporter-1.1.2.linux-amd64.tar.gz        #解压

ln -s node_exporter-1.1.2.linux-amd64 node_exporter        #建立软连接

chown -R root.root node_exporter-1.1.2.linux-amd64        #授予root权限

构建node_exporter后台启动脚本:
vim /lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/node_exporter/node_exporter \
--collector.mountstats \
--collector.systemd \
--collector.ntp \
--collector.tcpstat
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=2s
Restart=always

[Install]
WantedBy=multi-user.target

systemctl daemon-reload                #加载配置文件
systemctl start node_exporter.service        #启动node插件
systemctl status node_exporter.service      #查看运行状态

回到普罗米修斯主机,修改配置文件(只修改以下蓝色部分内容):
vim /usr/local/prometheus/prometheus.yml

......
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'
   metrics_path '/metrics'
   static_configs:
    - targets: 
      - 'xxx.xxx.xxx.134:9100'
......

systemctl daemon-reload
systemctl restart prometheus.service
重启完成可访问页面查看

三、添加监控应用级选项(监控各种应用,以mysql为例)

在配置文件中加入监控配置信息,比如要监控xxx.xxx.xxx.135服务器上的mysql,如下配置

在xxx.xxx.xxx.135安装mysqld_exporter插件,在普罗米修斯官网就可下载

在xxx.xxx.xxx.135主机操作:
cd /usr/local

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz

tar xf mysqld_exporter-0.13.0.linux-amd64.tar.gz

ln -s mysqld_exporter-0.13.0.linux-amd64 mysqld_exporter

chown -R root.root mysqld_exporter-0.13.0.linux-amd64

构建mysqld_exporter后台启动脚本:
vim /lib/systemd/system/mysqld_exporter.service
[Unit]
Description=Prometheus MySQL Exporter
After=network.target

[Service]
Type=simple
Restart=always
User=root
Group=root
ExecStart=/usr/local/mysqld/mysqld_exporter --config.my-cnf=/usr/local/mysqld/mysqld_exporter.cnf --collect.global_status --collect.auto_increment.columns --collect.info_schema.processlist --collect.binlog_size
 --collect.info_schema.tablestats --collect.global_variables --collect.info_schema.innodb_metrics --collect.info_schema.query_response_time --collect.info_schema.userstats --collect.info_schema.tables --collect.perf_schema.tablelocks --collect.perf_schema.file_events --collect.perf_schema.eventswaits --collect.perf_schema.indexiowaits --collect.perf_schema.tableiowaits --collect.slave_status --web.listen-address=0.0.0.0:9104
[Install]
WantedBy=multi-user.target

创建mysql进入启动配置文件(同时确保mysql数据库有root用户并授权了远程可登录):
vim /usr/local/mysqld_exporter/mysqld_exporter.cnf
[client]
user=root
password=123456

检测mysql配置文件是否正确:
./mysqld_exporter --config.my-cnf="./mysqld_exporter.cnf"

systemctl daemon-reload        #加载配置
systemctl start mysqld_exporter        #启动mysqld监控插件

回到普罗米修斯主机,修改配置文件:
vim /usr/local/prometheus/prometheus.yml

......
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'
   metrics_path '/metrics'
   static_configs:
    - targets: 
      - 'xxx.xxx.xxx.134:9100'

- job_name: 'mysqld_exporter'
   metrics_path '/metrics'
   static_configs:
    - targets: 
      - 'xxx.xxx.xxx.135:9104'
  
......

systemctl daemon-reload                #加载配置
systemctl restart prometheus.service        #重启prometheus服务

访问xxx.xxx.xxx.xxx:9090就可看到主机级和mysql的监控情况

注意:各类监控服务配置和上面配置大同小异,各类监控服务插件在prometheus官网就可直接下载使用:https://prometheus.io/

普罗米修斯!Ubuntu下prometheus监控软件安装使用的更多相关文章

  1. 一步步教你用Prometheus搭建实时监控系统系列(一)——上帝之火,普罗米修斯的崛起

    上帝之火 本系列讲述的是开源实时监控告警解决方案Prometheus,这个单词很牛逼.每次我都能联想到带来上帝之火的希腊之神,普罗米修斯.而这个开源的logo也是火,个人挺喜欢这个logo的设计. 本 ...

  2. Prometheus普罗米修斯快速入门

    欢迎来到普罗米修斯! Prometheus是一个监控平台,通过从监控目标的抓取HTTP端点上获取指标. 本指南将展示如何使用和安装Promethues,配置和监视第一个资源.还将下载并安装导出器Exp ...

  3. 普罗米修斯Prometheus监控安装

    普罗米修斯Prometheus监控安装 架构: 服务端:192.168.0.204 客户端:192.168.0.206 环境准备:所有节点安装go 语言环境 rz go1.12.linux-amd64 ...

  4. 监控神器-普罗米修斯Prometheus的安装

    搬砖党的福音:普罗米修斯-监控神器 功能: 在业务层用作埋点系统 Prometheus支持多种语言(Go,java,python,ruby官方提供客户端,其他语言有第三方开源客户端).我们可以通过客户 ...

  5. 在Grafana使用普罗米修斯

    aaarticlea/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IE ...

  6. 记录一次k8s环境尝试过程(初始方案,现在已经做过很多完善,例如普罗米修斯)

    记录一次Team k8s环境搭建过程(初始方案,现在已经做过很多完善,例如普罗米修斯) span::selection, .CodeMirror-line > span > span::s ...

  7. (2012年旧文)纪念史蒂夫乔布斯---IT界的普罗米修斯

    谈苹果与乔布斯系列一  IT界的普罗米修斯 纪念PC界的先驱 史蒂夫乔布斯 2012-4-5 清明节,纪念IT时代的开创人—伟大的史蒂夫 乔布斯. 没有乔布斯,计算机还是属于一群科技人士的工具,没有漂 ...

  8. 当ABAP遇见普罗米修斯

    Jerry每次在工作场合中同Prometheus(普罗米修斯)打交道时,都会"出戏",因为这个单词给我的第一印象,并不是用go语言实现的微服务监控利器,而是名导雷德利·斯科特(Ri ...

  9. 普罗米修斯+grafana监控k8s

    其实现原理有点类似ELK.node-exporter组件负责收集节点上的metrics监控数据,并将数据推送给prometheus, prometheus负责存储这些数据,grafana将这些数据通过 ...

随机推荐

  1. SolidWorks在一个零件中设置不同的尺寸版本

    问题 比如想设置一系列螺丝的长度,一个一个建零件非常麻烦,希望在一个零件中设置不同的长度尺寸版本 解决 比如想设置不同的拉伸长度,右键拉伸>配置特征 可以生成新配置,设置不同的D1参数,即可生成 ...

  2. J20航模遥控器开源项目系列教程(五)| 制作STM32F0接收机,8路PWM输出,SBUS输出,PPM输出 | 加密狗无线化,畅玩飞行模拟器

    我们的开源宗旨:自由 协调 开放 合作 共享 拥抱开源,丰富国内开源生态,开展多人运动,欢迎加入我们哈~ 和一群志同道合的人,做自己所热爱的事! 项目开源地址:https://github.com/J ...

  3. MySQL—分页查询

    分页查询 应用场景:当要显示的数据,当一页显示不全,有很多的数据时,就需要分页提交sql请求 语法:select 查询列表 from表名 [  join type join 表2 on连接条件 whe ...

  4. 一文读懂蓝绿发布、A/B 测试和金丝雀发布的优缺点

    作者 | 扬少 背景 目前,业界已经总结出了几种常见的服务发布策略来解决版本升级过程中带来的流量有损问题.本文首先会对这些普遍的发布策略进行简单的原理解析,最后结合阿里云的云原生网关对这些发布策略进行 ...

  5. Python -用虚拟环境保存库文件

    如果你同时负责多个 Python 项目,或者想要轻松打包某个项目及其关联的库文件,再或者你担心已安装的库之间可能有冲突,那么你可以安装一个 Python 虚拟环境来分而治之.当一个 Python 库不 ...

  6. swagger-ui提交请求无name(指input中的name属性)值

    swagger-ui提交请求,请求不包含name值,造成后台无法进行接受参数. @Operation(description = "上传文件",tags = "上传&qu ...

  7. MyBatis Plus 2.3 个人笔记-04-配置文件与插件使用

    接入 springboot application.yml配置 1.mapper 扫描 mybatis-plus: # 如果是放在src/main/java目录下 classpath:/com/you ...

  8. 阿里低代码引擎 | LowCodeEngine - 如何配置并调用请求

    首发于 语雀文档@blueju 前言 发送请求是前端中很重要也很常见的一部分,阿里低代码引擎自然也不会缺少这一块.在阿里低代码引擎中,请求是在数据源中配置,数据源位置如下图: 配置 配置界面如下图:其 ...

  9. Excel之“提取指定符号(中括号)中的字符”

    提取A1中[]内的字符函数:=MID(A1,SEARCH("[",A1)+1,SEARCH("]",A1)-SEARCH("[",A1)-1 ...

  10. Java根路径设置(在获取本地路径时会获取到这个文件夹,,这样就可以专门放配置文件了)

    在获取本地路径时会获取到这个文件夹,,这样就可以专门放配置文件了