这里我下载的是 prometheus-2.6.1.linux-amd64.tar.gz,任何2.x.x版本的Prometheus都足以满足本章的要求。解压文件并进入目录
Copy $ wget https://github.com/prometheus/prometheus/releases/download/v2.6.1/prometheus-2.6.1.linux-amd64.tar.gz
$ tar -zxf prometheus-*.linux-amd64.tar.gz
$ cd prometheus-*.linux-amd64/
Copy global:
scrape_interval: 10s
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- localhost:9090
Copy ./promtool check config prometheus.yml
Checking prometheus.yml
SUCCESS: 0 rule files found
Copy $ ./prometheus
level=info ts=2019-01-22T07:35:15.200658518Z caller=main.go:243 msg="Starting Prometheus" version="(version=2.6.1, branch=HEAD, revision=b639fe140c1f71b2cbad3fc322b17efe60839e7e)"
level=info ts=2019-01-22T07:35:15.200745786Z caller=main.go:244 build_context="(go=go1.11.4, user=root@4c0e286fe2b3, date=20190115-19:12:04)"
level=info ts=2019-01-22T07:35:15.200787708Z caller=main.go:245 host_details="(Linux 4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018 x86_64 258c0505930c (none))"
level=info ts=2019-01-22T07:35:15.200858577Z caller=main.go:246 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2019-01-22T07:35:15.200886497Z caller=main.go:247 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2019-01-22T07:35:15.201740888Z caller=web.go:429 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2019-01-22T07:35:15.201672651Z caller=main.go:561 msg="Starting TSDB ..."
level=info ts=2019-01-22T07:35:15.215188095Z caller=main.go:571 msg="TSDB started"
level=info ts=2019-01-22T07:35:15.215264666Z caller=main.go:631 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2019-01-22T07:35:15.216085652Z caller=main.go:657 msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=2019-01-22T07:35:15.216168709Z caller=main.go:530 msg="Server is ready to receive web requests."
这是表达式浏览器,您可以从中运行PromQL查询。 UI中还有其他几个页面可帮助您了解Prometheus正在执行的操作,例如Status选项卡下的Targets页面
在此页面上,只有一个Prometheus服务器处于UP状态,这意味着最后一次刮擦(scrape)成功。 如果上次刮擦出现问题,则“ERROR”字段中会显示一条消息
您应该看到的另一个页面是Prometheus本身的度量信息(metrics),因为Prometheus本身也配备了Prometheus指标。 可以通过访问http://localhost:9090/metrics查看可用的度量标准,并且是人类可读的,如图