ServiceWatch Agent 사용하기
사용자는 Virtual Server/GPU Server/Bare Metal Server 등에서 ServiceWatch Agent를 설치하여 사용자 정의 지표와 로그를 수집할 수 있습니다.
ServiceWatch Agent
서버에 ServiceWatch의 사용자 정의 지표 및 로그 수집을 위해 설치해야 하는 Agent는 크게 2가지로 나눌 수 있습니다. Prometheus Exporter와 Open Telemetry Collector 입니다.
| 구분 | 상세 설명 | |
|---|---|---|
| Prometheus Exporter | 특정 애플리케이션이나 서비스의 메트릭을 Prometheus가 스크랩(scrape)할 수 있는 형식으로 제공
| |
| Open Telemetry Collector | 분산 시스템의 메트릭, 로그와 같은 텔레메트리 데이터를 수집하고, 처리(필터링, 샘플링 등)한 후, 여러 백엔드(예: Prometheus, Jaeger, Elasticsearch 등)로 내보내는 중앙 집중식 수집기 역할
|
ServiceWatch Agent를 통해 서버의 로그 파일을 ServiceWatch에 연계하기 위해서는 로그 그룹과 로그 그룹 내 로그 스트림을 먼저 생성해야합니다.
- 로그 그룹 생성 및 로그 스트림 생성에 대한 자세한 내용은 로그를 참고하세요.
ServiceWatch를 위한 Open Telemetry Collector 사전 설정
서버에서 ServiceWatch 지표와 로그 수집을 위한 Open Telemetry Collector를 사용하기 위해 아래의 순서에 따라 설치합니다.
- ServiceWatch를 위한 Agent 파일을 다운로드 받을 수 있는 URL로 부터 Agent 파일을 다운로드 받습니다.
wget [ServiceWatch Agent 파일 다운로드 URL]wget [ServiceWatch Agent 파일 다운로드 URL]- ServiceWatch를 위한 Open Telemetry Collector Agent 파일은 아래와 같이 확인할 수 있습니다.
- ServiceWatch를 위한 Agent 파일을 압축 해제합니다.배경색 변경
unzip ServiceWatch_Agent.zipunzip ServiceWatch_Agent.zip코드블록. ServiceWatch를 위한 Agent 파일 압축 해제 - ServiceWatch Agent를 사용하는 환경이 Linux OS인 경우, 아래와 같이 실행 권한을 부여해야합니다.배경색 변경
chmod +x agent/otelcontribcol_linux_amd64 chmod +x agent/servicewatch-agent-manager-linux-amd64chmod +x agent/otelcontribcol_linux_amd64 chmod +x agent/servicewatch-agent-manager-linux-amd64코드블록. ServiceWatch를 위한 Agent 파일 실행 권한 부여 구분 상세 설명 examples 예시 설정 파일 폴더. 각 폴더 안에 agent.json,log.json,metric.json예시 파일이 존재함os-metrics-min-examples: Node Exporter를 활용한 최소 지표 설정 예시
os-metrics-all-examples: Node Exporter를 활용한 memory/filesystem Collector 지표 설정 예시
gpu-metrics-min-examples: DCGM Exporter를 활용한 최소 지표 설정 예시
gpu-metrics-all-examples: DCGM Exporter를 활용한 주요 지표 설정 예시
otelcontribcol_linux_amd64 ServiceWatch용 Open Telemetry Collector for Linux otelcontribcol_windows_amd64.exe ServiceWatch용 Open Telemetry Collector for Windows servicewatch-agent-manager-linux-amd64 ServiceWatch Agent Manager for Linux servicewatch-agent-manager-windows-amd64.exe ServiceWatch Agent Manager for Windows 표. ServiceWatch를 위한 Agent 파일 구성
- ServiceWatch를 위한 Agent 파일을 압축 해제합니다.
ServiceWatch용 Open Telemetry Collector를 위해 ServiceWatch Agent Manager의 Agent 설정 파일을 정의합니다.
구분 상세 설명 namespace 사용자 정의 지표를 위한 사용자 정의 네임 스페이스 - 네임스페이스는 지표를 구분하고 그룹화하기 위한 논리적인 구분으로 사용자 정의 지표를 구분하기 위한 사용자 정의 지표로 지정
- 네임 스페이스는 영문, 숫자, 공백, 특수문자(
_-/)를 포함하여 3~128자로 작성해야하며, 영문으로 시작해야 합니다.
accessKey IAM 인증키 Access Key accessSecret IAM 인증키 Secret Key resourceId 서버의 Samsung Cloud Platform에서의 자원 ID - 예시: Virtual Server의 자원 ID
openApiEndpoint 리전/오퍼링별 ServiceWatch OpenAPI Endpoint - 예시: https://servicewatch.
region.offering.samsungsdscloud.com
region과offering정보는 Samsung Cloud Platform Console 접속 URL에서 확인 가능
telemetryPort ServiceWatch Agent의 Telemetry Port - 보통 8888 Port로 사용. 8888 Port가 사용 중인 경우 변경 필요
표. agent.json 설정 파일 항목배경색 변경{ "namespace": "swagent-windows", # 사용자 정의 지표를 위한 사용자 정의 네임 스페이스 "accessKey": "testKey", # IAM 인증키 Access Key "accessSecret": "testSecret", # IAM 인증키 Secret Key "resourceId": "resourceID", # 서버의 Samsung Cloud Platform에서의 자원 ID "openApiEndpoint": "https://servicewatch.kr-west1.e.samsungsdscloud.com", # 리전/환경별 ServiceWatch OpenAPI Endpoint "telemetryPort": 8889 # ServiceWatch Agent의 Telemetry Port (보통 8888 Port로 사용. 8888 Port가 사용 중인 경우 변경 필요) }{ "namespace": "swagent-windows", # 사용자 정의 지표를 위한 사용자 정의 네임 스페이스 "accessKey": "testKey", # IAM 인증키 Access Key "accessSecret": "testSecret", # IAM 인증키 Secret Key "resourceId": "resourceID", # 서버의 Samsung Cloud Platform에서의 자원 ID "openApiEndpoint": "https://servicewatch.kr-west1.e.samsungsdscloud.com", # 리전/환경별 ServiceWatch OpenAPI Endpoint "telemetryPort": 8889 # ServiceWatch Agent의 Telemetry Port (보통 8888 Port로 사용. 8888 Port가 사용 중인 경우 변경 필요) }코드블록. agent.json 설정 예시 ServiceWatch용 지표 수집을 위한 Metric 설정 파일을 정의합니다.
- Agent를 통해 지표 수집하고자 하는 경우 metric.json을 설정합니다.
구분 상세 설명 prometheus > scrape_configs > targets 지표 수집 대상의 Endpoint - 서버의 경우 같은 서버에 Prometheus Exporter 설치하므로 해당 endpoint로 설정
- 예시: localhost:9100
prometheus > scrape_configs > jobName Job Name 설정. 보통 지표 수집 시 사용하는 Prometheus Exporter 종류로 설정 - 예시: node-exporter
metricMetas > metricName 수집하고자 하는 지표 이름 설정. 지표명은 영문, 숫자, 특수문자( _)를 포함하여 3~128자로 작성해야하며, 영문으로 시작해야 합니다.- 예시: node_cpu_seconds_total
metricMetas > dimensions Exporter의 지표 데이터의 출처를 식별하기 위해 제공하는 Collector의 레이블 중 Console에 시각화하여 보여주기 위한 레이블을 설정. 수집한 지표를 Console에 시각화하여 보여줄 때, 차원(dimensions) 설정에 따라 조합하여 표시. - 예시: Node Exporter의 Memory Collector의 지표와 같이 특별한 레이블을 제공하지 않는 경우에는 resource_id로 설정
- 예시: Node Exporter의 Filesystem Collector 지표는 파일시스템이 시스템상에 마운트된 경로를 나타내는 mountpoint로 차원(dimensions) 설정할 수 있음
metricMetas > unit 지표의 단위 설정 가능 - 예시: Bytes, Count 등
metricMetas > aggregationMethod 지정한 차원(dimensions) 기준으로 집계하는 방법 - 예시: SUM, MAX, MIN, COUNT 중 선택
metricMetas > descriptionKo 수집하는 지표에 대한 국문 설명 metricMetas > descriptionEn 수집하는 지표에 대한 영문 설명 표. metric.json 설정 파일 항목배경색 변경{ "prometheus": { "scrape_configs": { "targets": [ "localhost:9100" # 서버 내 설치한 Prometheus Exporter의 Endpoint ], "jobName": "node-exporter" # 보통 설치한 Exporter의 이름으로 설정 } }, "metricMetas": [ { "metricName": "node_memory_MemTotal_bytes", # Prometheus Exporter로부터 수집되는 지표 중 ServiceWatch로 연계하고자 하는 지표명 설정 "dimensions": [ [ "resource_id" # Node Exporter의 지표 데이터의 출처를 식별하기 위해 제공하는 Collector의 레이블 중 Console에 시각화하여 보여주기 위한 레이블을 설정 # 해당 Memory 관련 지표와 같이 특별한 레이블을 제공하지 않는 경우에는 resource_id로 설정 ] ], "unit": "bytes", # 수집 지표 데이터의 단위 "aggregationMethod": "SUM", # 집계 방법 "descriptionKo": "서버의 총 물리적 메모리 크기", # 지표의 국문 설명 "descriptionEn": "node memory total bytes" # 지표의 영문 설명 }, { "metricName": "node_filesystem_size_bytes", # Prometheus Exporter로부터 수집되는 지표 중 ServiceWatch로 연계하고자 하는 지표명 설정 "dimensions": [ [ "mountpoint" # Node Exporter의 지표 데이터의 출처를 식별하기 위해 제공하는 Collector의 레이블 중 Console에 시각화하여 보여주기 위한 레이블을 설정 # 해당 Filesystem 관련 지표의 파일시스템이 시스템상에 마운트된 경로를 나타내는 mountpoint로 차원(dimensions) 설정 ] ], "unit": "bytes", "aggregationMethod": "SUM", "descriptionKo": "node filesystem size bytes", "descriptionEn": "node filesystem size bytes" }, { "metricName": "node_memory_MemAvailable_bytes", "dimensions": [ [ "resource_id" ] ], "unit": "bytes", "aggregationMethod": "SUM", "descriptionKo": "node memory available bytes", "descriptionEn": "node memory available bytes" }, { "metricName": "node_filesystem_avail_bytes", "dimensions": [ [ "mountpoint" ] ], "unit": "bytes", "aggregationMethod": "SUM", "descriptionKo": "node filesystem available bytes", "descriptionEn": "node filesystem available bytes" } ] }{ "prometheus": { "scrape_configs": { "targets": [ "localhost:9100" # 서버 내 설치한 Prometheus Exporter의 Endpoint ], "jobName": "node-exporter" # 보통 설치한 Exporter의 이름으로 설정 } }, "metricMetas": [ { "metricName": "node_memory_MemTotal_bytes", # Prometheus Exporter로부터 수집되는 지표 중 ServiceWatch로 연계하고자 하는 지표명 설정 "dimensions": [ [ "resource_id" # Node Exporter의 지표 데이터의 출처를 식별하기 위해 제공하는 Collector의 레이블 중 Console에 시각화하여 보여주기 위한 레이블을 설정 # 해당 Memory 관련 지표와 같이 특별한 레이블을 제공하지 않는 경우에는 resource_id로 설정 ] ], "unit": "bytes", # 수집 지표 데이터의 단위 "aggregationMethod": "SUM", # 집계 방법 "descriptionKo": "서버의 총 물리적 메모리 크기", # 지표의 국문 설명 "descriptionEn": "node memory total bytes" # 지표의 영문 설명 }, { "metricName": "node_filesystem_size_bytes", # Prometheus Exporter로부터 수집되는 지표 중 ServiceWatch로 연계하고자 하는 지표명 설정 "dimensions": [ [ "mountpoint" # Node Exporter의 지표 데이터의 출처를 식별하기 위해 제공하는 Collector의 레이블 중 Console에 시각화하여 보여주기 위한 레이블을 설정 # 해당 Filesystem 관련 지표의 파일시스템이 시스템상에 마운트된 경로를 나타내는 mountpoint로 차원(dimensions) 설정 ] ], "unit": "bytes", "aggregationMethod": "SUM", "descriptionKo": "node filesystem size bytes", "descriptionEn": "node filesystem size bytes" }, { "metricName": "node_memory_MemAvailable_bytes", "dimensions": [ [ "resource_id" ] ], "unit": "bytes", "aggregationMethod": "SUM", "descriptionKo": "node memory available bytes", "descriptionEn": "node memory available bytes" }, { "metricName": "node_filesystem_avail_bytes", "dimensions": [ [ "mountpoint" ] ], "unit": "bytes", "aggregationMethod": "SUM", "descriptionKo": "node filesystem available bytes", "descriptionEn": "node filesystem available bytes" } ] }코드블록. metric.json 설정 예시
- Agent를 통해 지표 수집하고자 하는 경우 metric.json을 설정합니다.
ServiceWatch용 로그 수집을 위한 Log 설정 파일을 정의합니다.
- 로그 수집을 하고자 하는 경우 log.json 설정을 해야합니다.
구분 상세 설명 fileLog > include 수집할 로그 파일 위치 fileLog > operators 수집할 로그 메시지를 파싱하기 위해 정의 fileLog > operators > regex 로그 메시지 형식을 정규식으로 표현 fileLog > operators > timestamp ServiceWatch로 전송될 로그 메시지의 Time Stamp의 형식 logMetas > log_group_value ServiceWatch로 로그 전송을 위해 생성한 로그 그룹 이름 logMetas > log_stream_value ServiceWatch 로그 그룹내 로그 스트림 이름 표. log.json 설정 파일 항목배경색 변경{ "fileLog": { "include": [ "/var/log/syslog", # ServiceWatch로 수집할 로그 파일 "/var/log/auth.log" ], "operators": { "regex": "^(?P<timestamp>\\S+)\\s+(?P<hostname>\\S+)\\s+(?P<process>[^:]+):\\s+(?P<message>.*)$", # 로그 파일 형식을 정규식으로 표현 "timestamp": { # 로그 메시지의 Time Stamp 형식 설정정 "layout_type": "gotime", "layout": "2006-01-02T15:04:05.000000Z07:00" } } }, "logMetas": { "log_group_value": "custom-log-group", # 사전에 생성한 ServiceWatch의 로그 그룹명 "log_stream_value": "custom-log-stream" # 사전에 생성한 SerivceWatch 로그 그룹 내의 로그 스트림명 } }{ "fileLog": { "include": [ "/var/log/syslog", # ServiceWatch로 수집할 로그 파일 "/var/log/auth.log" ], "operators": { "regex": "^(?P<timestamp>\\S+)\\s+(?P<hostname>\\S+)\\s+(?P<process>[^:]+):\\s+(?P<message>.*)$", # 로그 파일 형식을 정규식으로 표현 "timestamp": { # 로그 메시지의 Time Stamp 형식 설정정 "layout_type": "gotime", "layout": "2006-01-02T15:04:05.000000Z07:00" } } }, "logMetas": { "log_group_value": "custom-log-group", # 사전에 생성한 ServiceWatch의 로그 그룹명 "log_stream_value": "custom-log-stream" # 사전에 생성한 SerivceWatch 로그 그룹 내의 로그 스트림명 } }코드블록. log.json 설정 예시
- 로그 수집을 하고자 하는 경우 log.json 설정을 해야합니다.
ServiceWatch Agent를 통해 서버의 로그 파일을 ServiceWatch에 연계하기 위해서는 로그 그룹과 로그 그룹 내 로그 스트림을 먼저 생성해야합니다.
- 로그 그룹 생성 및 로그 스트림 생성에 대한 자세한 내용은 로그를 참고하세요.
ServiceWatch를 위한 Open Telemetry Collector 실행
| 실행 옵션션 | 상세 설명 |
|---|---|
-action | 액션 설정 (run 또는 stop) |
-dir | agent.json, metric.json, log.json 과 같은 ServiceWatch Agent 설정 파일 위치 |
-collector | Open Telemetry Collector 실행파일 위치 |
ServiceWatch Agent 실행 (for Linux)
agent.json, metric.json, log.json 파일이 현재위치/agent/examples/os-metrics-min-examples에 있고, otelcontribcol_linux_amd64 파일은 현재위치/agent 에 있다고 가정했을 때 아래와 같이 실행합니다.ServiceWatch Agent를 실행합니다.
agent.json,metric.json,log.json파일 위치와servicewatch-agent-manager-linux-amd64,otelcontribcol_linux_amd64파일의 위치를 확인하여 ServiceWatch Agent를 시작합니다.배경색 변경./agent/servicewatch-agent-manager-linux-amd64 -action run -dir ./agent/examples/os-metrics-min-examples -collector ./agent/otelcontribcol_linux_amd64./agent/servicewatch-agent-manager-linux-amd64 -action run -dir ./agent/examples/os-metrics-min-examples -collector ./agent/otelcontribcol_linux_amd64코드블록. ServiceWatch Agent 시작 - 지표/로그 모두 수집 - 지표만 수집하고자 하는 경우,
log.json파일을 다른 파일명으로 변경하거나agent.json,metric.json과 같은 디렉토리에 있지 않도록 옮기고, 아래와 같이 실행해주세요.배경색 변경./agent/servicewatch-agent-manager-linux-amd64 -action run -dir ./agent/examples/os-metrics-min-examples -collector ./agent/otelcontribcol_linux_amd64./agent/servicewatch-agent-manager-linux-amd64 -action run -dir ./agent/examples/os-metrics-min-examples -collector ./agent/otelcontribcol_linux_amd64코드블록. ServiceWatch Agent 시작 - 지표만 수집 - 로그만 수집하고자 하는 경우,
metric.json파일을 다른 파일명으로 변경하거나agent.json,log.json과 같은 디렉토리에 있지 않도록 옮기고, 아래와 같이 실행해주세요.배경색 변경./agent/servicewatch-agent-manager-linux-amd64 -action run -dir ./agent/examples/os-metrics-min-examples -collector ./agent/otelcontribcol_linux_amd64./agent/servicewatch-agent-manager-linux-amd64 -action run -dir ./agent/examples/os-metrics-min-examples -collector ./agent/otelcontribcol_linux_amd64코드블록. ServiceWatch Agent 시작 - 로그만 수집
ServiceWatch Agent를 중지합니다.
배경색 변경./agent/servicewatch-agent-manager-linux-amd64 -action stop -dir ./agent/examples/os-metrics-min-examples./agent/servicewatch-agent-manager-linux-amd64 -action stop -dir ./agent/examples/os-metrics-min-examples코드블록. ServiceWatch Agent 중지
ServiceWatch Agent 실행 (for Windows)
ServiceWatch Agent를 실행합니다.
배경색 변경servicewatch-agent-manager-windows-amd64.exe -action run -dir ./examples -collector otelcontribcol_windows_amd64.exeservicewatch-agent-manager-windows-amd64.exe -action run -dir ./examples -collector otelcontribcol_windows_amd64.exe코드블록. ServiceWatch Agent 시작 ServiceWatch Agent를 중지합니다.
배경색 변경servicewatch-agent-manager-windows-amd64.exe -action stop -dir ./examplesservicewatch-agent-manager-windows-amd64.exe -action stop -dir ./examples코드블록. ServiceWatch Agent 중지