原文:https://prometheus.io/docs/prometheus/latest/getting_started/
本指南是一种“ Hello World”风格的教程,它通过简单的设置示例展示了如何安装、配置和使用Prometheus。 您将在本地下载并运行Prometheus,对其进行配置以抓取自身和示例应用程序,然后使用查询、规则和绘图来利用收集的时间序列数据。
下载并运行Prometheus
为您的平台下载最新版本的Prometheus,然后解压缩并运行它:
tar xvfz prometheus-*.tar.gz
cd prometheus-*
在启动Prometheus之前,让我们对其进行配置。
配置Prometheus监控自身
Prometheus通过HTTP endpoints从被监控的目标上抓取指标来收集。 由于Prometheus还以相同的方式公开有关其自身的数据,因此它也可以抓取并监控其自身的健康状况。
虽然仅收集有关自身数据的Prometheus server在实践中不是很有用,但它是一个很好的入门示例。 将以下基本Prometheus配置保存为名为prometheus.yml的文件:
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# 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'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_inter