Ubuntu 모니터링 환경 구성 (Telegraf, Prometheus)

Ubuntu 모니터링 환경 구성 (Telegraf, Prometheus)

Telegraf

# influxdata-archive_compat.key GPG fingerprint:
#     9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E
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
Telegraf | InfluxData
Telegraf is an open source server agent that makes it easy to collect metrics, logs, and data. Download the latest Telegraf and get release updates free!

시스템 상태를 InfluxDB로 push 해주는? 느낌인듯하다

다양한 플러그인 지원으로 확장성도 짱짱한듯 ㅇㅅㅇb

설정파일 위치

/etc/telegraf/telegraf.conf

# # Configuration for sending metrics to InfluxDB
[[outputs.influxdb_v2]]
#   ## The URLs of the InfluxDB cluster nodes.
#   ##
#   ## Multiple URLs can be specified for a single cluster, only ONE of the
#   ## urls will be written to each interval.
#   ##   ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
  urls = ["{수정}"]
#
#   ## Token for authentication.
  token = "{수정}"
#
#   ## Organization is the name of the organization you wish to write to; must exist.
  organization = "{수정}"
#
#   ## Destination bucket to write into.
  bucket = "{수정}"
#
#   ## The value of this tag will be used to determine the bucket.  If this
#   ## tag is not set the 'bucket' option is used as the default.
#   # bucket_tag = ""
#
#   ## If true, the bucket tag will not be added to the metric.
#   # exclude_bucket_tag = false
#
#   ## Timeout for HTTP messages.
#   # timeout = "5s"
#
#   ## Additional HTTP headers
#   # http_headers = {"X-Special-Header" = "Special-Value"}
#
#   ## HTTP Proxy override, if unset values the standard proxy environment
#   ## variables are consulted to determine which proxy, if any, should be used.
#   # http_proxy = "http://corporate.proxy:3128"
#
#   ## HTTP User-Agent
#   # user_agent = "telegraf"
#
#   ## Content-Encoding for write request body, can be set to "gzip" to
#   ## compress body or "identity" to apply no encoding.
#   # content_encoding = "gzip"
#
#   ## Enable or disable uint support for writing uints influxdb 2.0.
#   # influx_uint_support = false
#
#   ## Optional TLS Config for use on HTTP connections.
#   # tls_ca = "/etc/telegraf/ca.pem"
#   # tls_cert = "/etc/telegraf/cert.pem"
#   # tls_key = "/etc/telegraf/key.pem"
#   ## Use TLS but skip chain & host verification
#   # insecure_skip_verify = false
Install Telegraf | Telegraf Documentation
Install Telegraf on your operating system.

~ 로 진행하였으나 Grafana 적당한 템플릿을 못찾아 Prometheus 로 진행하기로 결정

Grafana 템플릿

Telegraf Metrics dashboard for InfluxDB 2.0 (Flux) | Grafana Labs

도커 모니터링

[[inputs.docker]]
  endpoint = "unix:///var/run/docker.sock"
  gather_services = false
  timeout = "5s"

telegraf 권한 추가 (docker)

sudo usermod -aG docker telegraf
sudo systemctl restart telegraf

Grafana 템플릿

InfluxDB 2.x Telegraf Docker Dashboard | Grafana Labs
The InfluxDB 2.x Telegraf Docker Dashboard dashboard uses the influxdb data source to create a Grafana dashboard with the stat and timeseries panels.

prometheus

sudo apt install prometheus

설정 수정

/etc/prometheus/prometheus.yml

환경 변수 변경

/etc/default/prometheus

ARGS="--web.listen-address=:9095"

Grafana 템플릿

Node Exporter Full | Grafana Labs

일단 정상작동 하는건 확인했으나 Ubuntu 종료시 모니터링 정보 확인못하는걸 생각을 못했음..

aws에 부하는 상대적으로 적겠지만 모니터링에는 적합하지 않을거라 생각됨