Jumat, 24 April 2020

How to install prometheus on centos 7

  Tidak ada komentar


Download Prometheus package
[[email protected] ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.17.2/prometheus-2.17.2.linux-amd64.tar.gz
--2020-04-24 08:42:05--  https://github.com/prometheus/prometheus/releases/download/v2.17.2/prometheus-2.17.2.linux-amd64.tar.gz
Resolving github.com (github.com)... 52.74.223.119
Connecting to github.com (github.com)|52.74.223.119|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/6838921/70e29d80-830b-11ea-91f7-0e535a551978?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200424%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200424T014206Z&X-Amz-Expires=300&X-Amz-Signature=842daed1a8eeda464238c85d29ffa4f97be6754b8d4a2d324df41e9707d86ff0&X-Amz-SignedHeaders=host&actor_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.17.2.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2020-04-24 08:42:06--  https://github-production-release-asset-2e65be.s3.amazonaws.com/6838921/70e29d80-830b-11ea-91f7-0e535a551978?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200424%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200424T014206Z&X-Amz-Expires=300&X-Amz-Signature=842daed1a8eeda464238c85d29ffa4f97be6754b8d4a2d324df41e9707d86ff0&X-Amz-SignedHeaders=host&actor_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.17.2.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.204.235
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.204.235|:443... connected                                                                     .
HTTP request sent, awaiting response... 200 OK
Length: 60150384 (57M) [application/octet-stream]
Saving to: ‘prometheus-2.17.2.linux-amd64.tar.gz’

100%[======================================>] 60,150,384  3.06MB/s   in 21s

2020-04-24 08:42:30 (2.72 MB/s) - ‘prometheus-2.17.2.linux-amd64.tar.gz’ saved [60150384/60150384]

[[email protected] ~]# 
 Perform following command
[[email protected] ~]# useradd --no-create-home --shell /bin/false prometheus
[[email protected] ~]# mkdir /etc/prometheus
[[email protected] ~]# mkdir /var/lib/prometheus
[[email protected] ~]# chown prometheus:prometheus /etc/prometheus
[[email protected] ~]# chown prometheus:prometheus /var/lib/prometheus
Extract Prometheus package
[[email protected] ~]# ls
anaconda-ks.cfg                       skema-prefork
check-mk-agent_1.6.0p10-1_all.deb     skema-prefork.tar
composer-setup.php                    skemaraja
L60464-1302TMP.html.gz                strace_dir
npm-debug.log                         update-source.sh
prometheus-2.17.2.linux-amd64.tar.gz
[[email protected] ~]#
[[email protected] ~]# tar -xzf prometheus-2.17.2.linux-amd64.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg                    prometheus-2.17.2.linux-amd64.tar.gz
check-mk-agent_1.6.0p10-1_all.deb  skema-prefork
composer-setup.php                 skema-prefork.tar
L60464-1302TMP.html.gz             skemaraja
npm-debug.log                      strace_dir
prometheus-2.17.2.linux-amd64      update-source.sh
[[email protected] ~]#
Rename the prometheus directory
[[email protected] ~]# mv prometheus-2.17.2.linux-amd64 prometheuspackage
[[email protected] ~]#
[[email protected] ~]# cp prometheuspackage/prometheus /usr/local/bin/
[[email protected] ~]# cp prometheuspackage/promtool /usr/local/bin/
[[email protected] ~]#
[[email protected] ~]# chown prometheus:prometheus /usr/local/bin/prometheus
[[email protected] ~]# chown prometheus:prometheus /usr/local/bin/promtool
[[email protected] ~]#
[[email protected] ~]# cp -r prometheuspackage/consoles /etc/prometheus
[[email protected] ~]# cp -r prometheuspackage/console_libraries /etc/prometheus                                                                     [[email protected] ~]#
[[email protected] ~]# vi /etc/prometheus/prometheus.yml
[[email protected] ~]# chown prometheus:prometheus /etc/prometheus/prometheus.yml
[[email protected] ~]#
[[email protected] ~]# vi /etc/systemd/system/prometheus.service
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]#
Check prometheus service status and open the firewall
[[email protected] ~]# systemctl status prometheus
● prometheus.service - Prometheus
   Loaded: loaded (/etc/systemd/system/prometheus.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-04-24 08:54:19 WIB; 12s ago
 Main PID: 25241 (prometheus)
   CGroup: /system.slice/prometheus.service
           └─25241 /usr/local/bin/prometheus --config.file /etc/prometheus/prometheus.yml --storage.tsdb.path /var/lib/prometheus/ --web.console.t...

Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.847Z caller=main.go:667 msg="Starting TSDB ..."
Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.847Z caller=web.go:515 component=web msg="Start listenin...0.0:9090
Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.849Z caller=head.go:575 component=tsdb msg="replaying WA... awhile"
Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.851Z caller=head.go:624 component=tsdb msg="WAL segment ...egment=0
Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.851Z caller=head.go:627 component=tsdb msg="WAL replay c...279231ms
Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.852Z caller=main.go:683 fs_type=XFS_SUPER_MAGIC
Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.852Z caller=main.go:684 msg="TSDB started"
Apr 24 08:54:19 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:19.852Z caller=main.go:788 msg="Loading configuration file"...heus.yml
Apr 24 08:54:29 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:29.251Z caller=main.go:816 msg="Completed loading of config...heus.yml
Apr 24 08:54:29 app01 prometheus[25241]: level=info ts=2020-04-24T01:54:29.251Z caller=main.go:635 msg="Server is ready to receive ...quests."
Hint: Some lines were ellipsized, use -l to show in full.
[[email protected] ~]#
[[email protected] ~]# firewall-cmd --zone=public --add-port=9090/tcp --permanent
success
[[email protected] ~]# firewall-cmd --reload
success
[[email protected] ~]#
[[email protected] ~]#