Prometheus와 Grafana를 연동하여 모니터링 환경을 구성할 때, 모니터링 대상 서버에서 데이터를 수집하기 위한 방법으로는 여러 가지가 있습니다. 그중에서 Grafana Agent를 설치하는 방식은 Prometheus와의 직접적인 데이터 수집 방식과는 다른 몇 가지 장점을 제공합니다.

Grafana Agent config 수정
C:\Program Files\Grafana Agent\agent-config.yaml 수정
Grafana Agent 서비스 재시작
net stop "Grafana Agent" & net start "Grafana Agent"
vi /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://rpm.grafana.com
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://rpm.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
yum install grafana-agent
Target의 유형에 따라 알맞은 형태로 endpoint를 기술합니다.
<기본값>
server:
log_level: warn
metrics:
global:
scrape_interval: 1m
wal_directory: '/var/lib/grafana-agent'
configs:
# Example Prometheus scrape configuration to scrape the agent itself for metrics.
# This is not needed if the agent integration is enabled.
# - name: agent
# host_filter: false
# scrape_configs:
# - job_name: agent
# static_configs:
# - targets: ['127.0.0.1:9090']
integrations:
agent: // metric을 Grafana agent에서 수집
enabled: true
node_exporter: // metric을 Linux OS에서 수집
enabled: true
include_exporter_metrics: true
disable_collectors:
- "mdadm"
< Target이 AMP일 경우 >
server:
log_level: warn
metrics:
global:
scrape_interval: 15s
wal_directory: '/var/lib/grafana-agent'
configs:
# Example Prometheus scrape configuration to scrape the agent itself for metrics.
# This is not needed if the agent integration is enabled.
# - name: agent
- name: agent
host_filter: false
scrape_configs:
- job_name: agent
static_configs:
- targets: ['127.0.0.1:12345']
integrations:
agent:
#enabled: true
enabled: false
node_exporter:
enabled: true
include_exporter_metrics: true
disable_collectors:
- "mdadm"
prometheus_remote_write:
- url: https://aps-workspaces.us-west-2.amazonaws.com/workspaces/ws-5467c113-4851-4e6d-bb70-2e53046b7dae/api/v1/remote_write
sigv4:
region: us-west-2
access_key: AKIAVxxxxxxxWNGLN // IAM 주체와 연결된 보안 액세스 키 및 액세스 키 ID를 사용하여 요청에 서명해야 함
secret_key: M/vrUyjx/xxxxxxxxxx/xxxxxxOekA8lG
< Target이 일반 Prometheus일 경우 >
server:
log_level: warn
metrics:
global:
scrape_interval: 15s
wal_directory: '/var/lib/grafana-agent'
configs:
- name: agent
host_filter: false
scrape_configs:
- job_name: agent
static_configs:
- targets: ['127.0.0.1:12345']
integrations:
agent:
enabled: false
node_exporter:
enabled: true
include_exporter_metrics: true
disable_collectors:
- "mdadm"
prometheus_remote_write:
- url: http://monitoring-p.company.com:9090/api/v1/write
< run the service >
systemctl start grafana-agent
< configure the Grafana Agent to restart at boot >
systemctl enable grafana-agent.service
< check the logs of running agent >
journalctl -u grafana-agent
참조 문서