二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

  • Nginx

  • Php

  • Zabbix

  • AWS

  • Prometheus

    • Prometheus安装部署及简单监控
      • 1,安装部署。
        • 1,环境准备。
        • 2,部署 Prometheus Server。
        • 1,下载安装包。
        • 2,安装 Prometheus。
        • 3,安装 node_exporter。
      • 2,配置 Prometheus 添加监控目标
    • Prometheus邮件报警配置
    • Prometheus配置Grafana Dashboard
    • Prometheus 监控之 Redis
    • Prometheus 监控之 MySQL
    • 从CPU的获取来学习理解Prometheus查询语句
    • Prometheus监控之kafka集群
    • Prometheus监控之elasticsearch集群
    • Prometheus关于with和by的作用及用法
    • 利用promwrite对prometheus进行remote-write写入
    • prometheus结合nginx-lua-prometheus监控openresty
  • Grafana

  • Loki

  • CentOS

  • Supervisord

  • Systemd

  • Docker

  • Docker-Compose

  • Rancher

  • Ansible

  • OpenLdap

  • GitLab

  • GitHub

  • Etcd

  • Consul

  • RabbitMQ

  • Kafka

  • Mysql

  • MongoDB

  • OpenVPN

  • Kvm

  • VMware

  • 配置文件详解

  • Other

  • 运维观止
  • Prometheus
二丫讲梵
2019-02-16
目录

Prometheus安装部署及简单监控

文章发布较早,内容可能过时,阅读注意甄别。

# 1,安装部署。

# 1,环境准备。

IP 地址 角色
192.168.111.3 Prometheus Server
192.168.111.4 node_exporter

版本:

  • 测试通过系统:CentOS Linux release 7.4.1708 (Core)
  • Prometheus:2.4.2.linux-amd64
  • Alertmanager:0.15.2.linux-amd64
  • node_exporter:0.16.0.linux-amd64

软件包下载地址:https://prometheus.io/download/

# 2,部署 Prometheus Server。

# 1,下载安装包。

$ cd /usr/local/src/
$ wget https://github.com/prometheus/prometheus/releases/download/v2.4.2/prometheus-2.4.2.linux-amd64.tar.gz
$ wget https://github.com/prometheus/alertmanager/releases/download/v0.15.2/alertmanager-0.15.2.linux-amd64.tar.gz
$ wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz
1
2
3
4

申明

原创文章eryajf,未经授权,严禁转载,侵权必究!此乃文中随机水印,敬请读者谅解。

Copyright 二丫讲梵 (opens new window) 版权所有

# 2,安装 Prometheus。

创建 prometheus 用户。

$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
1
2

解压安装包。

$ tar xf prometheus-2.4.2.linux-amd64.tar.gz -C /usr/local/
$ cd /usr/local/
$ mv prometheus-2.4.2.linux-amd64/ prometheus
1
2
3

创建启动脚本:

$ vim /usr/lib/systemd/system/prometheus.service

添加如下内容:

[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --storage.tsdb.retention=15d --log.level=info
Restart=on-failure
[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 3,安装 node_exporter。

在 Prometheus 节点和另一台节点上分别安装 node_exporter。

$ tar xf node_exporter-0.16.0.linux-amd64.tar.gz -C /usr/local/
$ cd /usr/local/
$ mv node_exporter-0.16.0.linux-amd64/ node_exporter
$ chown -R prometheus.prometheus node_exporter/
1
2
3
4

创建 node_exporter 启动脚本:

$ vim /usr/lib/systemd/system/node_exporter.service

添加如下内容:

[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target

[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

注意:node_exporter 的运行用户也是 prometheus 用户需要在每台节点上都创建该用户。

启动 node_exporter 服务:

$ systemctl enable node_exporter.service
$ systemctl start node_exporter.service
$ systemctl status node_exporter.service
$ ss -tnl | grep 9100
1
2
3
4

# 2,配置 Prometheus 添加监控目标

$ cd /usr/local/prometheus
$ vim prometheus.yml
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','localhost:9100'] # 对本机node_exporter 监控

# 新添加的对其它node节点抓取数据
  - job_name: '111.4'
    #重写了全局抓取间隔时间,由15秒重写成5秒。
    scrape_interval: 5s
    static_configs:
    - targets: ['192.168.111.4:9100']
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

启动 Prometheus 服务:

$ chown -R prometheus.prometheus prometheus/
$ systemctl enable prometheus.service
$ systemctl start prometheus.service
$ systemctl status prometheus.service
1
2
3
4

注意:要留意启动之前的目录权限更改,否则可能会在启动的时候报错Feb 11 16:08:41 localhost alertmanager: level=error ts=2019-02-11T08:08:41.419390133Z caller=main.go:179 msg="Unable to create data directory" err="mkdir data/: permission denied"。

访问 Prometheus WEB 查看我们定义的目标主机:http://192.168.111.3:9090/targets

image

微信 支付宝
#prometheus
上次更新: 2024/07/04, 22:40:37
AWS运维部署实践--EKS集群事件采集
Prometheus邮件报警配置

← AWS运维部署实践--EKS集群事件采集 Prometheus邮件报警配置→

最近更新
01
学习周刊-总第212期-2025年第21周
05-22
02
从赵心童世锦赛夺冠聊聊我的斯诺克情缘
05-16
03
学习周刊-总第211期-2025年第20周
05-15
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式