http://{IP}:9090 접속 시

 

설정한 장비(Agent)의 연결 확인

'기술 노트 > prometheus' 카테고리의 다른 글

prometheus 설정  (0) 2023.04.04
Prometheus 설치 및 실행  (0) 2023.03.21

기본 설정에 필요한 부분만 수정하였습니다.

각자 설치 시 재 설정 파일과 비교하시면 좋을 것아요.

# 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'.

    scrape_interval: 5m
    scrape_timeout: 1m

    static_configs:
      - targets: ["localhost:9090"]

  - job_name: 'snmp'
    static_configs:
      - targets: ['192.168.10.2']  # SNMP device.
      - targets: ['192.168.10.3']  # SNMP device.
      - targets: ['192.168.10.4']  # SNMP device.
      - targets: ['192.168.10.5']  # SNMP device.
    metrics_path: /snmp
    params:
      module: [if_mib]
      community: [<각자 설정한 commuity  값>]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 192.168.0.17:9116  # The SNMP exporter's real hostname:port.
  - job_name: 'grafana_metrics'
    scrape_interval: 15s
    scrape_timeout: 5s

    static_configs:
      - targets: ['192.168.0.17:3000']

'기술 노트 > prometheus' 카테고리의 다른 글

prometheus와 snmp_exporter 설치 결과  (0) 2023.04.04
Prometheus 설치 및 실행  (0) 2023.03.21

프로메테우스 다운로드

https://prometheus.io/download/

 

프로메테우스 설치

아래 매뉴얼을 따라하시면 별도로 다운로드를 하지 않으셔도 됩니다.

[root@tmplogsvr ~]# groupadd --system prometheus
[root@tmplogsvr ~]# useradd -s /sbin/nologin --system -g prometheus prometheus
[root@tmplogsvr ~]# mkdir /var/lib/prometheus
[root@tmplogsvr ~]# for i in rules rules.d files_sd; do mkdir -p /etc/prometheus/${i}; done
[root@tmplogsvr ~]# curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest   | grep browser_download_url   | grep linux-amd64   | cut -d '"' -f 4   | wget -qi -
[root@tmplogsvr ~]# tar xvf prometheus-2.42.0.linux-amd64.tar.gz
prometheus-2.42.0.linux-amd64/
prometheus-2.42.0.linux-amd64/NOTICE
prometheus-2.42.0.linux-amd64/consoles/
prometheus-2.42.0.linux-amd64/consoles/index.html.example
prometheus-2.42.0.linux-amd64/consoles/node.html
prometheus-2.42.0.linux-amd64/consoles/prometheus-overview.html
prometheus-2.42.0.linux-amd64/consoles/node-disk.html
prometheus-2.42.0.linux-amd64/consoles/prometheus.html
prometheus-2.42.0.linux-amd64/consoles/node-overview.html
prometheus-2.42.0.linux-amd64/consoles/node-cpu.html
prometheus-2.42.0.linux-amd64/console_libraries/
prometheus-2.42.0.linux-amd64/console_libraries/menu.lib
prometheus-2.42.0.linux-amd64/console_libraries/prom.lib
prometheus-2.42.0.linux-amd64/prometheus.yml
prometheus-2.42.0.linux-amd64/LICENSE
prometheus-2.42.0.linux-amd64/promtool
prometheus-2.42.0.linux-amd64/prometheus
[root@tmplogsvr ~]# cd prometheus-2.42.0.linux-amd64/
[root@tmplogsvr prometheus-2.42.0.linux-amd64]# cp ./prometheus promtool /usr/local/bin
[root@tmplogsvr prometheus-2.42.0.linux-amd64]# cp -r prometheus.yml consoles/ console_libraries/ /etc/prometheus/
[root@tmplogsvr prometheus-2.42.0.linux-amd64]# cd
[root@tmplogsvr ~]# echo '
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus \
  --web.console.templates=/etc/prometheus/consoles \
  --web.console.libraries=/etc/prometheus/console_libraries \
  --web.listen-address=0.0.0.0:9090 \
  --web.external-url=

SyslogIdentifier=prometheus
Restart=always

[Install]
WantedBy=multi-user.target' > /etc/systemd/system/prometheus.service
[root@tmplogsvr ~]# chown -R prometheus:prometheus /etc/prometheus
[root@tmplogsvr ~]# chmod -R 775 /etc/prometheus/
[root@tmplogsvr ~]# chown -R prometheus:prometheus /var/lib/prometheus/
[root@tmplogsvr ~]# systemctl daemon-reload
[root@tmplogsvr ~]# systemctl enable prometheus
Created symlink /etc/systemd/system/multi-user.target.wants/prometheus.service → /etc/systemd/system/prometheus.service.
[root@tmplogsvr ~]#

 

프로메테우스 실행

[root@tmplogsvr ~]# systemctl start prometheus.service
[root@tmplogsvr ~]# systemctl status prometheus.service
● prometheus.service - Prometheus
   Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-03-22 10:04:33 KST; 4s ago
     Docs: https://prometheus.io/docs/introduction/overview/
 Main PID: 233870 (prometheus)
    Tasks: 13 (limit: 99645)
   Memory: 20.5M
   CGroup: /system.slice/prometheus.service
           └─233870 /usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --web.console.templates=/etc/prometheus/consoles --web.console.lib>

 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.564Z caller=head.go:685 level=info component=tsdb msg="WAL segment loaded" segment=1 maxSegment=3
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.565Z caller=head.go:685 level=info component=tsdb msg="WAL segment loaded" segment=2 maxSegment=3
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.565Z caller=head.go:685 level=info component=tsdb msg="WAL segment loaded" segment=3 maxSegment=3
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.565Z caller=head.go:722 level=info component=tsdb msg="WAL replay completed" checkpoint_replay_duration=19.402µs wal_replay_dur>
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.566Z caller=main.go:1014 level=info fs_type=EXT4_SUPER_MAGIC
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.566Z caller=main.go:1017 level=info msg="TSDB started"
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.566Z caller=main.go:1197 level=info msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.568Z caller=main.go:1234 level=info msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.yml total>
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.568Z caller=main.go:978 level=info msg="Server is ready to receive web requests."
 3월 22 10:04:33 tmplogsvr prometheus[233870]: ts=2023-03-22T01:04:33.568Z caller=manager.go:974 level=info component="rule manager" msg="Starting rule manager..."
lines 1-20/20 (END)

 

웹페이지 접근

http://{서버IP}:9090

'기술 노트 > prometheus' 카테고리의 다른 글

prometheus와 snmp_exporter 설치 결과  (0) 2023.04.04
prometheus 설정  (0) 2023.04.04

+ Recent posts