Druid에 insert와 delete 하는 방식
1. Insert 하는 방식
Druid의 Insert는 spec과 raw data에 관한 JSON을 서버와 통신하며 이뤄진다.
JSON에는 데이터 JSON이 담긴 위치와 granularity, segment, dimension spec 등이 저장된다.
https://druid.apache.org/docs//0.15.1-incubating/ingestion/ingestion-spec.html
Druid | Ingestion Spec
Table of Contents <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership. The ASF licenses this
druid.apache.org
raw data는 new line으로 구분된 json이다. [다른 형태로도 가능하게 해놨는지는 잘 모르겠다]
spec에 관한 json과 raw data json이 준비됐다면,
curl -X 'POST' -H 'Content-Type:application/json' -d @{spec에관한JSON경로} http://{druid주소 및 포트}/druid/indexer/v1/task
형태로 insert 할 수 있다.
2. Delete 하는 방식
TSDB류의 특성상 DELETE는 까다로운 편이다
일단 __time의 Interval을 지정해 row를 unused로 mark해 주어야 한다.
curl -X 'POST' -H 'Content-Type:application/json' -d '{ "interval" : "1990-01-03T00:00:00.000Z/2222-02-09T00:00:00.000Z" }' http://{druid주소 및 포트}/druid/coordinator/v1/datasources/{datasource 이름}/markUnused
이렇게 하면 interval에 속하는 row들이 unused로 마크되고,
Datasource - Actions에서 Delete 가능하게 바뀐다.