Prometheus安装

直接安装:

root@localhost ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.20.0/prometheus-2.20.0.linux-amd64.tar.gz
--2020-09-09 22:18:52--  https://github.com/prometheus/prometheus/releases/download/v2.20.0/prometheus-2.20.0.linux-amd64.tar.gz
正在解析主机 github.com (github.com)... 13.114.40.48
正在连接 github.com (github.com)|13.114.40.48|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://github-production-release-asset-2e65be.s3.amazonaws.com/6838921/383ec100-cc78-11ea-95ea-572a29456c2a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200909%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200909T141852Z&X-Amz-Expires=300&X-Amz-Signature=9c8e035b9602248ebc07f4042b7466f12cc0ce71121f655b29ce7716ec7cdbb4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.20.0.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [跟随至新的 URL]
--2020-09-09 22:18:52--  https://github-production-release-asset-2e65be.s3.amazonaws.com/6838921/383ec100-cc78-11ea-95ea-572a29456c2a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200909%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200909T141852Z&X-Amz-Expires=300&X-Amz-Signature=9c8e035b9602248ebc07f4042b7466f12cc0ce71121f655b29ce7716ec7cdbb4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.20.0.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
正在解析主机 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.147.51
正在连接 github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.147.51|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:65312139 (62M) [application/octet-stream]
正在保存至: “prometheus-2.20.0.linux-amd64.tar.gz”

100%[=========================================================================================================>] 65,312,139  10.5MB/s 用时 7.4s

2020-09-09 22:19:01 (8.45 MB/s) - 已保存 “prometheus-2.20.0.linux-amd64.tar.gz” [65312139/65312139])

[root@localhost ~]# ll
总用量 63788
-rw-------. 1 root root     1242 7月  19 22:40 anaconda-ks.cfg
-rw-r--r--. 1 root root 65312139 7月  23 05:05 prometheus-2.20.0.linux-amd64.tar.gz
[root@localhost ~]# tar -zvxf prometheus-2.20.0.linux-amd64.tar.gz
prometheus-2.20.0.linux-amd64/
prometheus-2.20.0.linux-amd64/consoles/
prometheus-2.20.0.linux-amd64/consoles/node.html
prometheus-2.20.0.linux-amd64/consoles/node-overview.html
prometheus-2.20.0.linux-amd64/consoles/node-cpu.html
prometheus-2.20.0.linux-amd64/consoles/node-disk.html
prometheus-2.20.0.linux-amd64/consoles/prometheus.html
prometheus-2.20.0.linux-amd64/consoles/index.html.example
prometheus-2.20.0.linux-amd64/consoles/prometheus-overview.html
prometheus-2.20.0.linux-amd64/tsdb
prometheus-2.20.0.linux-amd64/console_libraries/
prometheus-2.20.0.linux-amd64/console_libraries/menu.lib
prometheus-2.20.0.linux-amd64/console_libraries/prom.lib
prometheus-2.20.0.linux-amd64/prometheus.yml
prometheus-2.20.0.linux-amd64/NOTICE
prometheus-2.20.0.linux-amd64/promtool
prometheus-2.20.0.linux-amd64/LICENSE
prometheus-2.20.0.linux-amd64/prometheus
[root@localhost ~]# ll
总用量 63788
-rw-------. 1 root root     1242 7月  19 22:40 anaconda-ks.cfg
drwxr-xr-x. 4 3434 3434      144 7月  23 05:03 prometheus-2.20.0.linux-amd64
-rw-r--r--. 1 root root 65312139 7月  23 05:05 prometheus-2.20.0.linux-amd64.tar.gz
[root@localhost ~]# cd prometheus-2.20.0.linux-amd64
[root@localhost prometheus-2.20.0.linux-amd64]# ll
总用量 153584
drwxr-xr-x. 2 3434 3434       38 7月  23 05:00 console_libraries
drwxr-xr-x. 2 3434 3434      173 7月  23 05:00 consoles
-rw-r--r--. 1 3434 3434    11357 7月  23 05:00 LICENSE
-rw-r--r--. 1 3434 3434     3420 7月  23 05:00 NOTICE
-rwxr-xr-x. 1 3434 3434 90933367 7月  23 02:53 prometheus
-rw-r--r--. 1 3434 3434      926 7月  23 05:00 prometheus.yml
-rwxr-xr-x. 1 3434 3434 51151585 7月  23 02:55 promtool
-rwxr-xr-x. 1 3434 3434 15159115 7月  23 02:56 tsdb
[root@localhost prometheus-2.20.0.linux-amd64]# cp prometheus promtool /usr/local/bin/
[root@localhost prometheus-2.20.0.linux-amd64]# prometheus --version
prometheus, version 2.20.0 (branch: HEAD, revision: e5a06b483527d4fe0704b8fa3a2b475b661c526f)
  build user:       root@ac954b6d5c6e
  build date:       20200722-18:51:45
  go version:       go1.14.6
[root@localhost prometheus-2.20.0.linux-amd64]# mkdir -p /etc/prometheus
[root@localhost prometheus-2.20.0.linux-amd64]# cp prom
prometheus      prometheus.yml  promtool
[root@localhost prometheus-2.20.0.linux-amd64]# cp prometheus.yml /etc/prometheus/
[root@localhost prometheus-2.20.0.linux-amd64]# promtool check config /etc/prometheus/prometheus.yml
Checking /etc/prometheus/prometheus.yml
  SUCCESS: 0 rule files found

[root@localhost prometheus-2.20.0.linux-amd64]# prometheus --config.file "/etc/prometheus/prometheus.yml"
level=info ts=2020-09-09T14:29:26.236Z caller=main.go:308 msg="No time or size retention was set so using the default time retention" duration=15d
level=info ts=2020-09-09T14:29:26.236Z caller=main.go:343 msg="Starting Prometheus" version="(version=2.20.0, branch=HEAD, revision=e5a06b483527d4fe0704b8fa3a2b475b661c526f)"
level=info ts=2020-09-09T14:29:26.236Z caller=main.go:344 build_context="(go=go1.14.6, user=root@ac954b6d5c6e, date=20200722-18:51:45)"

docker安装:

[root@localhost ~]# docker pull prom/prometheus:v2.20.0
v2.20.0: Pulling from prom/prometheus
76df9210b28c: Pull complete
559be8e06c14: Pull complete
c3806e22dbf3: Pull complete
56d23a920106: Pull complete
a972397e72b5: Pull complete
9b5a09e16121: Pull complete
2225e61e06fd: Pull complete
7146c8cda861: Pull complete
9842fcf5acf9: Pull complete
0fa64066a0cb: Pull complete
12d0f59dafd4: Pull complete
7d95766f273b: Pull complete
Digest: sha256:d4ba4dd1a9ebb90916d0bfed3c204adcb118ed24546bf8dd2e6b30fc0fd2009e
Status: Downloaded newer image for prom/prometheus:v2.20.0
docker.io/prom/prometheus:v2.20.0
[root@localhost ~]# mkdir -p /wgr/prometheus/
[root@localhost ~]# cp /etc/prometheus/prometheus.yml /wgr/prometheus/
[root@localhost ~]# docker run -d -p 9091:9090 -v  /wgr/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml 0da625e71069
3d19b00e9290b4d0e74f2e28ea815b597ac0f0d8395f7c35907d3775795c1805
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
3d19b00e9290        0da625e71069        "/bin/prometheus --c…"   4 seconds ago       Up 3 seconds        0.0.0.0:9091->9090/tcp   youthful_mendel
[root@localhost ~]#

image-20200909230018591

原文地址:https://www.cnblogs.com/dalianpai/p/13642880.html