前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Prometheus部署

Prometheus部署

原创
作者头像
kevin_yyc
修改2021-04-14 17:56:38
6960
修改2021-04-14 17:56:38
举报
文章被收录于专栏:Kubernetes生态Kubernetes生态

一、环境准备

1、 防火墙配置

代码语言:txt
复制
这里做了防火墙关闭,或者可以在防火墙开启9100、9093端口
[root@Prometheus ~]# systemctl stop firewall
[root@Prometheus ~]# systemctl disable firewalld

2、selinux配置

代码语言:txt
复制
[root@Prometheus ~]# vim /etc/selinux/config
SELINUX=disabled
[root@Prometheus ~]# setenforce 0

3、更新yum

代码语言:txt
复制
[root@Prometheus ~]# yum update

二、Prometheus部署

1、下载安装包

下载链接:https://prometheus.io/download/

2、包解压

代码语言:txt
复制
tar xvfz prometheus-*.tar.gz

3、配置Prometheus监控

代码语言:txt
复制
cd prometheus-*
[root@Prometheus prometheus-2.26.0.linux-amd64]# vi 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:
      - 172.16.1.x:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "rules/*_rules.yml"
  - "rules/*_alerts.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: 'linux172.16.1.4x'
    static_configs:
    - targets: ['172.16.1.4x:9100']
      labels:
        instance: linux172.16.1.4x

4、部署node_exporter

下载地址:https://prometheus.io/download/

代码语言:txt
复制
下载上传安装包:node_exporter-1.1.2.linux-amd64.tar.gz
[root@qxxx prometheus]# tar -xzvf node_exporter-1.1.2.linux-amd64.tar.gz
$ 配置node开机自启动
[root@qxxx node_exporter-1.1.2.linux-amd64]# sudo groupadd -r prometheus
[root@qxxx node_exporter-1.1.2.linux-amd64]# sudo useradd -r -g prometheus -s /sbin/nologin -M -c "prometheus Daemons" prometheus
[root@qxxx node_exporter-1.1.2.linux-amd64]# cat << EOF > /usr/lib/systemd/system/node_exporter.service
[Service]
User=prometheus
Group=prometheus
ExecStart=/opt/prometheus/node_exporter-1.1.2.linux-amd64/node_exporter

[Install]
WantedBy=multi-user.target

[Unit]
Description=node_exporter
After=network.target 
EOF
$ 启动,查看状态,配置开机启动
systemctl start node_exporter
systemctl status node_exporter
systemctl enable node_exporter

5、Master节点编辑“prometheus.yml”增加“node_exporter”IP

代码语言:txt
复制
[root@Prometheus plugins]# vi prometheus.yml
  - job_name: 'linux172.16.1.4x'
    static_configs:
    - targets: ['172.16.1.4x:9100']
      labels:
        instance: 172.16.1.4x

6、热更新Prometheus.yml

代码语言:txt
复制
curl -XPOST http://localhost:9090/-/reload

7、Web访问Prometheus地址:localhost:9090/targets

image.png
image.png

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、环境准备
  • 二、Prometheus部署
相关产品与服务
前端性能监控
前端性能监控(Real User Monitoring,RUM)是一站式前端监控解决方案,专注于 Web、小程序等场景监控。前端性能监控聚焦用户页面性能(页面测速,接口测速,CDN 测速等)和质量(JS 错误,Ajax 错误等),并且联动腾讯云应用性能监控实现前后端一体化监控。用户只需要安装 SDK 到自己的项目中,通过简单配置化,即可实现对用户页面质量的全方位守护,真正做到低成本使用和无侵入监控。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档