当前位置: 首页 > news >正文

襄阳网站设计制作公司宠物美容师宠物美容培训学校

襄阳网站设计制作公司,宠物美容师宠物美容培训学校,做代购起家的奢侈品特卖网站,网站建设岗位Prometheus(普罗米修斯) 是一种 新型监控告警工具,Kubernetes 的流行带动了 Prometheus 的应用。 全文参考自 prometheus 学习笔记(1)-mac 单机版环境搭建[1] Mac 上安装 Prometheus brew install prometheus 安装路径在 /usr/local/Cellar/prometheus/2.20.1, 配置文件在 /usr…

Prometheus(普罗米修斯) 是一种 新型监控告警工具,Kubernetes 的流行带动了 Prometheus 的应用。

全文参考自 prometheus 学习笔记(1)-mac 单机版环境搭建[1]



Mac 上安装 Prometheus


brew install prometheus

安装路径在 /usr/local/Cellar/prometheus/2.20.1,

配置文件在 /usr/local/etc/prometheus.yml:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
    - targets: ["localhost:9090"]

切换到安装目录的 bin 文件夹,

cd /usr/local/Cellar/prometheus/2.20.1/bin

执行:

./prometheus --config.file=/usr/local/etc/prometheus.yml

alt

此时可访问localhost:9090,有如下页面:

alt

Status中可以看到若干元信息.

alt



安装 grafana


brew install grafana

安装路径在 /usr/local/Cellar/grafana/7.1.5,

配置文件在 /usr/local/etc/grafana/grafana.ini,

可在此修改默认的端口等信息


启动:

grafana-server --config=/usr/local/etc/grafana/grafana.ini --homepath /usr/local/share/grafana --packaging=brew cfg:default.paths.logs=/usr/local/var/log/grafana cfg:default.paths.data=/usr/local/var/lib/grafana cfg:default.paths.plugins=/usr/local/var/lib/grafana/plugins

访问localhost:3000,有如下页面:

(默认的用户名/密码均为 admin,首次登陆必须修改密码)

alt

Grafana 是一个单纯的前端图表展示工具, 必须为其添加数据源,才能读取到数据进而进行展示, 参考下图:

alt

Grafana 支持非常多的数据源.

alt

选择Prometheus数据源, 指定 URL 地址, 然后保存即可

alt


安装 pushgateway


Prometheus 官网[2]搜索pushgateway, 下载 pushgateway-1.2.0.darwin-amd64.tar.gz[3]

本地解压,运行

./pushgateway

alt

此时, 在localhost:9091/页面Status这个 Tab 页,可见:

alt

pushgateway的作用:(图片来自网络)

alt

(图片来自煎鱼大佬的 Prometheus 快速入门[4])

alt

即 客户端(不管是通过代码, 还是直接终端敲命令行) 将数据 push 到网关(pushgateway), 然后 Prometheus 从网关 pull 数据



修改 Prometheus 的配置文件


vim /usr/local/etc/prometheus.yml

增加如下几行,重启 Prometheus,以让新的配置文件生效.

  - job_name: "push-metrics"
    static_configs:
    - targets: ["localhost:9091"]
    honor_labels: true

(Prometheus 提供了多种语言的 sdk, 最简单的方式是通过 shell)

推送一个指标:

echo "cui_metric 100" | curl --data-binary @- http://localhost:9091/metrics/job/dashen_blog

推送多个指标:

cat <<EOF | curl --data-binary @- http://localhost:9091/metrics/job/dashen_blog
blog_visit_total{blogid="12345",domain="dashen.tech",clientip="10.0.1.1"} 20
blog_visit_total{blogid="34567",domain="dashen.tech",clientip="10.0.1.2"} 30
blog_visit_total{blogid="56789",domain="dashen.tech",clientip="10.0.1.3"} 40
EOF

blog_visit_total 相当于指标名称,{ }中的内容相当于 tag,在查询时可根据 tag 进行过滤,最后的 20、30、40 相当于具体的指标值。

dashen_blog 是 job 名称, 可根据需要修改


此时http://localhost:9091上, 已能看到刚才 push 的数据:

alt

http://localhost:9090, Prometheus 里也能感知刚添加的数据

alt

Prometheus 本质上是一个时序数据库. curl 命令可以多执行几次, 相当于持续向时序数据库中写入数据.

alt


配置 Grafana


1.新建 Dashboard


alt

可在设置中进行相关修改

alt



2.添加图表

alt

(可以用 sum/max/min/avg 这类聚合函数统计指标)

alt
alt
alt



参考&进阶:

新型监控告警工具 prometheus(普罗米修斯)的入门使用[5]

Prometheus 快速入门[6]

Prometheus 四大度量指标的了解和应用[7]

使用 Prometheus 对 Go 程序进行指标采集[8]




Prometheus 推拉


Prometheus 是一个开源的监控系统,具有强大的查询语言和数据模型,用于收集和存储时间序列数据。Prometheus 通过 pull 模型从被监控的目标(如服务器、容器等)中获取数据,然后将其存储在本地数据库中。Prometheus 还提供了一种称为 pushgateway 的组件,用于允许被监控的目标通过 push 模型向 Prometheus 推送指标数据。

在 pull 模型中,Prometheus 通过 HTTP 协议从被监控的目标中拉取数据。被监控的目标必须运行一个称为 exporter 的组件,用于暴露指标数据的 HTTP 接口。Prometheus 定期通过该接口获取指标数据。

在 push 模型中,被监控的目标将指标数据推送到一个称为 pushgateway 的中间代理组件中。然后,Prometheus 定期从 pushgateway 中获取指标数据。推送数据的方式对于一些短暂存在的任务非常有用,比如批处理作业、临时性的任务等等,因为这些任务在 Prometheus 抓取数据之前就已经消失了,导致这些指标数据无法被 Prometheus 采集。




alt

5 分钟了解 Prometheus[9]

prometheus 架构[10]

Prometheus 核心组件[11]

[Prometheus 学习笔记(1)Prometheus 架构简介[12]]

参考资料

[1]

prometheus 学习笔记(1)-mac 单机版环境搭建: https://www.cnblogs.com/yjmyzz/p/how-to-install-prometheus-and-grafana.html

[2]

Prometheus 官网: https://prometheus.io/download/

[3]

pushgateway-1.2.0.darwin-amd64.tar.gz: https://github.com/prometheus/pushgateway/releases/download/v1.2.0/pushgateway-1.2.0.darwin-amd64.tar.gz

[4]

Prometheus 快速入门: https://eddycjy.com/posts/prometheus/2020-05-16-startup/

[5]

新型监控告警工具 prometheus(普罗米修斯)的入门使用: https://blog.csdn.net/lijiaocn/article/details/81865120

[6]

Prometheus 快速入门: https://eddycjy.com/posts/prometheus/2020-05-16-startup/

[7]

Prometheus 四大度量指标的了解和应用: https://eddycjy.com/posts/prometheus/2020-05-16-metrics/

[8]

使用 Prometheus 对 Go 程序进行指标采集: https://eddycjy.com/posts/prometheus/2020-05-16-pull/

[9]

5 分钟了解 Prometheus: https://blog.csdn.net/Dou_Hua_Hua/article/details/108535495

[10]

prometheus 架构: https://prometheus.kpingfan.com/01-introduction/01.prometheus%E6%9E%B6%E6%9E%84/

[11]

Prometheus 核心组件: https://yunlzheng.gitbook.io/prometheus-book/parti-prometheus-ji-chu/quickstart/prometheus-arch

[12]

[Prometheus 学习笔记(1)Prometheus 架构简介: https://www.cnblogs.com/linuxk/p/12017580.html

本文由 mdnice 多平台发布

http://www.tj-hxxt.cn/news/128017.html

相关文章:

  • 哪些网站做科技专题百度手机助手下载安卓版
  • 商城网站建设方案书徐州seo培训
  • 中企业网站建设最有效的推广学校的方式
  • 南京做网站的有哪些营销是什么
  • 大作业做网站网站友情链接有什么用
  • 武汉网站优化方案品牌软文案例
  • 永久免费补单系统关键词优化的五个步骤
  • 独立网站建设教程视频网络推广app
  • 西安网站 建设百度seo推广是什么
  • 青岛北京网站建设价格查询收录
  • 中国机械加工网站如何做seo搜索引擎优化
  • 做搜狐网站页面代运营靠谱吗
  • 我用帝国做的网站上传到别一个服务器上重新邦了一个域名购物链接
  • 中山市有做网站优化的吗怎样做网络销售平台
  • 图片搜集网站怎么做网站权重是怎么提升的
  • 找个靠谱网站做推广排名前十的大学
  • 在线设计的软件城关网站seo
  • 晋中建设局查合同网站热狗seo顾问
  • 义乌市微畅网络科技有限公司湖南关键词优化首选
  • 网站模板安装培训心得体会范文大全2000字
  • 做网站如何寻找客源厦门seo优化推广
  • seo服务公司上海湖南seo网站策划
  • 网络运营者对外提供产品和服务搜索引擎优化百度
  • aspnet网站开发实例项目百度竞价排名的使用方法
  • 生态建筑建设公司网站黄山seo排名优化技术
  • 网站怎么优化推广怎么优化网站关键词的方法
  • 佛山做网站建设竞价推广sem
  • 一起做网站17百度搜索量统计
  • 泉州网站建设工作室b站推广网站2024年不用下载
  • 外贸产品开发网站北京seo招聘网