본문 바로가기
etc

prometheus, grafana, pushgateway 설치

by kyeongseo.oh 2023. 9. 11.

binary files

prometheus : https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
grafana : https://dl.grafana.com/oss/release/grafana-10.0.2-1.x86_64.rpm (https://grafana.com/grafana/download?edition=oss)
pushgateway : https://github.com/prometheus/pushgateway/releases/download/v1.6.0/pushgateway-1.6.0.linux-amd64.tar.gz
 
## python으로 push할 경우
python package : https://files.pythonhosted.org/packages/5b/62/75fc6f255e214ff0a8bd3267a0bd337521dd24f76cd593c10795e488f41b/prometheus_client-0.17.0-py3-none-any.whl

 

작업 전에 방화벽을 해제합니다.

systemctl stop firewalld

 

prometheus 설치

1. binary 파일 다운로드 및 압축 해제

mkdir /prometheus
cd /prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
tar -zxvf prometheus-2.45.0.linux-amd64.tar.gz

 

2. prometheus.yml 수정

vi /prometheus/prometheus-2.45.0.linux-amd64/prometheus.yml

# 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"]
 
  - job_name: 'pushgateway'
    honor_labels: true
    static_configs:
      - targets: ['localhost:9091']

 

3. pushgateway 서비스 등록

vi /etc/systemd/system/prometheus.service

[Unit]
Description=prometheus
 
[Service]
User=root
Restart=on-failure
ExecStart=/prometheus/prometheus-2.45.0.linux-amd64/prometheus \
 --config.file=/prometheus/prometheus-2.45.0.linux-amd64/prometheus.yml \
 --storage.tsdb.path=/prometheus/prometheus-2.45.0.linux-amd64/data
 
 
[Install]
WantedBy=multi-user.target

 

grafana 설치

sudo yum install -y https://dl.grafana.com/oss/release/grafana-10.0.2-1.x86_64.rpm
systemctl start grafana-server

 

pushgateway 설치

1. binary 파일 다운로드 및 압축 해제

cd /prometheus
 
wget https://github.com/prometheus/pushgateway/releases/download/v1.6.0/pushgateway-1.6.0.linux-amd64.tar.gz
 
tar -zxvf pushgateway-1.6.0.linux-amd64.tar.gz

 

2. pushgateway 서비스 등록

vi /etc/systemd/system/pushgateway.service

[Unit]
Description=Pushgateway
Wants=network-online.target
After=network-online.target
 
[Service]
Type=simple
ExecStart=/prometheus/pushgateway-1.6.0.linux-amd64/pushgateway
 
[Install]
WantedBy=multi-user.target

 

prometheus, pushgateway 시작

systemctl enable prometheus
systemctl enable pushgateway

systemctl start prometheus
systemctl start pushgateway

'etc' 카테고리의 다른 글

smtp 서버  (0) 2023.09.27
mariadb binary log expire 설정  (0) 2023.09.12
cloudera hue 설치 (rhel8)  (0) 2023.09.11
taskfile  (0) 2023.08.05
mariadb data retention  (0) 2023.07.29

댓글