华为云云耀云服务器L实例评测|基于L实例安装Prometheus+Grafana插件实现数据可视化监控

2023-09-17 17:53:13

一、云耀云服务器介绍

  • 云耀云服务器的优势

image-20230917173441654

  • 多种产品规格,满足广大开发者的需求

image-20230917173558920

  • 拥有丰富的应用场景,和简洁的部署方式

image-20230917175551872

二、安装Prometheus

# 下载
[root@hcss-ecs-2d95 ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz

# 解压
[root@hcss-ecs-2d95 ~]# tar -zxvf prometheus-2.45.0.linux-amd64.tar.gz -C /usr/local/

# 更名
cd /usr/local/  &&  mv prometheus-2.45.0.linux-amd64 prometheus  &&  cd prometheus

创建prometheus.service配置文件

[root@hcss-ecs-2d95 ~]# cat > /usr/lib/systemd/system/prometheus.service << EOF
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus --storage.tsdb.retention=15d --log.level=info            
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF

启动prometheus服务

[root@hcss-ecs-2d95 ~]# systemctl daemon-reload && systemctl start prometheus && systemctl enable prometheus && systemctl status prometheus

image-20230917163515119

查看prometheus服务进程

[root@hcss-ecs-2d95 ~]# netstat -lntp | grep prometheus
[root@hcss-ecs-2d95 prometheus]# netstat -lntp | grep prometheus
tcp6       0      0 :::9090                 :::*                    LISTEN      30237/prometheus

三、安装node_exporter

下载node_exporter组件包

# 下载
[root@hcss-ecs-2d95 ~]# wget https://github.com/prometheus/node_exporter/releases/download/v1.6.1/node_exporter-1.6.1.linux-amd64.tar.gz

# 解压
[root@hcss-ecs-2d95 ~]# tar -zxvf node_exporter-1.6.1.linux-amd64.tar.gz -C /usr/local/

# 更名
[root@hcss-ecs-2d95 ~]# cd /usr/local && mv node_exporter-1.6.1.linux-amd64 node_exporter && cd node_exporter

创建node_exporter.service配置文件

[root@hcss-ecs-2d95 ~]# cat > /usr/lib/systemd/system/node_exporter.service << EOF
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

启动node_exproter服务

[root@hcss-ecs-2d95 ~]# systemctl daemon-reload && systemctl start node_exporter && systemctl enable node_exporter && systemctl status node_exporter

image-20230917164037321

配置prometheus.yml文件

  • 修改Prometheus.yml
[root@hcss-ecs-2d95 ~]# cat prometheus.yml
# 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:
       - 127.0.0.1:9093
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "rules/*.yml"
# - "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']  # 如果对本机node_exporter监控,加入,'localhost:9100'
  
  - job_name: '云耀云服务器监控'
  #重写了全局抓取间隔时间,由15秒重写成5秒。
    scrape_interval: 5s
    static_configs:
    - targets: ['121.37.153.196:9100']
  • 检验prometheus.yml配置是否有效
./promtool check config prometheus.yml

输出内容如下:

[root@hcss-ecs-2d95 prometheus]# ./promtool check config prometheus.yml
Checking prometheus.yml
 SUCCESS: prometheus.yml is valid prometheus config file syntax
  • 重启prometheus服务
systemctl daemon-reload && systemctl restart prometheus && systemctl status prometheus
  • 重启node_exporter服务
systemctl daemon-reload && systemctl restart prometheus && systemctl status prometheus

访问Prometheus

  • http://IP地址:9090/targets

注意:访问相应的服务时,需要找到对应的云主机,在安全组内开启相应的端口,允许放行。

image-20230917171823841


四、安装Grafana

下载并安装Grafana

# 下载
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-10.0.0-1.x86_64.rpm

# 安装
yum install -y grafana-enterprise-10.0.0-1.x86_64.rpm

image-20230917165959756

  • 启动grafana服务
systemctl start grafana-server.service && systemctl enable grafana-server.service && systemctl status grafana-server.service
  • 查看grafana进程
netstat -lntp | grep grafana

访问Grafana

  • 访问Grafana网页,即访问http://BastionIP地址:3000。注意:需要开启对应云主机安全组内的端口,允许放行此端口,才可以访问。
  • 输入用户名和密码(初始密码:admin)

image-20230917170221266

  • 修改新密码

image-20230917170301674

  • 添加数据源Prometheus

image-20230917170715689

  • 导入仪表盘

image-20230917171213144

  • 输入仪表盘编号

image-20230917171247603

  • 选择数据源,点击import

image-20230917171411245

  • Grafana可视化数据展示完成。

image-20230917172539581

image-20230917174652833

本实验基于华为云云耀云服务器,采用Prometheus+Grafana的安装部署方式实现对Linux系统主机的统一监控,Prometheus自带有监控功能,但不能简洁直观的反映出被监控端的详细信息。这时,采用grafana中提供的丰富的Dashboard页面,简洁直观的显示系统的各个参数的详细情况,给人焕然一新的感觉,便于维护管理。

五、参考链接

🔴https://grafana.com/

🟡https://github.com/prometheus/node_exporter/releases

🟢https://prometheus.io/

🔵https://www.huaweicloud.com/product/hecs-light.html


完结

更多推荐

树莓派4b装系统到运行 Blazor Linux 本地程序全记录

在Linux下运行gui程序,咱也是第一次做,属于是瞎子过河乱摸一通,写得有什么不对和可以优化的地方,希望各位看官斧正斧正.##1.下载烧录器https://www.raspberrypi.com/software/####我选择的是Raspbian64位系统,并配置好ssh账号密码,wifi,以便启动后可以直接黑屏s

贪心算法(Greedy Algorithm)

贪心算法(GreedyAlgorithm)是一种解决优化问题的算法策略。在贪心算法中,每一步都会选择当前情况下最优的选择,而不考虑未来的后果。贪心算法的基本思想是通过局部最优选择达到全局最优。它并不保证一定能得到全局最优解,但在某些情况下可以得到近似最优解或者符合要求的解。贪心算法的适用条件是问题具有"最优子结构"和"

Web自动化测试进阶 —— Selenium模拟鼠标操作

鼠标操作事件在实际的web产品测试中,对于鼠标的操作,不单单只有click(),有时候还要用到右击、双击、拖动等操作,这些操作包含在ActionChains类中。ActionChains类中鼠标操作常用方法:首先导入ActionChains类:fromselenium.webdriver.common.action_c

2023年9月21日,历史上的今天大事件早读

​公元前19年9月21日古罗马诗人维吉尔逝世1069年9月21日宋神宗采用王安石新法,开始实行青苗法1643年9月21日皇太极逝世1898年9月21日慈禧太后发动戊戌政变1909年9月21日我国飞机设计师冯如第一次试飞成功1920年9月21日民主革命家朱执信遇难1926年9月21日荷兰物理学家昂内斯首次发现物理超导性1

分布式/微服务---第五篇

系列文章目录文章目录系列文章目录一、简述ZAB协议二、zk的数据模型和节点类型一、简述ZAB协议ZAB协议是为分布式协调服务Zookeeper专门设计的一种支持崩溃恢复的原子广播协议,实现分布式数据一致性所有客户端的请求都是写入到Leader进程中,然后,由Leader同步到其他节点,称为Follower。在集群数据同

Python中的POST请求参数

一、什么是POST请求参数在HTTP协议中,GET和POST是两种常用的请求方法。GET请求通过URL参数将请求数据传递给服务器,而POST请求则通过请求体中的参数传递数据。POST请求通常用于提交表单、上传文件等操作。POST请求参数就是请求体中的参数。在Python中,我们可以使用第三方库如requests来发送P

利用fiddler正向代理前端请求到本地后端

前景:在实际开发测试环境中,(前后端均已上线到测试服务器或前端以上线而后端还在开发中)。在测试过程中(前端页面点击,功能测试)发现了bug或异常点。正常排查问题可能是先利用浏览器检查工具查看接口的返回参数是否正常,如果异常那就得用(pycharm/vscode)启动服务再通过(postman/apifox)模拟前端请求

群晖管家+内网穿透实现公网远程访问本地黑群晖

白嫖怪狂喜!黑群晖也能使用群晖管家啦!文章目录白嫖怪狂喜!黑群晖也能使用群晖管家啦!1.使用环境要求:2.下载安装群晖管家app3.随机地址登陆群晖管家app4.固定地址登陆群晖管家app自己组装nas的白嫖怪们虽然也可以通过在局域网使用黑群晖,但是群晖quickconnect需要绑定正版群晖账号,那么白嫖怪们要怎样在

Nmap安装和使用详解

Nmap安装和使用详解Nmap概述功能概述运行方式Nmap安装官方文档参考:Nmap参数详解目标说明主机发现端口扫描Nmap将目标主机端口分成6种状态:Nmap产生结果是基于机器的响应报文,而这些主机可能是不可信任的,会产生一些迷惑或者误导Nmap的报文端口说明和扫描顺序服务与版本探测参数含义:脚本扫描操作系统探测时间

【Flutter】built_value 解决 Flutter 中的不可变性问题

文章目录一、前言二、什么是built_value?三、为什么我们需要built_value?四、如何在Flutter中安装和设置built_value?五、如何使用built_value创建不可变的值类型?六、如何使用built_value创建枚举类?七、如何使用built_value进行JSON序列化?八、版本信息九

解决2K/4K高分屏下Vmware等虚拟机下Kail Linux界面显示问题

问题现象在我们日常使用VirtualBox、Vmwareworkstation、Hyper-V等虚拟机安装使用Kali系统,在2K/4K高分辨率电脑下Kali系统界面显示太小,包括各种软件及命令终端字体均无法很直观的看出,影响我们的正常测试及使用。常规处理思路很多人会通过调整我们笔记本或台式机的系统屏幕分辨率设置,或者

热文推荐