Prometheus 安装部署

Prometheus 安装部署

  • 安装版本:prometheus-2.6.1
  • 百度云下载:https://pan.baidu.com/s/1w16lQZKw8PCHqlRuSK2i7A
  • 提取码:lw1q

二进制安装部署

1、下载二进制包:prometheus-2.6.1.linux-amd64.tar.gz

2、解压包:tar xvzf prometheus-2.6.1.linux-amd64.tar.gz 

3、移动到安装目录:mv prometheus-2.6.1.linux-amd64 /usr/local/prometheus

4、进入目录:cd /usr/local/prometheus

5、修改配置文件底部监控本机: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: ['server02:9090']
复制代码

注:Prometheus从目标机上通过http方式拉取采样点数据, 它也可以拉取自身服务数据并监控自身的健康状况。

注:当然Prometheus服务拉取自身服务采样数据,并没有多大的用处,但是它是一个好的DEMO。

复制代码
global:
  # 默认情况下,每15s拉取一次目标采样点数据。
  scrape_interval:     15s 
  # 我们可以附加一些指定标签到采样点度量标签列表中, 用于和第三方系统进行通信, 包括:federation, remote storage, Alertmanager
  external_labels:
    # 下面就是拉取自身服务采样点数据配置
    monitor: 'codelab-monitor'
scrape_configs:
  # job名称会增加到拉取到的所有采样点上,同时还有一个instance目标服务的host:port标签也会增加到采样点上
  - job_name: 'prometheus'
    # 覆盖global的采样点,拉取时间间隔5s
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:9090']

配置文件注解
复制代码

6、启动服务

 nohup ./prometheus --config.file=prometheus.yml &
复制代码
# 指定配置文件
--config.file="prometheus.yml"
# 指定监听地址端口
--web.listen-address="0.0.0.0:9090" 
# 最大连接数
--web.max-connections=512
# tsdb数据存储的目录,默认当前data/
--storage.tsdb.path="data/"
# premetheus 存储数据的时间,默认保存15天
--storage.tsdb.retention=15d 

启动选项了解:./prometheus --help
复制代码

7、测试访问:http://localhost:9090

 

 8、查看暴露指标:http://localhost.com:9090/metrics

 

9、将Prometheus配置为系统服务

1、进入systemd目录下:cd /usr/lib/systemd/system

2、创建文件:vim prometheus.service

复制代码
[Unit]
  Description=https://prometheus.io
  
  [Service]
  Restart=on-failure
  ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml

  [Install]                      
  WantedBy=multi-user.target
复制代码

4、生效系统system文件

systemctl daemon-reload

5、启动服务

systemctl stop prometheus.service
systemctl start prometheus.service

Docker 容器安装部署

  • 官方地址:https://prometheus.io/docs/prometheus/latest/installation/

一、prometheus.yml通过运行以下命令将您从主机绑定:

docker run -p 9090:9090 -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml \
       prom/prometheus

二、或者为配置使用额外的卷:

docker run -p 9090:9090 -v /prometheus-data \
       prom/prometheus --config.file=/prometheus-data/prometheus.yml

注:普罗米修斯的配置文件的需要指定对。

 

posted @   星火撩原  阅读(98)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2020-03-03 进程间通信(1):简介
2020-03-03 IO操作和DMA、RDMA
2020-03-03 两个缓冲空间:kernel buffer和io
2020-03-03 OOM和Swap分区
2020-03-03 页翻译——快速地址转换
2020-03-03 分页和页表
2020-03-03 栈空间之用户栈和内核栈
点击右上角即可分享
微信分享提示