【Prometheus】Prometheus+Grafana部署

news/2024/5/18 23:24:05 标签: prometheus, grafana

Prometheus

概述

官网https://prometheus.io/docs/introduction/overview/

Prometheus 是一款基于时序数据库的开源监控告警系统,非常适合Kubernetes集群的监控。Prometheus的基本原理是通过HTTP协议周期性抓取被监控组件的状态,任意组件只要提供对应的HTTP接口就可以接入监控。不需要任何SDK或者其他的集成过程。这样做非常适合做虚拟化环境监控系统,比如VM、Docker、Kubernetes等。输出被监控组件信息的HTTP接口被叫做exporter 。目前互联网公司常用的组件大部分都有exporter可以直接使用,比如Varnish、Haproxy、Nginx、MySQL、Linux系统信息(包括磁盘、内存、CPU、网络等等)。Promethus有以下特点:

  • 支持多维数据模型:由度量名和键值对组成的时间序列数据
  • 内置时间序列数据库TSDB
  • 支持PromQL查询语言,可以完成非常复杂的查询和分析,对图表展示和告警非常有意义
  • 支持HTTP的Pull方式采集时间序列数据
  • 支持PushGateway采集瞬时任务的数据
  • 支持服务发现和静态配置两种方式发现目标
  • 支持接入Grafana

部署

Docker方式

部署Prometheus

#下载配置文件
https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus.yml

#运行prometheus
docker run --name myPrometheus \
-d -p 9090:9090 \
-v /root/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus

测试访问
在这里插入图片描述

#若提示图中Warning内容
#更新一下服务器的时间
ntpdate ntp.aliyun.com

在这里插入图片描述

监控计算机资源信息-部署node_exporter

#下载符合操作系统的tar包,我这里是arm版本的虚拟机
https://github.com/prometheus/node_exporter/releases
#解压
tar zxvf node_exporter-0.18.0.linux-arm64.tar.gz 
#前台方式启动,默认9100端口
./node_exporter

#后台方式启动,使用nohup命令
# 忽略输入并把输出追加到“nohup.out“ 增加 > /dev/null 2>&1
nohup ./node_exporter --web.listen-address=":9100" > /dev/null 2>&1 &

在这里插入图片描述
在这里插入图片描述

增加监控信息

编辑prometheus.yml,增加监控宿主机myCentOS

# 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: "myCentOS"
    static_configs:
      - targets: ["10.211.55.88:9100"]    

重启prometheus容器
在这里插入图片描述

Linux

。。。

k8s

。。。

Grafana

概述

官网https://grafana.com/docs/grafana/latest/introduction/

Grafana 开源软件使您能够查询、可视化、警报和探索存储在任何位置的指标、日志和跟踪。Grafana OSS 为您提供了将时间序列数据库 (TSDB) 数据转换为富有洞察力的图形和可视化的工具。Grafana OSS 插件框架还使您能够连接其他数据源(例如 NoSQL/SQL 数据库)、票务工具(例如 Jira 或 ServiceNow)以及 CI/CD 工具(例如 GitLab)。

部署

Docker方式

docker pull grafana/grafana

docker run --name myGrafana \
-d -p 3000:3000 \
grafana/grafana

测试访问,默认账号密码admin
在这里插入图片描述

配置数据源

在这里插入图片描述
选择普罗米修斯
在这里插入图片描述
设置name url,保存即可
在这里插入图片描述
在这里插入图片描述

配置dashboard

直接使用官网模版
https://grafana.com/grafana/dashboards

搜索node
在这里插入图片描述
copy id

点加号,选择import,粘贴ID->load
选择数据源
在这里插入图片描述
在查询这里选择要查看的监控job
在这里插入图片描述
效果如下,我的虚拟机监控信息
在这里插入图片描述

Linux

。。。

k8s

。。。

前人栽树

https://blog.csdn.net/liu_chen_yang/article/details/131049402
https://zhuanlan.zhihu.com/p/344743604
https://zhuanlan.zhihu.com/p/267966193


http://www.niftyadmin.cn/n/5026339.html

相关文章

uni-app 新增 微信小程序之新版隐私协议

一、manifest.json中配置 "__usePrivacyCheck__": true 二、编写封装后的组件 <template><view class"privacy" v-if"showPrivacy"><view class"content"><view class"title">隐私保护指引</…

word文档怎么转换成pdf?几个实用文档转换方法

word文档怎么转换成pdf&#xff1f;PDF文档可以保护文档的格式和布局。如果你将Word文档发送给他人&#xff0c;他人可能会使用不同版本的Word软件打开文档&#xff0c;导致格式和布局发生变化。但是&#xff0c;如果你将Word文档转换为PDF文档&#xff0c;无论对方使用什么软件…

LabVIEW使用巴特沃兹低通滤波器过滤噪声

LabVIEW使用巴特沃兹低通滤波器过滤噪声 设备采集到的数据往往都有噪声&#xff0c;有时候这些数据要做判断使用&#xff0c;如果不处理往往会影响最终的结果。可以使用动态平滑&#xff0c;或者中值滤波等方法。这里介绍使用巴特沃斯低通滤波&#xff0c;也是非常方便的。 下…

Python 环境搭建,集成开发环境IDE: PyCharm

Python 环境搭建,集成开发环境IDE: PyCharm 一、Python 环境搭建二、Python下载三、Python安装四、环境变量配置五、Python 环境变量六、运行Python1、交互式解释器&#xff1a;2、命令行脚本3、集成开发环境&#xff08;IDE&#xff1a;Integrated Development Environment&am…

力扣106 补9.11

106.从中序与后序遍历序列构造二叉树 做不出来&#xff0c;这题能用哈希有个条件就是&#xff0c;每个节点的值都不一样。 先根据后序遍历找到根结点&#xff0c;在根据根结点的数组下标&#xff0c;把中序遍历序列分成2部分&#xff0c;就这样递归不断地分&#xff0c;直到左…

Flutter 挖孔屏的状态栏占用问题怎么解决,横屏后去掉了状态栏,还是会有一块黑色的竖条

使用下方代码后依旧有一条黑色的区域 overridevoid initState() {// TODO: implement initStatesuper.initState();///关闭状态栏&#xff0c;与底部虚拟操作按钮SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);//隐藏状态栏&#xff0c;底部按钮栏S…

CentOS 搭建k8s

目录 1.下载CentOS ISO镜像 (一) https://preparedata.blog.csdn.net/article/details/132878013 2.Hyper-V 安装 CentOS (二) https://preparedata.blog.csdn.net/article/details/132878766 附录&#xff1a;

小剧场短剧影视小程序源码分享,搭建自己的短剧小程序

拥有一个属于自己的短剧小程序&#xff0c;是现代人追求创作梦想和与观众互动的新方式。近年来&#xff0c;小剧场短剧影视小程序的兴起为广大创作者提供了展示才华和与观众互动的平台。如果你也渴望搭建一个自己的短剧小程序&#xff0c;那么你来对地方了&#xff01;在本文中…