当前位置:首页 >> 技术栈专业化分层 >> 【Prometheus】Prometheus+Grafana部署,6199

【Prometheus】Prometheus+Grafana部署,6199

cpugpu芯片开发光刻机 技术栈专业化分层 2
文件名:【Prometheus】Prometheus+Grafana部署,6199 【Prometheus】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#运行prometheusdocker 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>&1nohup ./node_exporter --web.listen-address=":9100" > /dev/null 2>&1 &

增加监控信息

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

# my global configglobal: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 configurationalerting: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/grafanadocker 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

协助本站SEO优化一下,谢谢!
关键词不能为空
同类推荐
«    2025年12月    »
1234567
891011121314
15161718192021
22232425262728
293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接