일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- wazuh 취약점 점검
- grafana esxi monitoring
- 특정 도메인 url rewrite
- MSCS
- grafana vsphere
- FortiGate
- wazuh 서버 설치
- ubuntu 22.04+Prometheus+Grafana+Node Exporter
- prometheus grafana 연동
- IBM X3550 M4
- telegraf esxi 모니터링
- grafana esxi
- Node Exporter 설치 및 연동
- wazuh 설치
- grafana esxio
- piolink
- grafana telegraf influxdb esxi 모니터링
- IIS https 무한루프
- centos
- grafana
- URL 재작성
- grafana vcenter
- iis url rewrite
- telegraf influxdb
- https 자동전환
- grafana esxi 모니터링
- http 리디렉션
- Prometheus
- wazuh agent 설치
- observium 설정
- Today
- Total
IDC 엔지니어의 기술 이야기
Prometheus+Grafana+Exporter 연동 구축 본문
환경 : Ubuntu 22.04(프로세스 2개, 메모리 4G, DISK 50G)
초록색 : 명령어 입력
파랑색 : 설정 입력(Vi,Nano등)
빨강색 : 주석
ㅁ Prometheus 설치
1. 패키지 업데이트
root@grafana:~# sudo apt update
2. Prometheus 관련 사용자,그룹,폴더 생성
root@grafana:~# sudo groupadd --system prometheus
root@grafana:~# sudo useradd -s /sbin/nologin --system -g prometheus prometheus
root@grafana:~# sudo mkdir /etc/prometheus
root@grafana:~# sudo mkdir /var/lib/prometheus
root@grafana:~# sudo chown -R prometheus:prometheus /var/lib/prometheus/
3. Prometheus 다운로드
root@grafana:~# wget https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz
4. 다운로드한 파일 압축 풀기
root@grafana:~# tar xvf prometheus-2.43.0.linux-amd64.tar.gz
5. 명령어 파일 이동 및 Prometheus 버전 확인
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo mv prometheus promtool /usr/local/bin/
root@grafana:~/prometheus-2.43.0.linux-amd64# prometheus --version
6. Prometheus 설정 파일 이동 및 확인
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo mv prometheus.yml /etc/prometheus/prometheus.yml
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo mv consoles/ console_libraries/ /etc/prometheus/
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo cat /etc/prometheus/prometheus.yml
7. Prometheus 시스템 서비스 만들기
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo vi /etc/systemd/system/prometheus.service
>> 아래 내용 작성후 저장
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
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 \
[Install]
WantedBy=multi-user.target
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo systemctl daemon-reload
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo systemctl start prometheus
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo systemctl enable --now prometheus
root@grafana:~/prometheus-2.43.0.linux-amd64# sudo systemctl status prometheus
8. Prometheus 접속
http://Prometheus 서버IP:9090/
ㅁ Grafana 설치
1. Grafana 패키지 저장소 추가하기
root@grafana:~# sudo apt-get install -y apt-transport-https gnupg2 curl
root@grafana:~# curl https://packages.grafana.com/gpg.key | sudo apt-key add -
root@grafana:~# echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
root@grafana:~# sudo apt-get update
2. Grafana 설치
root@grafana:~# sudo apt-get install -y grafana
3. Grafana 실행
root@grafana:~# sudo systemctl enable grafana-server
root@grafana:~# sudo systemctl start grafana-server
root@grafana:~# sudo systemctl status grafana-server
4. Grafana 접속
http://Prometheus 서버IP:3000/
초기 ID/PW : admin / admin
ㅁ exporter(Agent) 설치 [리눅스 계열]
** Agent 대상 서버에 설치 하는것임
** exporter 사용 용도에 맞게 다양하게 있다. 그중에 시스템 성능체크가 가능한 node-exporter를 설치 진행
1. node-exporter-install.sh 파일 작성
root # vi node-exporter-install.sh
DIST=$(
. /etc/os-release
echo $ID
)
if [[ $DIST == "ubuntu" ]]; then
VERSION=$(lsb_release -r | awk '{print $2}' | awk -F . '{print $1$2}')
apt install prometheus-node-exporter -y
systemctl --now enable prometheus-node-exporter
systemctl --now start prometheus-node-exporter
fi
if [[ $DIST == "centos" ]]; then
{
echo '[prometheus]'
echo 'name=prometheus'
echo 'baseurl= https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch'
echo 'repo_gpgcheck=1'
echo 'enabled=1'
echo 'gpgkey=https://packagecloud.io/prometheus-rpm/release/gpgkey'
echo ' https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm'
echo 'gpgcheck=1'
echo 'metadata_expire=300'
} >/etc/yum.repos.d/prometheus.repo
yum install -y node_exporter
systemctl --now enable node_exporter
systemctl --now start node_exporter
fi
2. 설치 진행
root # chmod 775 /root/node-exporter-install.sh
root # /root/node-exporter-install.sh
3. 확인
root # ps -ef | grep exporter | grep -v grep
prometh+ 3497047 1 0 Oct06 ? 00:00:44 /usr/bin/prometheus-node-exporter
4. Prometheus 서버에서 Agent 등록 해주기
root@grafana:~# vi /etc/prometheus/prometheus.yml
** 아래와 같이 추가 해주면 된다
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"]
- targets: ["Agent 서버IP:9100"]
** Prometheus 서버 재시작하여 적용 해주기
root@grafana:~# systemctl restart prometheus
상단메뉴에서 "Status > Target" 이동후 확인해 보면 아래와 같이 확인 가능할것 이다.
ㅁ Grafana 대쉬보드 설정
** 기존에 만들어진 대쉬보드를 활용해서 볼 생각이다
1. 대쉬보드 다운로드
https://grafana.com/grafana/dashboards/?pg=community&plcmt=topnav&collector=nodeexporter
Dashboards | Grafana Labs
Thank you! Your message has been received!
grafana.com
접속후 다운로드수가 가장 많은 "Node Export Full"을 가지고 테스트
아래 화면 에서 "Copy ID to clipboard" 클릭
2. Grafana 대쉬보드 적용
"Home > Dashboards" 이동
"New > Import" 이동
Copy한 ID 붙여놓고 Load 하기(JSON 파일 다운로드후 업로드해도 동일)
Data Source는 Prometheus 선택후 Import 진행
그럼 아래와 같은 화면을 볼수 있을것이다.
'OS_APP > Monitoring' 카테고리의 다른 글
HIDS Wazuh 서버 구축 (1) | 2023.12.26 |
---|---|
Grafana+Telegraf+influxDB 연동을 통한 Vmware Esxi 모니터 (0) | 2023.11.28 |
Docker+Prometheus+Grafana+Node Exporter 설치 및 연동 (0) | 2023.09.21 |
Observium 설정 (0) | 2023.07.04 |
Observium 설치 (0) | 2023.07.04 |