Prometheus监控
  • 介绍
  • 全书组织
  • Part I - Prometheus基础
    • 第1章 天降奇兵
      • Prometheus简介
      • 初识Prometheus
        • 安装Prometheus Server
        • 使用Node Exporter采集主机数据
        • 使用PromQL查询监控数据
        • 监控数据可视化
      • 任务和实例
      • Prometheus核心组件
      • 小结
    • 第2章 探索PromQL
      • 理解时间序列
      • Metrics类型
      • 初识PromQL
      • PromQL操作符
      • PromQL聚合操作
      • PromQL内置函数
      • 在HTTP API中使用PromQL
      • 最佳实践:4个黄金指标和USE方法
      • 小结
    • 第3章 Prometheus告警处理
      • Prometheus告警简介
      • 自定义Prometheus告警规则
      • 部署AlertManager
      • Alertmanager配置概述
      • 基于标签的告警处理路由
      • 使用Receiver接收告警信息
        • 集成邮件系统
        • 集成Slack
        • 集成企业微信
        • 集成钉钉:基于Webhook的扩展
      • 告警模板详解
      • 屏蔽告警通知
      • 使用Recoding Rules优化性能
      • 小结
  • Part II - Prometheus进阶
    • 第4章 Exporter详解
      • Exporter是什么
      • 常用Exporter
        • 容器监控:cAdvisor
        • 监控MySQL运行状态:MySQLD Exporter
        • 网络探测:Blackbox Exporter
      • 使用Java自定义Exporter
        • 使用Client Java构建Exporter程序
        • 在应用中内置Prometheus支持
      • 小结
    • 第5章 数据与可视化
      • 使用Console Template
      • Grafana的基本概念
      • Grafana与数据可视化
        • 变化趋势:Graph面板
        • 分布统计:Heatmap面板
        • 当前状态:SingleStat面板
      • 模板化Dashboard
      • 小结
    • 第6章 集群与高可用
      • 本地存储
      • 远程存储
      • 联邦集群
      • Prometheus高可用
      • Alertmanager高可用
      • 小结
    • 第7章 Prometheus服务发现
      • Prometheus与服务发现
      • 基于文件的服务发现
      • 基于Consul的服务发现
      • 服务发现与Relabel
      • 小结
  • Part III - Prometheus实战
    • 第8章 监控Kubernetes
      • 初识Kubernetes
      • 部署Prometheus
      • Kubernetes下的服务发现
      • 监控Kubernetes集群
      • 基于Prometheus的弹性伸缩
      • 小结
    • 第9章 Prometheus Operator
      • 什么是Prometheus Operator
      • 使用Operator管理Prometheus
      • 使用Operator管理监控配置
      • 在Prometheus Operator中使用自定义配置
      • 小结
    • 参考资料
Powered by GitBook
On this page
  • 从二进制包安装
  • 使用容器安装

Was this helpful?

  1. Part I - Prometheus基础
  2. 第1章 天降奇兵
  3. 初识Prometheus

安装Prometheus Server

Previous初识PrometheusNext使用Node Exporter采集主机数据

Last updated 5 years ago

Was this helpful?

Prometheus基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖。用户只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prometheus Server。

从二进制包安装

对于非Docker用户,可以从找到最新版本的Prometheus Sevrer软件包:

export VERSION=2.4.3
curl -LO  https://github.com/prometheus/prometheus/releases/download/v$VERSION/prometheus-$VERSION.darwin-amd64.tar.gz

解压,并将Prometheus相关的命令,添加到系统环境变量路径即可:

tar -xzf prometheus-${VERSION}.darwin-amd64.tar.gz
cd prometheus-${VERSION}.darwin-amd64

解压后当前目录会包含默认的Prometheus配置文件promethes.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:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "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']

Promtheus作为一个时间序列数据库,其采集的数据会以文件的形似存储在本地中,默认的存储路径为data/,因此我们需要先手动创建该目录:

mkdir -p data

用户也可以通过参数--storage.tsdb.path="data/"修改本地数据存储的路径。

启动prometheus服务,其会默认加载当前路径下的prometheus.yaml文件:

./prometheus

正常的情况下,你可以看到以下输出内容:

level=info ts=2018-10-23T14:55:14.499484Z caller=main.go:554 msg="Starting TSDB ..."
level=info ts=2018-10-23T14:55:14.499531Z caller=web.go:397 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2018-10-23T14:55:14.507999Z caller=main.go:564 msg="TSDB started"
level=info ts=2018-10-23T14:55:14.508068Z caller=main.go:624 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2018-10-23T14:55:14.509509Z caller=main.go:650 msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=2018-10-23T14:55:14.509537Z caller=main.go:523 msg="Server is ready to receive web requests."

使用容器安装

对于Docker用户,直接使用Prometheus的镜像即可启动Prometheus Server:

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

启动完成后,可以通过访问Prometheus的UI界面:

https://prometheus.io/download/
http://localhost:9090
Prometheus UI