1.Prometheus的主要特征及概述

概述:

Prometheus(由go语言(golang)开发)是一套开源的监控&报警&时间序列数据库的组合。适合监控docker容器。因为kubernetes(俗称k8s)的流行带动了prometheus的发展。

时间序列数据特点:
1.性能好
2.存储成本低,高效的压缩算法,节省存储空间,有效降低IO。 Prometheus有着非常高效的时间序列数据存储方法,每个采样数据仅仅占用3.5byte左右空间,上百万条时间序列,30秒间隔,保留60天,大概花了200多G(来自官方数据)

特征:

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

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

3.下载安装启动Prometheus

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

4.web客户端操作

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

5.默认图像

6.目录解释

console_libraries目录:
consoles目录:
LICENSE问价:
NOTICE文件:
prometheus文件:默认启动的可执行文件
prometheus.yml配置文件:默认配置文件
promtool文件:

7.配置文件

vi prometheus.yml

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

8.监控指标

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

8.1.监控其他机器node_exporter

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

第一步:下载安装node_exporter

//下载
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/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
//启动
nohup /usr/local/node_exporter/node_exporter &
//浏览器输入,监控数据,端口9100
http://192.168.0.216:9100/metrics

第二步:配置到prometheus

vi /usr/local/prometheus/prometheus.yml

  - job_name: "node"
static_configs:
- targets: ["192.168.0.216:9100"]
labels:
instance: 192.168.0.216
group: node
- targets: ["192.168.0.247:9100"]
labels:
instance: 192.168.0.247
group: node
- targets: ["192.168.0.235:9100"]
labels:
instance: 192.168.0.235
group: node
- targets: ["192.168.0.236:9100"]
labels:
instance: 192.168.0.236
group: node //重启prometheus
lsof -i:9090
kill -9 xxxx
nohup ./prometheus &

查看:

8.2监控mysql指标mysqld_exporter

第一步:下载安装mysqld_exporter

端口:9104

//下载
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.14.0/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
//创建mysqld_exporter需要使用mysql的用户名和密码,文件需要手动创建
vi /usr/local/mysqld_exporter/my.cnf
[client]
host=192.168.0.215
user=root
password=123456
port=3306
//启动mysqld_exporter
nohup ./mysqld_exporter --config.my-cnf=./my.cnf &
//检查端口
lsof -i:9104

第二步:配置到prometheus

vi /usr/local/prometheus/prometheus.yml

- job_name: "sg-215-mysql"
static_configs:
- targets: ["192.168.0.215:9104"] //重启prometheus
lsof -i:9090
kill -9 xxxx
nohup ./prometheus &

查看:

8.3监控postgres指标postgres_exporter

第一步:下载安装postgres_exporter

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

第二步:配置到prometheus

- job_name: "postgreSql"
static_configs:
- targets: ["192.168.0.215:9187"]
labels:
instance: 192.168.0.247:32432
group: postgreSql
- targets: ["192.168.0.216:9187"]
labels:
instance: hk-center.pg.rds.aliyuncs.com:5432
group: postgreSql

8.4监控redis指标redis_exporter

第一步:下载安装redis_exporter

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

第二步:配置到prometheus

- job_name: "redis"
static_configs:
- targets: ["192.168.0.215:9121"]
labels:
instance: 192.168.0.247:30279
group: redis

9.监控站点

9.1blackbox_exporter应用场景

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

9.2下载安装blackbox_exporter

https://prometheus.io/download/

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

9.3网站监控-prometheus配置

vi /usr/local/prometheus/prometheus.yml

//重启prometheus

lsof -i:9090

kill -9 xxxx

nohup ./prometheus &

网站监控:

  - job_name: 'http_status'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: ['https://admin.d.blueshark.com']
labels:
instance: admin.d.blueshark.com
group: web
- targets: ['https://admin.k.blueshark.com']
labels:
instance: admin.k.blueshark.com
group: web
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 192.168.0.215:9115

9.4ping检测-prometheus配置

ping检测:

  - job_name: 'ping_status'
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets: ['192.168.0.249']
labels:
instance: 'ping_status'
group: 'icmp'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 192.168.0.215:9115

9.5端口检测--prometheus配置

端口检测:

  - job_name: 'port_status'
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets: ['192.168.0.215:80', '192.168.0.216:80', '192.168.0.217:80']
labels:
instance: 'port_status'
group: 'port'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
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. Mybatis框架基础入门(五)--输入映射和输出映射

    1.parameterType(输入类型) 1.1 传递简单类型 使用#{}占位符,或者${}进行sql拼接. <select id="caseCountByQueryCaseVo&q ...

  2. scrapy--使用案例

    1.scrapy框架 1.1 安装scrapy pip3 install wheel 下载twisted http://www.lfd.uci.edu/~gohlke/pythonlibs/#twis ...

  3. ctfhub web信息泄露备份文件下载(vim缓存 Ds-Store)

    Vim缓存 进入环境由于不懂得vim是什么借鉴大佬的博客 网页提示flag在index.php中我们按着这个思路去找 将文件保存下来因为是swp文件我们用kail进行打开 使用vim -r index ...

  4. (stm32f103学习总结)—USART串口通信

    一. USART简介 USART即通用同步异步收发器,它能够灵活地与外部设备进行全双工 数据交换,满足外部设备对工业标准 NRZ 异步串行数据格式的要求. UART即通用异步收发器,它是在USART基 ...

  5. web入门+书籍推荐

    如果你想建立一个自己的网站,你可以从网上搜到许多的教程:比如 wordpress gitpages 等等. 如果你想了解这个框架是怎么工作的,你可以了解以下下面的三个基本概念: 服务器, 数据库, 前 ...

  6. 2D骨骼动画工具DragonBones的使用教程

    怎样用更少的美术成本创造出更生动的动画效果?今天就为大家介绍一套开源的2D骨骼动画框架和工具--DragonBones,它包含了桌面骨骼动画制作工具DragonBonesPro和一套多语言版本的Dra ...

  7. Linux 0.11源码阅读笔记-总览

    Linux 0.11源码阅读笔记-总览 阅读源码的目的 加深对Linux操作系统的了解,了解Linux操作系统基本架构,熟悉进程管理.内存管理等主要模块知识. 通过阅读教复杂的代码,锻炼自己复杂项目代 ...

  8. activity-alias属性的使用

    activity-alias是Android里为了重复使用Activity而设计的.1. 含义和作用:         对于activity-alias标签,它有一个属性叫android:targen ...

  9. 世界各国 MCC 和 MNC 列表

    http://www.cnblogs.com/inteliot/archive/2012/08/22/2651666.html常见MCC:代码(MCC)    ISO 3166-1    国家202 ...

  10. DOCTYPE(⽂档类型) 的作⽤

    DOCTYPE是HTML5中一种标准通用标记语言的文档类型声明,它的目的是告诉浏览器(解析器)应该以什么样(html或xhtml)的文档类型定义来解析文档,不同的渲染模式会影响浏览器对 CSS 代码甚 ...