Blackbox exporter
- tcp, http 체크가 가능한 exporter
integrations쪽에 exporter에 대한 설정을 넣고 configs쪽에 prometheus에 대힌 설정을 담음
- http 상태 코드를 받고 싶다면
valid_status_codes 부분에 받고자 하는 상태 코드를 모두 기입
port check
server:
log_level: info
metrics:
global:
scrape_interval: 1m
remote_write:
- url: "https://aps-workspaces.ap-south-1.amazonaws.com/workspaces/ws-0246d7a9-77a1-4109-bf19-c322ae84c98b/api/v1/remote_write"
sigv4:
region: ap-south-1
role_arn: arn:aws:iam::560412178918:role/grafana-agent_to_amp
wal_directory: /var/lib/grafana-agent
configs:
- name: blackbox_port
scrape_configs:
- job_name: port
metrics_path: /integrations/blackbox/metrics
params:
module: ["tcp_connect"]
static_configs:
- targets:
- 10.0.155.203:22
- 10.0.25.46:22
- 10.0.155.203:8080
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.0.155.203:9115
integrations:
blackbox:
enabled: true
blackbox_config:
modules:
tcp_connect:
prober: tcp
timeout: 5s
tcp:
preferred_ip_protocol: "ip4"
http
server:
log_level: info
metrics:
global:
scrape_interval: 1m
remote_write:
- url: "https://aps-workspaces.ap-south-1.amazonaws.com/workspaces/ws-0246d7a9-77a1-4109-bf19-c322ae84c98b/api/v1/remote_write"
sigv4:
region: ap-south-1
role_arn: arn:aws:iam::560412178918:role/grafana-agent_to_amp
wal_directory: /var/lib/grafana-agent
configs:
- name: blackbox_http
scrape_configs:
- job_name: http
metrics_path: /integrations/blackbox/metrics
params:
module: ["http_xxx"]
static_configs:
- targets:
- "https://prometheus.io"
- "https://google.co.kr"
- "https://naver.go.kr"
- "https://grafana-agent77.s3.ap-south-1.amazonaws.com/blackbox_exporter.yaml"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.0.155.203:9115
integrations:
blackbox:
enabled: true
blackbox_config:
modules:
http_xxx:
prober: http
timeout: 5s
http:
preferred_ip_protocol: "ip4"
valid_status_codes: [0, 100, 101, 102, 200, 201, 202, 203, 204, 205, 206, 207, 300, 301, 302, 303, 304, 305, 307, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 422, 423, 424, 426, 428, 429, 431, 444, 451, 500, 501, 502, 503, 504, 505, 506]
Process exporter
yaml
# Sample config for Grafana Agent
# For a full configuration reference, see: https://grafana.com/docs/agent/latest/configuration/.
server:
log_level: info
metrics:
global:
scrape_interval: 1m
remote_write:
- url: "https://aps-workspaces.ap-south-1.amazonaws.com/workspaces/ws-0246d7a9-77a1-4109-bf19-c322ae84c98b/api/v1/remote_write"
sigv4:
region: ap-south-1
role_arn: arn:aws:iam::560412178918:role/grafana-agent_to_amp
wal_directory: /var/lib/grafana-agent
configs:
- name: blackbox1
scrape_configs:
- job_name: proc
metrics_path: /integrations/process_exporter/metrics
integrations:
node_exporter:
enabled: true
process_exporter:
enabled: true
process_names:
- name: "{{.Comm}}:{{.PID}}"
cmdline:
- '.+'
{{.Comm}} : 프로세스의 명령어(top -c를 했을 때의 명령어)
{{.ExecBase}} : cgroup의 이름
cmdline: '.*' : 전체 프로세스
- 기본 포트 : 9256
하나의 agent에 다수의 exporter 설정
Linux
grafana-agent.yaml
server:
log_level: info
metrics:
global:
scrape_interval: 1m
remote_write:
- url: "https://aps-workspaces.ap-south-1.amazonaws.com/workspaces/ws-0246d7a9-77a1-4109-bf19-c322ae84c98b/api/v1/remote_write"
sigv4:
region: ap-south-1
role_arn: arn:aws:iam::560412178918:role/grafana-agent_to_amp
wal_directory: /var/lib/grafana-agent
configs:
- name: blackbox_port
scrape_configs:
- job_name: port
metrics_path: /integrations/blackbox/metrics
params:
module: ["tcp_connect"]
static_configs:
- targets:
- 10.0.155.203:22
- 10.0.25.46:22
- 10.0.155.203:8080
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.0.155.203:9115
- name: ec2
scrape_configs:
- job_name: scoc-test
metrics_path: /integrations/node_exporter/metrics
ec2_sd_configs:
- region: ap-south-1
port: 9115
relabel_configs:
- source_labels: [__meta_ec2_tag_Name]
target_label: instance_name
- source_labels: [__meta_ec2_owner_id]
target_label: account_id
- source_labels: [__meta_ec2_private_ip]
target_label: private_ip
- source_labels: [__meta_ec2_instance_id]
target_label: instance_id
- source_labels: [__meta_ec2_tag_Name, __meta_ec2_instance_id]
regex: ([^;]+);([^;]+)
replacement: ${1} / ${2}
target_label: instance_name_id
metric_relabel_configs:
- source_labels: [__name__]
regex: '(up|scrape_series_added |scrape_duration_seconds | scrape_samples_scraped | scrape_samples_post_metric_relabeling)'
action: 'drop'
- name: blackbox_http
scrape_configs:
- job_name: http
metrics_path: /integrations/blackbox/metrics
params:
module: ["http_xxx"]
static_configs:
- targets:
- "https://prometheus.io"
- "https://google.co.kr"
- "https://naver.go.kr"
- "https://grafana-agent77.s3.ap-south-1.amazonaws.com/blackbox_exporter.yaml"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.0.155.203:9115
integrations:
blackbox:
enabled: true
blackbox_config:
modules:
tcp_connect:
prober: tcp
timeout: 5s
tcp:
preferred_ip_protocol: "ip4"
http_xxx:
prober: http
timeout: 5s
http:
preferred_ip_protocol: "ip4"
valid_status_codes: [0, 100, 101, 102, 200, 201, 202, 203, 204, 205, 206, 207, 300, 301, 302, 303, 304, 305, 307, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 422, 423, 424, 426, 428, 429, 431, 444, 451, 500, 501, 502, 503, 504, 505, 506]
node_exporter:
enabled: true