-
『모니터링』Telegraf 에이전트 설정DevOps 2023. 8. 20. 22:53
Telegraf란?
모니터링을 위해 CPU, Memory, Disk 등의 정보를 InfluxDB(대표적)나 다른 DB등으로 보내주는 역할을 한다.
Cloudwatch Agent와 같은 역할을 한다고 생각하면 될 듯 하다.
설정법
우선 설치를 위해 공식 홈페이지로 접속해야한다.
https://docs.influxdata.com/telegraf/v1.27/install/
Install Telegraf | Telegraf 1.27 Documentation
Thank you for your feedback! Let us know what we can do better:
docs.influxdata.com
여기서 내리다보면 자신의 환경에 맞게 설치가 가능하다.
Ubuntu, Debian
wget -q https://repos.influxdata.com/influxdata-archive_compat.key echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list sudo apt-get update && sudo apt-get install telegraf
CentOS, RedHat
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo [influxdb] name = InfluxData Repository - Stable baseurl = https://repos.influxdata.com/stable/\$basearch/main enabled = 1 gpgcheck = 1 gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key EOF sudo yum install telegraf
SLES, OpenSuse
zypper ar -f obs://devel:languages:go/ go zypper in telegraf
Windows
https://docs.influxdata.com/telegraf/v1.27/install/?t=Windows
Install Telegraf | Telegraf 1.27 Documentation
Thank you for your feedback! Let us know what we can do better:
docs.influxdata.com
윈도우는 위 링크에 나와있는대로 설치하면 된다.
이후에 설정파일을 건들여야한다. 즉 해당파일 설정전 아래 포스트를 확인하고 와야한다.
https://itmango.tistory.com/40
『모니터링』InfluxDB설치(docker-compose)
InfluxDB란? 시계열 데이터 이며, 이전 포스트에서 작성한대로 Telegraf에 데이터를 받아올 목적이다. 설정법 influxdb는 v1과 v2가 있다. v2의 경우 새로운 문법을 사용하기에 공부가 조금 필요하다. 해
itmango.tistory.com
나는 Telegraf와 InfluxDB를 연동할 것이기에 InfluxDB에 맞추어 설정하였다.
(리눅스 유저 설정이 기본값일 경우 sudo 명령어를 함께 사용하여 진행해야한다.)
InfluxDB v2기준 파일 설정
cat <<EOF > /etc/telegraf/telegraf.conf [[outputs.influxdb_v2]] urls = ["http://<InfluxDB URL>:8086"] token = "<Token Value>" organization = "<Organization Name>" bucket = "<Bubcket Name>" EOF
위 값들에 대한 설정값은 본인의 환경에 맞추어 진행하면 된다.
그 뒤 Telegraf를 enable, start 시키면 된다.
systemctl enable telegraf systemctl start telegraf
이제 설정은 완료되었다. 다음 글에서는 InfluxDB에 대한 설정을 해볼까 한다.
오류 해결
만약 블로그에서 설정한 대로 했을 때 오류가 발생된다면, 두가지 방법이 있다.
systemctl enable시 에러가 발생되는 경우는 telegraf설정 파일을 삭제 후 기본값에서 필요한 부분을 찾아 활성화 하면 된다.
이때 반드시 [[outputs.<value>]] 부분을 함께 주석을 해제 하여야 한다.
yum remove telegraf rm /etc/telegraf/telegraf.conf
그래도 해결되지 않는다면 다음을 따라야 한다.
기본파일을 telegraf.d밑으로 보내고 빈 파일을 기존 위치에 두는 것 이다.
아마 위에서 다 해결이 되었겠지만 아래 방법으로도 해결이 된다고 한다.
mv /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.d/ touch /etc/telegraf/telegraf.conf