Prometheus学习笔记——安装Prometheus Server

网友投稿 924 2022-11-13

Prometheus学习笔记——安装Prometheus Server

Prometheus学习笔记——安装Prometheus Server

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

从二进制包安装

对于非Docker用户,可以从Sevrer软件 包:

export VERSION=2.4.3 curl -LO amd64.tar.gz

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

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

解压后当前目录会包含默认的Prometheus配置文件promethes.yml:

# my global config 2. global: 3. scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5. # scrape_timeout is set to the global default (10s). 6.7. # Alertmanager configuration 8. alerting: 9. alertmanagers: 10. - static_configs: 11. - targets: 12. # - alertmanager:9093 13. 14. # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 15. rule_files: 16. # - "first_rules.yml" 17. # - "second_rules.yml" 18. 19. # A scrape configuration containing exactly one endpoint to scrape: 20. # Here it's Prometheus itself. 21. scrape_configs: 22. # The job name is added as a label `job=` to any timeseries scraped from this config. 23. - job_name: 'prometheus' 24. 25. # metrics_path defaults to '/metrics' 26. # scheme defaults to 'static_configs: 29. - targets: ['localhost:9090']

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

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

启动prometheus服务,其会默认加载当前路径下的prometheus.yaml文件:​​./prometheus​​ 正常的情况下,你可以看到以下输出内容:

1. level=info ts=2018-10-23T14:55:14.499484Z caller=main.go:554 msg="Starting TSDB ..."2. 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 3. level=info ts=2018-10-23T14:55:14.507999Z caller=main.go:564 msg="TSDB started" 4. level=info ts=2018-10-23T14:55:14.508068Z caller=main.go:624 msg="Loading configuration file" filename=prometheus.yml 5. level=info ts=2018-10-23T14:55:14.509509Z caller=main.go:650 msg="Completed loading of configuration file" filename=prometheus.yml6. 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​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:springboot2.0配置连接池(hikari、druid)的方法
下一篇:Prometheus学习笔记——启动
相关文章

 发表评论

暂时没有评论,来抢沙发吧~