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

news/2024/5/18 21:51:24 标签: 服务器, prometheus, grafana, 华为云

文章目录

    • 一、云耀云服务器介绍
    • 二、安装Prometheus
    • 创建prometheus.service配置文件
    • 启动prometheus服务
    • 查看prometheus服务进程
    • 三、安装node_exporter
    • 下载node_exporter组件包
    • 创建node_exporter.service配置文件
    • 启动node_exproter服务
    • 配置prometheus.yml文件
    • 访问Prometheus
    • 四、安装Grafana
    • 下载并安装Grafana
    • 访问Grafana
    • 五、参考链接

一、云耀云服务器介绍

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

prometheusservice_29">创建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_46">启动prometheus服务

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

image-20230917163515119

prometheus_54">查看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

prometheusyml_112">配置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']
./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
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

systemctl start grafana-server.service && systemctl enable grafana-server.service && systemctl status grafana-server.service
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


完结


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

相关文章

Lua顺序执行循环

1.一般赋值语句 local aa1; aa "HELLOW WORLD" aa {bb 1,[1] 2, }2.字符串的加减法(使用…而不是) local bb "hellow" bb bb .."world" print(bb) -- Lua没有简化表达式 --[[ temp 1 temp 3 temp ]] -- end3.if判断语句 local temp 2 if…

AJAX 技术学习笔记(基础)

Asynchronous JavaScript And XML 概念&#xff1a;异步的 JavaScript 和 XML 原生 AJAX 介绍 作用&#xff1a; 和服务器进行数据交换&#xff0c;利用HTML一起代替耦合的JSP动态页面完成异步交互 同步交互和异步交互&#xff1a; 同步交互&#xff1a;客户端向服务器端发…

链表的基本操作(acm模式,中等)

此题自己亲自动手实现难度确实不容易&#xff0c;为了更好的掌握 链表这一结构&#xff0c;还是得自己敲&#xff0c;自己debug,还得多次看&#xff0c;才能脑子清楚&#xff0c;手也熟。 // 本题的删除索引是从1开始&#xff0c;函数实现是从0开始&#xff0c;先说明这一点&a…

Python 使用raise引发异常

视频版教程 Python3零基础7天入门实战视频教程 当程序出现错误时&#xff0c;系统会自动引发异常。除此之外&#xff0c;Python也允许程序自行引发异常&#xff0c;自行引发异常使用raise语句来完成。 一般是业务逻辑上&#xff0c;业务异常问题&#xff0c;我们可以自行引发…

【系统架构】系统架构设计基础知识

导读&#xff1a;本文整理关于系统架构设计基础知识来构建系统架构知识体系。完整和扎实的系统架构知识体系是作为架构设计的理论支撑&#xff0c;基于大量项目实践经验基础上&#xff0c;不断加深理论体系的理解&#xff0c;从而能够创造新解决系统相关问题。 目录 1、软件架…

CLR via C#(三)垃圾回收

一、资源生命周期 每个程序运行都需要各种资源&#xff0c;如文件、内存缓冲区、数据库等。要使用这些资源&#xff0c;就必须为代表资源的类型分配内存。访问一个资源所需的步骤如下&#xff1a; 调用IL指令newobj&#xff0c;为代表资源的类型分配内存&#xff08;在C#中一…

多款大模型向公众开放,百模大战再升级?

作为一种使用大量文本数据训练的深度学习模型&#xff0c;大模型可以生成自然语言文本或理解语言文本的含义&#xff0c;是通向人工智能的一条重要途径。大模型可以应用于各种机器学习任务&#xff0c;包括自然语言处理、计算机视觉、语音识别、机器翻译、推荐系统、强化学习等…

利用Python将dataframe格式的所有列的数据类型转换为分类数据类型

一、样例理解 import pandas as pd import numpy as np# 创建测试数据 feature_names [col1 , col2, col3, col4, col5, col6] values np.random.randint(20, size(10,6))dataset pd.DataFrame(data values, columns feature_names)print("转换前的数据为\n",d…