1.Prometheus的主要特征及概述

概述:

  1. Prometheus(由go语言(golang)开发)是一套开源的监控&报警&时间序列数据库的组合。适合监控docker容器。因为kubernetes(俗称k8s)的流行带动了prometheus的发展。
  2. 时间序列数据特点:
  3. 1.性能好
  4. 2.存储成本低,高效的压缩算法,节省存储空间,有效降低IO
  5. Prometheus有着非常高效的时间序列数据存储方法,每个采样数据仅仅占用3.5byte左右空间,上百万条时间序列,30秒间隔,保留60天,大概花了200G(来自官方数据)

特征:

  1. 1.多维度数据模型
  2. 2.灵活的查询语言
  3. 3.不依赖分布式存储,单个服务器节点是自主的
  4. 4.HTTP方式,通过pull模型拉去时间序列数据
  5. 5.也可以通过中间网关支持push模型
  6. 6.通过服务发现或者静态配置,来发现目标服务对象
  7. 7.支持多种多样的图表和界面展示

2.普罗米修斯原理架构图

3.下载安装启动Prometheus

  1. 官网下载地址:https://prometheus.io/download/
  2. //下载
  3. wgt https://github.com/prometheus/prometheus/releases/download/v2.35.0/prometheus-2.35.0.linux-amd64.tar.gz
  4. //解压
  5. tar -xf prometheus-2.35.0.linux-amd64.tar.gz -C /usr/local
  6. //改名
  7. mv prometheus-2.35.0.linux-amd64 prometheus
  8. //默认启动
  9. nohup ./prometheus --config.file="/usr/local/prometheus/prometheus.yml" &
  10. //端口检查
  11. lsof -i:9090
  12. ss -naltp |grep 9090
  13. //浏览器访问192.168.0.215:9090

4.web客户端操作

  1. //浏览器访问192.168.0.215:9090
  2. 默认监控本机

5.默认图像

6.目录解释

  1. console_libraries目录:
  2. consoles目录:
  3. LICENSE问价:
  4. NOTICE文件:
  5. prometheus文件:默认启动的可执行文件
  6. prometheus.yml配置文件:默认配置文件
  7. promtool文件:

7.配置文件

vi prometheus.yml

  1. global:
  2. scrape_interval: 60s # 拉取时间间隔
  3. evaluation_interval: 60s # 告警时间间隔
  4. - job_name: "prometheus" #监控名称取名字
  5. static_configs:
  6. - targets: ["localhost:9090"] #被监控机器的ip和端口

8.监控指标

  1. 指标配置下载:https://prometheus.io/download/

8.1.监控其他机器node_exporter

  1. 在其他机器安装node_exporter,端口9100

第一步:下载安装node_exporter

  1. //下载
  2. wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
  3. //解压
  4. tar -xf node_exporter-1.3.1.linux-amd64.tar.gz -C /usr/local/
  5. //改名
  6. mv node_exporter-1.3.1.linux-amd64 node_exporter
  7. //启动
  8. nohup /usr/local/node_exporter/node_exporter &
  9. //浏览器输入,监控数据,端口9100
  10. http://192.168.0.216:9100/metrics

第二步:配置到prometheus

  1. vi /usr/local/prometheus/prometheus.yml
  2. - job_name: "node"
  3. static_configs:
  4. - targets: ["192.168.0.216:9100"]
  5. labels:
  6. instance: 192.168.0.216
  7. group: node
  8. - targets: ["192.168.0.247:9100"]
  9. labels:
  10. instance: 192.168.0.247
  11. group: node
  12. - targets: ["192.168.0.235:9100"]
  13. labels:
  14. instance: 192.168.0.235
  15. group: node
  16. - targets: ["192.168.0.236:9100"]
  17. labels:
  18. instance: 192.168.0.236
  19. group: node
  20. //重启prometheus
  21. lsof -i:9090
  22. kill -9 xxxx
  23. nohup ./prometheus &

查看:

8.2监控mysql指标mysqld_exporter

第一步:下载安装mysqld_exporter

端口:9104

  1. //下载
  2. wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.14.0/mysqld_exporter-0.14.0.linux-amd64.tar.gz
  3. //解压
  4. tar -xf mysqld_exporter-0.14.0.linux-amd64.tar.gz -C /usr/local/
  5. //改名
  6. mv mysqld_exporter-0.14.0.linux-amd64 mysqld_exporter
  7. //创建mysqld_exporter需要使用mysql的用户名和密码,文件需要手动创建
  8. vi /usr/local/mysqld_exporter/my.cnf
  9. [client]
  10. host=192.168.0.215
  11. user=root
  12. password=123456
  13. port=3306
  14. //启动mysqld_exporter
  15. nohup ./mysqld_exporter --config.my-cnf=./my.cnf &
  16. //检查端口
  17. lsof -i:9104

第二步:配置到prometheus

  1. vi /usr/local/prometheus/prometheus.yml
  2. - job_name: "sg-215-mysql"
  3. static_configs:
  4. - targets: ["192.168.0.215:9104"]
  5. //重启prometheus
  6. lsof -i:9090
  7. kill -9 xxxx
  8. nohup ./prometheus &

查看:

8.3监控postgres指标postgres_exporter

第一步:下载安装postgres_exporter

  1. //下载
  2. wget https://github.com/prometheus-community/postgres_exporter/releases/download/v0.10.1/postgres_exporter-0.10.1.linux-386.tar.gz
  3. //解压
  4. tar -xf postgres_exporter-0.10.1.linux-386.tar.gz -C /usr/local/
  5. //改名
  6. mv postgres_exporter-0.10.1.linux-386 postgres_exporter
  7. //添加环境变量
  8. export DATA_SOURCE_NAME="postgresql://postgres:iLoveShark@192.168.0.247:32432/postgres?sslmode=disable"
  9. //启动
  10. nohup ./postgres_exporter &
  11. //浏览器输入:http://192.168.0.215:9187/metrics

第二步:配置到prometheus

  1. - job_name: "postgreSql"
  2. static_configs:
  3. - targets: ["192.168.0.215:9187"]
  4. labels:
  5. instance: 192.168.0.247:32432
  6. group: postgreSql
  7. - targets: ["192.168.0.216:9187"]
  8. labels:
  9. instance: hk-center.pg.rds.aliyuncs.com:5432
  10. group: postgreSql

8.4监控redis指标redis_exporter

第一步:下载安装redis_exporter

  1. //下载
  2. wget https://github.com/oliver006/redis_exporter/releases/download/v1.37.0/redis_exporter-v1.37.0.linux-386.tar.gz
  3. //解压
  4. tar -xf redis_exporter-v1.37.0.linux-386.tar.gz -C /usr/local/
  5. //改名
  6. mv redis_exporter-v1.37.0.linux-386 redis_exporter
  7. //启动
  8. ./redis_exporter -help //查看参数
  9. nohup ./redis_exporter -redis.addr 192.168.0.247:30279 & //无密码
  10. nohup ./redis_exporter -redis.addr 192.168.0.247:30279 -redis.password 123456 & //有密码
  11. //浏览器输入:http://192.168.0.215:9121/metrics

第二步:配置到prometheus

  1. - job_name: "redis"
  2. static_configs:
  3. - targets: ["192.168.0.215:9121"]
  4. labels:
  5. instance: 192.168.0.247:30279
  6. group: redis

9.监控站点

9.1blackbox_exporter应用场景

  1. HTTP 测试: 定义 Request Header 信息、判断 Http status / Http Respones Header / Http Body 内容
  2. TCP 测试: 业务组件端口状态监听、应用层协议定义与监听
  3. ICMP 测试: 主机探活机制
  4. POST 测试: 接口联通性
  5. SSL证书过期时间

9.2下载安装blackbox_exporter

  1. https://prometheus.io/download/

  1. //下载
  2. wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.20.0/blackbox_exporter-0.20.0.linux-amd64.tar.gz
  3. //解压
  4. tar -xf blackbox_exporter-0.20.0.linux-amd64.tar.gz -C /usr/local/
  5. //改名
  6. mv blackbox_exporter-0.20.0.linux-amd64 blackbox_exporter
  7. //启动
  8. nohup ./blackbox_exporter &
  9. //浏览器输入http://192.168.0.215:9115/

9.3网站监控-prometheus配置

vi /usr/local/prometheus/prometheus.yml

//重启prometheus

lsof -i:9090

kill -9 xxxx

nohup ./prometheus &

网站监控:

  1. - job_name: 'http_status'
  2. metrics_path: /probe
  3. params:
  4. module: [http_2xx]
  5. static_configs:
  6. - targets: ['https://admin.d.blueshark.com']
  7. labels:
  8. instance: admin.d.blueshark.com
  9. group: web
  10. - targets: ['https://admin.k.blueshark.com']
  11. labels:
  12. instance: admin.k.blueshark.com
  13. group: web
  14. relabel_configs:
  15. - source_labels: [__address__]
  16. target_label: __param_target
  17. - target_label: __address__
  18. replacement: 192.168.0.215:9115

9.4ping检测-prometheus配置

ping检测:

  1. - job_name: 'ping_status'
  2. metrics_path: /probe
  3. params:
  4. module: [icmp]
  5. static_configs:
  6. - targets: ['192.168.0.249']
  7. labels:
  8. instance: 'ping_status'
  9. group: 'icmp'
  10. relabel_configs:
  11. - source_labels: [__address__]
  12. target_label: __param_target
  13. - target_label: __address__
  14. replacement: 192.168.0.215:9115

9.5端口检测--prometheus配置

端口检测:

  1. - job_name: 'port_status'
  2. metrics_path: /probe
  3. params:
  4. module: [tcp_connect]
  5. static_configs:
  6. - targets: ['192.168.0.215:80', '192.168.0.216:80', '192.168.0.217:80']
  7. labels:
  8. instance: 'port_status'
  9. group: 'port'
  10. relabel_configs:
  11. - source_labels: [__address__]
  12. target_label: __param_target
  13. - target_label: __address__
  14. replacement: 192.168.0.215:9115

Prometheus监控实战应用的更多相关文章

  1. Prometheus监控实战day1-监控简介

    福利 Prometheus监控实战PDF电子书下载 链接:https://pan.baidu.com/s/1QH4Kvha5g70OhYQdp4YsfQ 提取码:oou5 若你喜欢该资料,请购买该资料 ...

  2. prometheus监控实战--基础

    1.简介 prometheus就是监控系统+TSDB(时间序列数据库),通过pull方式从exporter获取时间序列数据,存入本地TSDB,被监控端需安装exporter作为http端点暴露指标数据 ...

  3. Prometheus监控实战day2——监控主机和容器

    Prometheus使用exporter工具来暴露主机和应用程序上的指标,目前有很多exporter可供利用.对于收集各种主机指标数据(包括CPU.内存和磁盘),我们使用Node Exporter即可 ...

  4. prometheus监控实战

    第一节.环境和软件版本 1.1.操作系统环境 主机ip 操作系统 部署软件 备注 192.168.10.10 Centos7.9 Grafana.Pushgateway.Blackbox Export ...

  5. 监控实战Prometheus+Grafana

    这期的分享是监控实战,其实不想写这篇的,因为网上相关的文章也挺多的,但是出于光说不练都是假把式,而且也想告诉你:当帅气的普罗米修斯(Prometheus)遇到高颜值的格拉法纳(Grafana)究竟会擦 ...

  6. K8S(13)监控实战-部署prometheus

    k8s监控实战-部署prometheus 目录 k8s监控实战-部署prometheus 1 prometheus前言相关 1.1 Prometheus的特点 1.2 基本原理 1.2.1 原理说明 ...

  7. prometheus和granfana企业级监控实战v5

    文件地址:https://files.cnblogs.com/files/sanduzxcvbnm/prometheus和granfana企业级监控实战v5.pdf

  8. Docker 监控实战

    如今,越来越多的公司开始使用 Docker 了,现在来给大家看几组数据: 2 / 3 的公司在尝试了 Docker 后最终使用了它 也就是说 Docker 的转化率达到了 67%,而转化市场也控制在 ...

  9. Prometheus监控学习笔记之教程推荐

    最近学习K8S和基于容器的监控,发现了如下的教程质量不错,记录下来以备参考 1. K8S最佳实战(包括了K8S的Prometheus监控和EFK日志搜集) https://jimmysong.io/k ...

随机推荐

  1. springcloud断路器作用?

    当一个服务调用另一个服务由于网络原因或自身原因出现问题,调用者就会等待被调用者的响应 当更多的服务请求到这些资源导致更多的请求等待,发生连锁效应(雪崩效应)断路器有完全打开状态:一段时间内 达到一定的 ...

  2. Oracle入门基础(四)一一多行函数

    SQL> --工资总额 SQL> select sum(sal) from emp; SUM(SAL) 29025 SQL> --人数 SQL> select count(*) ...

  3. c++ 虚函数多态、纯虚函数、虚函数表指针、虚基类表指针详解

    静态多态.动态多态 静态多态:程序在编译阶段就可以确定调用哪个函数.这种情况叫做静态多态.比如重载,编译器根据传递给函数的参数和函数名决定具体要使用哪一个函数.动态多态:在运行期间才可以确定最终调用的 ...

  4. 论文阅读总结-Patient clustering improves efficiency of federated machine learning to predict mortality and hospital stay time using distributed electronic medical records

    一.论文提出的方法: 使用进入ICU前48h的用药特征作为预测因子预测重症监护患者的死亡率和ICU住院时间. 用到了联邦学习,自编码器,k-means聚类算法,社区检测. 数据集:从50家患者人数超过 ...

  5. PAT B1051 复数乘法

    输入样例: 2.3 3.5 5.2 0.4 输出样例: -8.68-8.23i 解题思路: 1.读入R1.P1.R2.P2. 2.A=(R1*R2)cos(P1+P2),B=(R1*R2)sin(P1 ...

  6. IDEA中 mybatis-config、applicationContext.xml、log4j.properties、SpringMVC等文件没有图标标识符号,不是一个xml文件

    1. 举例说明 mybatis-config.xml文件不显示图标,识别不出该xml文件 2. 解决办法 1)先点击 File -> Settings-,然后贴入下面代码 (2) 具体操作如下图 ...

  7. Node自动重启工具 nodemon

    为什么要使用 在编写调试Node.js项目,修改代码后,需要频繁的手动close掉,然后再重新启动,非常繁琐.现在,我们可以使用nodemon这个工具,它的作用是监听代码文件的变动,当代码改变之后,自 ...

  8. IDEA出现Error during artifact deployment. See server log for details.

    第一步查看配置 然后点击Web Application Exploded->from Module, 如果以上问题都不存在,则要检查lib下是否缺少相应的jar包,是否导入,是否jar包过多产生 ...

  9. xtrabackup备份和恢复数据脚本

    该脚本用于备份和恢复MySQL数据库. 总结xtrabackup备份的两个坑: 1.在恢复数据的过程中,如果中途出错,则数据将会被破坏,后续很难再恢复. 2.在恢复过程中,如果版本过低,在准备全量数据 ...

  10. Map的key是否可重复

    我们都知道Map的一大特性是key唯一不可重复,可是真的是这样的吗? 我们来试验一下: 运行结果: 我们可以看到在map里有两个同样的person作为key,打破了map的key不可重复的特性. 我们 ...