ServiceWatch Agent 사용하기

사용자는 Virtual Server/GPU Server/Bare Metal Server 등에서 ServiceWatch Agent를 설치하여 사용자 정의 지표와 로그를 수집할 수 있습니다.

참고
ServiceWatch Agent를 통한 사용자 정의 지표/로그 수집은 현재 Samsung Cloud Platform For Enterprise에서만 사용 가능합니다. 이외 오퍼링에서도 향후 제공 예정입니다.
주의
ServiceWatch Agent를 통한 지표 수집은 사용자 정의 지표로 구분되어 각 서비스로부터 기본으로 수집되는 지표와는 달리 요금이 부과되므로, 불필요한 메트릭 수집 설정을 하지 않도록 주의해야 합니다. 반드시 수집이 필요한 지표만 수집될 수 있도록 설정하세요.

ServiceWatch Agent

서버에 ServiceWatch의 사용자 정의 지표 및 로그 수집을 위해 설치해야 하는 Agent는 크게 2가지로 나눌 수 있습니다. Prometheus Exporter와 Open Telemetry Collector 입니다.

구분상세 설명
Prometheus Exporter특정 애플리케이션이나 서비스의 메트릭을 Prometheus가 스크랩(scrape)할 수 있는 형식으로 제공
  • 서버의 OS 지표 수집을 위해서 OS 타입에 따라 Linux 서버를 위한 Node Exporter와 Windows 서버를 위한 Windows Exporter를 사용할 수 있음.
    • 대상
      • Virtual Server
      • GPU Server
      • Bare Metal Server
      • Multi-node GPU Cluster > GPU Node
  • GPU 지표를 위한 DCGM(NVIDIA Data Center GPU Manager) Exporter를 사용할 수 있음.
    • 대상
      • GPU Server
      • Multi-node GPU Cluster > GPU Node
Open Telemetry Collector분산 시스템의 메트릭, 로그와 같은 텔레메트리 데이터를 수집하고, 처리(필터링, 샘플링 등)한 후, 여러 백엔드(예: Prometheus, Jaeger, Elasticsearch 등)로 내보내는 중앙 집중식 수집기 역할
  • ServiceWatch Gateway로 데이터를 내보내어 ServiceWatch에서 지표 및 로그 데이터를 수집할 수 있도록 함.
  • 해당 가이드에서는 ServiceWatch에서 제공하는 Open Telemetry Collector 사용 방법에 대해 안내
표. Prometheus Exporter와 Open Telemetry Collector 설명
참고

ServiceWatch Agent를 통해 서버의 로그 파일을 ServiceWatch에 연계하기 위해서는 로그 그룹과 로그 그룹 내 로그 스트림을 먼저 생성해야합니다.

  • 로그 그룹 생성 및 로그 스트림 생성에 대한 자세한 내용은 로그를 참고하세요.

ServiceWatch를 위한 Open Telemetry Collector 사전 설정

서버에서 ServiceWatch 지표와 로그 수집을 위한 Open Telemetry Collector를 사용하기 위해 아래의 순서에 따라 설치합니다.

  1. ServiceWatch를 위한 Agent 파일을 다운로드 받을 수 있는 URL로 부터 Agent 파일을 다운로드 받습니다.
안내
ServiceWatch를 위한 Agent 설치를 위한 파일 다운로드 링크는 Samsung Cloud Platform Console 공지 사항과 Support Center > 문의하기를 통해 안내해드리겠습니다.
배경색 변경
wget [ServiceWatch Agent 파일 다운로드 URL]
wget [ServiceWatch Agent 파일 다운로드 URL]
코드블록. ServiceWatch를 위한 Agent 설치 파일 다운로드 명령어
  1. ServiceWatch를 위한 Open Telemetry Collector Agent 파일은 아래와 같이 확인할 수 있습니다.
    • ServiceWatch를 위한 Agent 파일을 압축 해제합니다.
      배경색 변경
      unzip ServiceWatch_Agent.zip
      unzip ServiceWatch_Agent.zip
      코드블록. ServiceWatch를 위한 Agent 파일 압축 해제
    • ServiceWatch Agent를 사용하는 환경이 Linux OS인 경우, 아래와 같이 실행 권한을 부여해야합니다.
      배경색 변경
      chmod +x agent/otelcontribcol_linux_amd64
      chmod +x agent/servicewatch-agent-manager-linux-amd64
      chmod +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_amd64ServiceWatch용 Open Telemetry Collector for Linux
      otelcontribcol_windows_amd64.exeServiceWatch용 Open Telemetry Collector for Windows
      servicewatch-agent-manager-linux-amd64ServiceWatch Agent Manager for Linux
      servicewatch-agent-manager-windows-amd64.exeServiceWatch Agent Manager for Windows
      표. ServiceWatch를 위한 Agent 파일 구성
참고
ServiceWatch Agent Manager는 ServiceWatch와 연동되어 사용자 정의 지표와 로그를 효율적으로 전송하기 위해 Open Telemetry Collector 설정을 도와주는 도구입니다. 이를 통해 다양한 사용자 정의 지표와 로그 데이터를 ServiceWatch로 전달할 수 있습니다.
  1. ServiceWatch용 Open Telemetry Collector를 위해 ServiceWatch Agent Manager의 Agent 설정 파일을 정의합니다.

    구분상세 설명
    namespace사용자 정의 지표를 위한 사용자 정의 네임 스페이스
    • 네임스페이스는 지표를 구분하고 그룹화하기 위한 논리적인 구분으로 사용자 정의 지표를 구분하기 위한 사용자 정의 지표로 지정
    • 네임 스페이스는 영문, 숫자, 공백, 특수문자(_-/)를 포함하여 3~128자로 작성해야하며, 영문으로 시작해야 합니다.
    accessKeyIAM 인증키 Access Key
    accessSecretIAM 인증키 Secret Key
    resourceId서버의 Samsung Cloud Platform에서의 자원 ID
    • 예시: Virtual Server의 자원 ID
    openApiEndpoint리전/오퍼링별 ServiceWatch OpenAPI Endpoint
    • 예시: https://servicewatch.region.offering.samsungsdscloud.com
    • regionoffering 정보는 Samsung Cloud Platform Console 접속 URL에서 확인 가능
    telemetryPortServiceWatch 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 설정 예시

  2. ServiceWatch용 지표 수집을 위한 Metric 설정 파일을 정의합니다.

    • Agent를 통해 지표 수집하고자 하는 경우 metric.json을 설정합니다.
      구분상세 설명
      prometheus > scrape_configs > targets지표 수집 대상의 Endpoint
      • 서버의 경우 같은 서버에 Prometheus Exporter 설치하므로 해당 endpoint로 설정
      • 예시: localhost:9100
      prometheus > scrape_configs > jobNameJob Name 설정. 보통 지표 수집 시 사용하는 Prometheus Exporter 종류로 설정
      • 예시: node-exporter
      metricMetas > metricName수집하고자 하는 지표 이름 설정. 지표명은 영문, 숫자, 특수문자(_)를 포함하여 3~128자로 작성해야하며, 영문으로 시작해야 합니다.
      • 예시: node_cpu_seconds_total
      metricMetas > dimensionsExporter의 지표 데이터의 출처를 식별하기 위해 제공하는 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 설정 예시
  3. ServiceWatch용 로그 수집을 위한 Log 설정 파일을 정의합니다.

    • 로그 수집을 하고자 하는 경우 log.json 설정을 해야합니다.
      구분상세 설명
      fileLog > include수집할 로그 파일 위치
      fileLog > operators수집할 로그 메시지를 파싱하기 위해 정의
      fileLog > operators > regex로그 메시지 형식을 정규식으로 표현
      fileLog > operators > timestampServiceWatch로 전송될 로그 메시지의 Time Stamp의 형식
      logMetas > log_group_valueServiceWatch로 로그 전송을 위해 생성한 로그 그룹 이름
      logMetas > log_stream_valueServiceWatch 로그 그룹내 로그 스트림 이름
      표. 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 설정 예시
참고

ServiceWatch Agent를 통해 서버의 로그 파일을 ServiceWatch에 연계하기 위해서는 로그 그룹과 로그 그룹 내 로그 스트림을 먼저 생성해야합니다.

  • 로그 그룹 생성 및 로그 스트림 생성에 대한 자세한 내용은 로그를 참고하세요.

ServiceWatch를 위한 Open Telemetry Collector 실행

ServiceWatch Agent 실행 방법
[SerivceWatch Agent 실행파일] -action [run|stop] - dir [설정파일 위치] -collector [Open Telemetry Collector 실행파일 위치]
실행 옵션션상세 설명
-action액션 설정 (run 또는 stop)
-diragent.json, metric.json, log.json 과 같은 ServiceWatch Agent 설정 파일 위치
-collectorOpen Telemetry Collector 실행파일 위치
표. log.json 설정 파일 항목

ServiceWatch Agent 실행 (for Linux)

참고
agent.json, metric.json, log.json 파일이 현재위치/agent/examples/os-metrics-min-examples에 있고, otelcontribcol_linux_amd64 파일은 현재위치/agent 에 있다고 가정했을 때 아래와 같이 실행합니다.
  1. 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 시작 - 로그만 수집
  2. 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)

  1. ServiceWatch Agent를 실행합니다.

    배경색 변경
    servicewatch-agent-manager-windows-amd64.exe -action run -dir ./examples -collector otelcontribcol_windows_amd64.exe
    servicewatch-agent-manager-windows-amd64.exe -action run -dir ./examples -collector otelcontribcol_windows_amd64.exe
    코드블록. ServiceWatch Agent 시작

  2. ServiceWatch Agent를 중지합니다.

    배경색 변경
    servicewatch-agent-manager-windows-amd64.exe -action stop -dir ./examples
    servicewatch-agent-manager-windows-amd64.exe -action stop -dir ./examples
    코드블록. ServiceWatch Agent 중지

이벤트
ServiceWatch Event Reference