Prometheus 是一个开源监控系统,可以用来监控各种服务和应用程序。以下是一个简单的 Prometheus 部署教程。

系统要求

  • 一台运行 Linux 的服务器
  • Docker 安装

步骤

  1. 安装 Docker

    首先,您需要在服务器上安装 Docker。可以通过以下命令安装:

    sudo apt-get update
    sudo apt-get install docker.io
    
  2. 拉取 Prometheus 镜像

    使用以下命令拉取 Prometheus 镜像:

    docker pull prom/prometheus
    
  3. 创建 Prometheus 配置文件

    创建一个名为 prometheus.yml 的配置文件,并添加以下内容:

    global:
      scrape_interval: 15s
    
    scrape_configs:
      - job_name: 'prometheus'
        static_configs:
          - targets: ['localhost:9090']
    

    这个配置文件会从本地的 Prometheus 实例中收集数据。

  4. 运行 Prometheus 容器

    使用以下命令运行 Prometheus 容器:

    docker run -d \
      --name prometheus \
      -p 9090:9090 \
      -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
      prom/prometheus
    
  5. 访问 Prometheus

    打开浏览器,访问 http://localhost:9090,您应该能看到 Prometheus 的 Web 界面。

扩展阅读

Prometheus Logo