一、准备条件
Windows10
go1.15.1.windows-amd64
二、下载与安装
1、下载
Download | Prometheus,依据需求选择对应版本的包,此处选择 Windows
对应版本 amd64
2、解压文件
解压到目标安装目录,此处为D:\ProgramData\prometheus-2.23.0-rc
,解压之后,目录结构如下:
<DIR> consoles <DIR> console_libraries 11,357 LICENSE 3,420 NOTICE 89,340,928 prometheus.exe 926 prometheus.yml 79,250,432 promtool.exe
3、修改配置
解压路径中的配置文件为prometheus.yml
,系统默认的数据存储方式为文件形式,存储在与执行程序prometheus.exe
同目录下的data
文件夹中,可以通过指令--storage.tsdb.path="data/"
进行数据存储路径的设置。
# 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']
4、运行访问
在 cmd
中启动 prometheus.exe
,可看到如下输出:
level=info ts=2020-11-26T10:36:59.027Z caller=head.go:722 component=tsdb msg="WAL replay completed" checkpoint_replay_duration=0s wal_replay_duration=996.2µs total_replay_duration=1.9937ms level=info ts=2020-11-26T10:36:59.028Z caller=main.go:742 fs_type=unknown level=info ts=2020-11-26T10:36:59.028Z caller=main.go:745 msg="TSDB started" level=info ts=2020-11-26T10:36:59.028Z caller=main.go:871 msg="Loading configuration file" filename=prometheus.yml level=info ts=2020-11-26T10:36:59.040Z caller=main.go:902 msg="Completed loading of configuration file" filename=prometheus.yml totalDuration=11.9662ms remote_storage=0s web_handler=0s query_engine=0s scrape=10.969ms scrape_sd=0s notify=0s notify_sd=0s rules=0s level=info ts=2020-11-26T10:36:59.040Z caller=main.go:694 msg="Server is ready to receive web requests."
执行成功后访问http://localhost:9090/能够出现对应页面,则表示访问成功。