SQL 기반 수집을 위해 수집 스펙 변환하기

SQL 기반 수집을 위해 수집 스펙 변환하기 (Convert an ingestion spec for SQL-based ingestion)

Druid 24.0에 새로 추가된 druid-multi-stage-query 확장 프로그램을 사용하는 SQL 기반 배치 수집을 설명하는 페이지예요. 웹 콘솔을 이용하면 기존의 네이티브 배치 수집 스펙을 멀티-스테이지 쿼리(MSQ) 태스크 엔진이 데이터 수집에 사용할 수 있는 SQL 쿼리로 변환할 수 있어요.

출처: 문서

본문

어떤 수집 방법이 적합한지 결정하려면 수집 방법 (ingestion methods) 표를 참고해 주세요.

이미 네이티브 배치 수집 (native batch ingestion)으로 데이터를 수집하고 있다면, 웹 콘솔을 사용해 수집 스펙을 멀티-스테이지 쿼리 태스크 엔진이 데이터를 수집하는 데 사용할 수 있는 SQL 쿼리로 변환할 수 있어요.

이 튜토리얼은 웹 콘솔에서 수집 스펙을 쿼리 태스크로 변환하는 방법을 보여 줘요.

수집 스펙을 쿼리 태스크로 변환하려면 다음을 수행해 주세요:

  • 웹 콘솔의 Query 뷰에서 Run 을 포함한 메뉴 바로 이동해 주세요.

  • 말줄임표 아이콘을 클릭하고 Convert ingestion spec to SQL 을 선택해 주세요.

  • Ingestion spec to convert 창에 수집 스펙을 넣어 주세요. 직접 만든 스펙이나 튜토리얼에서 제공하는 샘플 수집 스펙을 사용할 수 있어요. 샘플 스펙은 https://druid.apache.org/data/wikipedia.json.gz 에 호스팅된 데이터를 사용해 wikipedia 라는 테이블에 로드해요:

    스펙 보기 (Show the spec)

    {
      "type" : "index_parallel",
      "spec" : {
        "ioConfig" : {
          "type" : "index_parallel",
          "inputSource" : {
            "type" : "http",
            "uris" : [ "https://druid.apache.org/data/wikipedia.json.gz" ]
          },
          "inputFormat" : {
            "type" : "json"
          }
        },
        "tuningConfig" : {
          "type" : "index_parallel",
          "partitionsSpec" : {
            "type" : "dynamic"
          }
        },
        "dataSchema" : {
          "dataSource" : "wikipedia",
          "timestampSpec" : {
            "column" : "timestamp",
            "format" : "iso"
          },
          "dimensionsSpec" : {
            "dimensions" : [
              "isRobot",
              "channel",
              "flags",
              "isUnpatrolled",
              "page",
              "diffUrl",
              { "type" : "long", "name" : "added" },
              "comment",
              { "type" : "long", "name" : "commentLength" },
              "isNew",
              "isMinor",
              { "type" : "long", "name" : "delta" },
              "isAnonymous",
              "user",
              { "type" : "long", "name" : "deltaBucket" },
              { "type" : "long", "name" : "deleted" },
              "namespace",
              "cityName",
              "countryName",
              "regionIsoCode",
              "metroCode",
              "countryIsoCode",
              "regionName"
            ]
          },
          "granularitySpec" : {
            "queryGranularity" : "none",
            "rollup" : false,
            "segmentGranularity" : "day"
          }
        }
      }
    }
    
  • Submit 을 클릭해 스펙을 제출해 주세요. 웹 콘솔은 JSON 기반 수집 스펙으로 대신 사용할 수 있는 SQL 쿼리를 생성해요. 샘플 수집 스펙에 대한 쿼리는 다음과 같아요:

    쿼리 보기 (Show the query)

    -- This SQL query was auto generated from an ingestion spec
    REPLACE INTO wikipedia OVERWRITE ALL
    WITH source AS ( SELECT * FROM TABLE ( EXTERN ( '{"type":"http","uris":["https://druid.apache.org/data/wikipedia.json.gz"]}' , '{"type":"json"}' , '[{"name":"timestamp","type":"string"},{"name":"isRobot","type":"string"},{"name":"channel","type":"string"},{"name":"flags","type":"string"},{"name":"isUnpatrolled","type":"string"},{"name":"page","type":"string"},{"name":"diffUrl","type":"string"},{"name":"added","type":"long"},{"name":"comment","type":"string"},{"name":"commentLength","type":"long"},{"name":"isNew","type":"string"},{"name":"isMinor","type":"string"},{"name":"delta","type":"long"},{"name":"isAnonymous","type":"string"},{"name":"user","type":"string"},{"name":"deltaBucket","type":"long"},{"name":"deleted","type":"long"},{"name":"namespace","type":"string"},{"name":"cityName","type":"string"},{"name":"countryName","type":"string"},{"name":"regionIsoCode","type":"string"},{"name":"metroCode","type":"string"},{"name":"countryIsoCode","type":"string"},{"name":"regionName","type":"string"}]' ) ) ) SELECT TIME_PARSE ( "timestamp" ) AS __time , "isRobot" , "channel" , "flags" , "isUnpatrolled" , "page" , "diffUrl" , "added" , "comment" , "commentLength" , "isNew" , "isMinor" , "delta" , "isAnonymous" , "user" , "deltaBucket" , "deleted" , "namespace" , "cityName" , "countryName" , "regionIsoCode" , "metroCode" , "countryIsoCode" , "regionName" FROM source PARTITIONED BY DAY
    
  • 생성된 SQL 쿼리를 검토해 요구 사항에 맞고 기대한 대로 동작하는지 확인해 주세요.

  • Run 을 클릭해 수집을 시작해 주세요.

더 알아보기 (Learn more)