基于华为云欧拉操作系统(HCE OS)单节点容器化部署(Prometheus、node-exporter、Grafana)应用性能监控平台

news/2024/5/18 21:27:24 标签: 华为云, prometheus, grafana

写在前面


  • 博文内容为 华为云欧拉操作系统入门级开发者认证(HCCDA – Huawei Cloud EulerOS)实验笔记整理
  • 认证地址:https://edu.huaweicloud.com/certificationindex/developer/9bf91efb086a448ab4331a2f53a4d3a1
  • 内容涉及,HCE OS 容器化部署(Prometheus、node-exporter、Grafana)应用性能监控平台
  • 理解不足小伙伴帮忙指正

不必太纠结于当下,也不必太忧虑未来,当你经历过一些事情的时候,眼前的风景已经和从前不一样了。——村上春树


创建一个专用网络,这个网络一般是业务对应网络

[root@ecs-hce ]# docker network create oa-net
8858411315a892cd61bbe8b31411595dd8b013792fd05ab68806f3ca5572c3a7

部署 Prometheus

下载 Prometheus 镜像, 查看 Prometheus 镜像

[root@ecs-hce ~]# cd ~ && docker pull prom/prometheus
Using default tag: latest
latest: Pulling from prom/prometheus
9fa9226be034: Pull complete
1617e25568b2: Pull complete
0af4f5a1aba4: Pull complete
524450aac7ac: Pull complete
3427b0266353: Pull complete
87f5816afa35: Pull complete
fe81a20504a7: Pull complete
bfac845c5ca1: Pull complete
6c1aa870016a: Pull complete
6126ba6f9b4f: Pull complete
68d61c64cf66: Pull complete
5e5897603b11: Pull complete
Digest: sha256:beb5e30ffba08d9ae8a7961b9a2145fc8af6296ff2a4f463df7cd722fcbfc789
Status: Downloaded newer image for prom/prometheus:latest
[root@ecs-hce ~]# docker images|grep prometheus
prom/prometheus      latest              2a72b385beaf        3 weeks ago         250MB

启动 Prometheus 容器, 这里需要注意端口和网络

[root@ecs-hce ~]# docker run -id --name=prom --network=oa-net -p  9090:9090 prom/prometheus
b1f8fb907b6963e84df3e9ca1cb7e190d9089e582ebff20956c33321fcbd219c

验证 Prometheus,在浏览器输入 EIP:9090 访问 Prometheus

在这里插入图片描述

在这里插入图片描述

点击 Endpoint 下的链接,此时会发现页面无法访问,需要修改配置文件

[root@ecs-hce ~]# mkdir prometheus
[root@ecs-hce ~]# docker cp prom:/etc/prometheus/prometheus.yml ./prometheus
[root@ecs-hce ~]# vim prometheus/prometheus.yml

```yaml
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"]

修改 targets 对应的值为 eip:9090,并且保存退出

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: ["120.46.64.191:9090"]

停止 prom 容器,删除 prom 容器,重新启动 Prometheus 容器

[root@ecs-hce ~]# docker stop prom
prom
[root@ecs-hce ~]# docker rm prom
prom

需要注意 -v /root/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml,这里直接映射的文件

[root@ecs-hce ~]# docker run -id --name=prom --network=oa-net -p  9090:9090 -v /root/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  prom/prometheus
08905b1011feb7e98431f53e53eadf8f5bb1ce6d44eb0894fb13b9598efa4c1f
[root@ecs-hce ~]#

通过 EIP:9090 访问 Prometheus,并进入 Status 选项下 Targets 页面

在这里插入图片描述

部署 node-exporter

下载 node-exporter 镜像

[root@ecs-hce ~]# docker pull prom/node-exporter
Using default tag: latest
latest: Pulling from prom/node-exporter
2abcce694348: Pull complete
455fd88e5221: Pull complete
324153f2810a: Pull complete
Digest: sha256:4cb2b9019f1757be8482419002cb7afe028fdba35d47958829e4cfeaf6246d80
Status: Downloaded newer image for prom/node-exporter:latest

启动 node-exporter,注意网络和端口配置

[root@ecs-hce ~]# docker run -id --name=node-exporter --network=oa-net -p 9100:9100 prom/node-exporter
933a43e1cebbdc2192928c69b0e0f60faf84156601caed0548f08cafe979923d

修改 Prometheus 配置文件,重新启动 prometheus

[root@ecs-hce ~]# vim prometheus/prometheus.yml
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "node-exporter"
    static_configs:
      - targets: ["120.46.64.191:9100"]
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["120.46.64.191:9090"]
[root@ecs-hce ~]# docker restart prom
prom
[root@ecs-hce ~]#

通过 EIP:9090 访问 Prometheus,在 Status—Targets 页面下,可以看到新配置的 node-exporter 数据源。

在这里插入图片描述

部署 Grafana

下载 Grafana 镜像

[root@ecs-hce ~]# docker pull grafana/grafana
Using default tag: latest
latest: Pulling from grafana/grafana
96526aa774ef: Pull complete
c7ba78600384: Pull complete
c27e091f8ead: Pull complete
1d06c4d0ba22: Pull complete
183afb97c8c4: Pull complete
409b84eddcee: Pull complete
10a0006e04fc: Downloading [==========>                                        ]  11.79MB/53.8MB
24decdaaac3e: Download complete
10a0006e04fc: Pull complete
24decdaaac3e: Pull complete
e178ee908fb8: Pull complete
d42dc690a758: Pull complete
Digest: sha256:7567a7c70a3c1d75aeeedc968d1304174a16651e55a60d1fb132a05e1e63a054
Status: Downloaded newer image for grafana/grafana:latest
[root@ecs-hce ~]#
[root@ecs-hce ~]#
[root@ecs-hce ~]# docker images grafana/grafana
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
grafana/grafana     latest              2fec87cd4362        2 weeks ago         406MB

启动 Grafana 容器,注意这里的端口和网络,grafana 并不需要和上面的组件放到同一个网络里面

[root@ecs-hce ~]# docker run -d --name grafana -p 3000:3000 grafana/grafana
ab78373b51595e6de467d2e42f119309f9a301ff31e7ed89525334f7e0ed5e47
[root@ecs-hce ~]#

通过 EIP:3000 访问 Grafana,初始账号为 admin,密码为 admin

在这里插入图片描述

登录后,DATA SOURCE,增加数据源

在这里插入图片描述

到这里容器化部署Prometheus、node-exporter、Grafana就完成了,之后可以根据情况配置面板

© 文中涉及参考链接内容版权归原作者所有,如有侵权请告知 😃


https://edu.huaweicloud.com/certificationindex/developer/9bf91efb086a448ab4331a2f53a4d3a1


© 2018-2024 liruilonger@gmail.com, All rights reserved. 保持署名-非商用-相同方式共享(CC BY-NC-SA 4.0)


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

相关文章

使用Arcgis裁剪

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、掩膜提取二、随意裁剪三、裁剪 前言 因为从网站下载的是全球气候数据&#xff0c;而我们需要截取成中国部分&#xff0c;需要用到Arcgis的裁剪工具 一、掩…

C语言如何控制输出⻓度?

一、问题 什么是⻓度&#xff1f;如何控制⻓度&#xff1f; 二、解答 其实这⾥所说的⻓度表示输出数据占⽤的内存⻓度。通俗地说&#xff0c;就是输出指定类型的 数据。⽐如最为常⻅的%d&#xff0c;表示输出 int 型数据&#xff0c;但是要输出 long 类型的数据&#xff0c;那…

C++分支语句

个人主页&#xff1a;PingdiGuo_guo 收录专栏&#xff1a;C干货专栏 大家新年快乐&#xff0c;今天&#xff0c;我们来了解一下分支语句。 文章目录 1.什么是分支语句 1.if语句 基本形式 用法说明 练习 2.if-else语句 基本形式 用法说明 练习 3.switch语句 基本形式…

大数据 - Spark系列《五》- Spark常用算子

Spark系列文章&#xff1a; 大数据 - Spark系列《一》- 从Hadoop到Spark&#xff1a;大数据计算引擎的演进-CSDN博客 大数据 - Spark系列《二》- 关于Spark在Idea中的一些常用配置-CSDN博客 大数据 - Spark系列《三》- 加载各种数据源创建RDD-CSDN博客 大数据 - Spark系列《…

Git - 每次 git pull/push 时需要账号和密码解决方案

问题描述 在提交项目代码或者拉取代码的时候&#xff0c;每次 git 都要输入用户名密码&#xff0c;很烦~ 解决方案 让服务器记下来用户名和密码&#xff0c;此时输入一次&#xff0c;以后再 git push /pull 的时候就不用再输账号和密码了 # 配置 git 记录用户名和密码 git c…

【Git】Windows下通过Docker安装GitLab

私有仓库 前言基本思路拉取镜像创建挂载目录创建容器容器启动成功登录仓库设置中文更改密码人员审核配置邮箱 前言 由于某云存在人数限制&#xff0c;这个其实很好理解&#xff0c;毕竟使用的是云服务器&#xff0c;人家也是要交钱的。把代码完全放在别人的服务器上面&#xf…

Github 2024-02-08 开源项目日报 Top9

根据Github Trendings的统计&#xff0c;今日(2024-02-08统计)共有9个项目上榜。根据开发语言中项目的数量&#xff0c;汇总情况如下&#xff1a; 开发语言项目数量Ruby项目1HTML项目1Python项目1Scala项目1PLpgSQL项目1Rust项目1NASL项目1C项目1TypeScript项目1非开发语言项目…

问题:重热现象可使多级汽轮机的理想焓降增加,重热系数越大,多级汽轮机的内效率就越低。 #学习方法#微信#媒体

问题&#xff1a;重热现象可使多级汽轮机的理想焓降增加&#xff0c;重热系数越大&#xff0c;多级汽轮机的内效率就越低。 参考答案如图所示