콘텐츠로 이동

서비스 데이터 소스 정의 및 DQL 쿼리

서비스 성능 데이터 소스 정의

TM 인덱스 공간에는 서비스 목록 및 성능 메트릭 관련 데이터가 저장됩니다. APM > 성능 메트릭의 데이터는 주로 이 인덱스 공간에서 조회됩니다. TM은 각 서비스에 대해 분, 시간, 일의 세 가지 세분화 수준으로 서비스 메트릭 데이터를 집계하여 데이터 쿼리 효율성을 향상시킵니다.

예를 들어 2024-03-19 15:00:00 ~ 2024-03-19 15:15:00 15분 동안의 모든 서비스 메트릭 데이터를 조회하려면 다음 DQL을 사용할 수 있습니다.

TM::`*`:(){source="service_list_1m"} [1710831600000:1710832500000]

다음과 유사한 결과가 반환됩니다.

쿼리 결과 예시
[
  {
    "time": 1710835681000,
    "time_us": 1710835681000000,
    "__docid": "T_cnskg71jdosvib6m44s0",
    "__source": "service_list_1m",
    "source": "service_list_1m",
    "__namespace": "tracing",
    "r_env": "demo",
    "r_error_count": 0,
    "r_max_duration": 2293857,
    "r_psketch": "Av1KgVq/UvA/AAAAAAAAAAAJAbgL",
    "r_request_count": 1,
    "r_resp_time": 2293857,
    "r_service": "go-profiling-demo-1",
    "r_service_sub": "go-profiling-demo-1:demo:v0.8.888",
    "r_type": "custom",
    "r_version": "v0.8.888",
    "create_time": 1710835740447,
    "date": 1710835681000,
    "date_ns": 0
  },
  {
    "time": 1710835201000,
    "time_us": 1710835201000000,
    "__docid": "T_cnskcf9jdosvib6jl4kg",
    "__source": "service_list_1m",
    "source": "service_list_1m",
    "__namespace": "tracing",
    "r_env": "demo",
    "r_error_count": 0,
    "r_max_duration": 2370648,
    "r_psketch": "Av1KgVq/UvA/AAAAAAAAAAAJAboL",
    "r_request_count": 1,
    "r_resp_time": 2370648,
    "r_service": "go-profiling-demo-1",
    "r_service_sub": "go-profiling-demo-1:demo:v0.8.888",
    "r_type": "custom",
    "r_version": "v0.8.888",
    "create_time": 1710835261477,
    "date": 1710835201000,
    "date_ns": 0
  }
]

주요 필드 설명은 다음과 같습니다.

필드 유형 설명
source string 데이터 집계 세분화 수준, 구분:
  • 분별(source="service_list_1m")
  • 시간별(source="service_list_1h")
  • 일별(source="service_list_1d")
  • r_env string 서비스 배포 환경
    r_error_count int 서비스 오류 횟수
    r_max_duration int 시간 세분화 내 최대 응답 시간, 단위: 마이크로초
    r_request_count int 요청 횟수
    r_resp_time int 시간 세분화 내 집계된 응답 시간 합계
    r_service string 서비스 이름
    r_service_sub string <서비스 이름>:<배포 환경>:<서비스 버전>
    r_type string 서비스 유형, http/web/db/gateway...
    r_version string 서비스 버전
    date int 밀리초 타임스탬프, 해당:
  • 분의 0초(hh:mm:00, source="service_list_1m"인 경우)
  • 시의 0분(hh:00, source="service_list_1h"인 경우)
  • 일의 0시(00:00:00, source="service_list_1d"인 경우)
  • 마찬가지로 2024-03-19 15:00:00 ~ 2024-03-19 17:00:00 두 시간의 데이터를 조회하려면 다음 DQL을 사용할 수 있습니다.

    TM::`*`:(){source="service_list_1h"} [1710831600000:1710838800000]
    

    2024-03-19 00:00:00 ~ 2024-03-21 00:00:00 이틀간의 데이터를 조회하려면 다음 DQL을 사용할 수 있습니다.

    TM::`*`:(){source="service_list_1d"} [1710777600000:1710950400000]
    

    시간 세분화 수준을 조합하여 사용할 수 있습니다. 예를 들어 2024-03-19 15:00:00 ~ 2024-03-19 17:30:00 2시간 30분 동안의 데이터를 조회하려면 다음 DQL을 사용할 수 있습니다.

    TM::`*`:(){ (source="service_list_1h" and date >= 1710831600000 and date < 1710838800000) or (source="service_list_1m" and date >= 1710838800000 and date <= 1710840600000) }
    
    Abstract

    물론 분 단위 source="service_list_1m"만 사용하여 2024-03-19 15:00:00 ~ 2024-03-19 17:30:00와 같이 시간 또는 일을 넘나드는 시간 범위의 데이터를 쿼리할 수도 있지만, 쿼리 효율이 크게 저하되고 반환되는 데이터 양도 기하급수적으로 증가하므로 이러한 방식의 쿼리는 권장하지 않습니다.

    쿼리 결과를 추가 가공하면 관련 서비스 수준의 메트릭을 계산할 수 있습니다. 예를 들면 다음과 같습니다.

    total_count = SUM(r_request_count)
    error_count = SUM(r_error_count)
    error_rate = SUM(r_error_count) / SUM(r_request_count)
    max_duration = MAX(r_max_duration)
    sum_resp_time = SUM(r_resp_time)
    avg_per_second = SUM(r_request_count) / <쿼리 시간 범위>
    avg_resp_time = SUM(r_resp_time) / SUM(r_request_count)
    p50: 생성 배열 [(r_resp_time1/r_request_count1)...{r_request_count1번 반복}, (r_resp_time2/r_request_count2)...{r_request_count2번 반복}, (r_resp_time3/r_request_count3)...{r_request_count3번 반복}, ...], 배열 정렬 후 인덱스 SUM(r_request_count)*0.5
    

    예를 들어 각 서비스의 특정 시간 범위 내 QPS (초당 요청 수)를 조회하려면 다음을 사용할 수 있습니다.

    TM::`*`:(r_service, sum(r_request_count) / (1737099000000 - 1737093600000) * 1000 as QPS){ (source="service_list_1h" and date >= 1737093600000 and date < 1737097200000) or (source="service_list_1m" and date >= 1737097200000 and date <= 1737099000000) } by r_service
    

    서비스 토폴로지 데이터 소스 정의

    TSM 인덱스 공간에는 주로 서비스 간 호출 토폴로지 관계 데이터가 저장되며, 분 단위로 데이터가 사전 집계되었습니다. 예를 들어 2024-03-19 15:00:00 ~ 2024-03-19 15:15:00 15분 범위의 모든 서비스 호출 관계를 조회하려면 다음 DQL을 사용할 수 있습니다.

    TSM::`*`:(){} [1710831600000:1710832500000]
    

    다음과 유사한 쿼리 결과가 반환됩니다.

    쿼리 결과 예시
    [
        {
            "time": 1710835700438,
            "time_us": 1710835700438064,
            "__docid": "6340252d-331c-6e1dd9338-0ed04e818c4d",
            "__source": "relationship",
            "source_service": "go-profiling-demo-1",
            "source_wsuuid": "wksp_8d351d83bdf14b8b8270ab75fe29a990",
            "source_env": "demo",
            "source_project": "",
            "source_version": "v0.8.888",
            "source_type": "custom",
            "source_organization": "",
            "source_status": "ok",
            "source_start": 1710835700059433,
            "source_duration": 220210272,
            "target_service": "go-profiling-demo-2",
            "target_wsuuid": "wksp_8d351d83bdf14b8b8270ab75fe29a990",
            "target_env": "demo",
            "target_project": "",
            "target_version": "v0.8.888",
            "target_type": "custom",
            "target_organization": "",
            "target_status": "ok",
            "target_start": 1710835700438064,
            "target_duration": 886040,
            "count": 96,
            "unique_id": "XTzHH-jScNjXgBSXNIdFcSOVpHwWKyAZroh71ttyPnXK9nl3jW0re0hlKOeHj6PYgo-profiling-demo-1go-profiling-demo-2",
            "unique_id_env_version": "Zp-9KKvEb4m9aU0OeUMon8MiH2isxqXU742YFlVtokgL2Vy73NwtykkG3vA3X0z1go-profiling-demo-1go-profiling-demo-2",
            "error_count": 0
        },
        {
            "time": 1710835243699,
            "time_us": 1710835243699376,
            "__docid": "f4c7de67-ca1b-6e17fd78e-e8bcb4d1d64d",
            "__source": "relationship",
            "source_service": "go-profiling-demo-1",
            "source_wsuuid": "wksp_8d351d83bdf14b8b8270ab75fe29a990",
            "source_env": "demo",
            "source_project": "",
            "source_version": "v0.8.888",
            "source_type": "custom",
            "source_organization": "",
            "source_status": "ok",
            "source_start": 1710835243379392,
            "source_duration": 227582208,
            "target_service": "go-profiling-demo-2",
            "target_wsuuid": "wksp_8d351d83bdf14b8b8270ab75fe29a990",
            "target_env": "demo",
            "target_project": "",
            "target_version": "v0.8.888",
            "target_type": "custom",
            "target_organization": "",
            "target_status": "ok",
            "target_start": 1710835243699376,
            "target_duration": 856217,
            "count": 96,
            "unique_id": "XTzHH-jScNjXgBSXNIdFcSOVpHwWKyAZroh71ttyPnXK9nl3jW0re0hlKOeHj6PYgo-profiling-demo-1go-profiling-demo-2",
            "unique_id_env_version": "Zp-9KKvEb4m9aU0OeUMon8MiH2isxqXU742YFlVtokgL2Vy73NwtykkG3vA3X0z1go-profiling-demo-1go-profiling-demo-2",
            "error_count": 0
        }
    ]
    

    주요 필드 설명은 다음과 같습니다.

    필드 유형 설명
    time int 밀리초 타임스탬프, 서비스 호출이 발생한 시간
    time_us int 서비스 호출이 발생한 시간, 마이크로초 단위
    source_service string 호출 서비스 이름
    source_wsuuid string 호출 서비스의 리포팅 워크스페이스 ID
    source_env string 호출 서비스 배포 환경
    source_project string 호출 서비스 프로젝트 이름
    source_version string 호출 서비스 버전
    source_type string 호출 서비스 유형
    source_organization string 호출 서비스의 리포팅 워크스페이스가 속한 조직
    source_status string 호출 서비스 상태, ok/error
    source_start int 호출 서비스 Span 시작 시간, 마이크로초 타임스탬프
    source_duration int 분당 호출 서비스 Span 지속 시간 합계, 단위: 마이크로초
    target_service string 피호출 서비스 이름
    target_wsuuid string 피호출 서비스의 리포팅 워크스페이스 ID
    target_env string 피호출 서비스 배포 환경
    target_project string 피호출 서비스 프로젝트 이름
    target_version string 피호출 서비스 버전
    target_type string 피호출 서비스 유형
    target_organization string 피호출 서비스의 리포팅 워크스페이스가 속한 조직
    target_status string 피호출 서비스 상태, ok/error
    target_start int 피호출 서비스 Span 시작 시간 (서비스 호출이 발생한 시간), 마이크로초 타임스탬프
    target_duration int 분당 피호출 서비스 Span 지속 시간 합계, 단위: 마이크로초
    count int 분당 호출 횟수
    unique_id string 호출 서비스 이름과 피호출 서비스 이름만으로 생성된 고유 ID
    unique_id_env_version int 호출 서비스, 환경, 버전과 피호출 서비스, 환경, 버전을 구분하여 생성된 고유 ID
    error_count int 분당 호출 실패 횟수

    서비스 호출 관계 및 서비스 호출 수준 메트릭의 경우, 예를 들어 다음 DQL을 사용하여 서비스 간 호출 관계를 조회할 수 있습니다.

    TSM::`*`:(first(source_service) as source_service,
    first(source_wsuuid) as source_wsuuid,
    first(target_service) as target_service,
    first(target_wsuuid) as target_wsuuid,
    sum(count) as total_count,
    sum(error_count) as total_error_count,
    sum(target_duration) as total_duration
    ){} by unique_id
    

    문서 평가

    이 페이지가 도움이 되었나요?