天天看點

Apache Druid常用API

1.查詢某個Meta Datasource下所有的segments

GET

http://coordinator_hostname:8081/druid/coordinator/v1/metadata/datasources/datasource_name/segments/
GET http://coordinator_hostname:8062/druid/coordinator/v1/metadata/datasources/T24R16_RATE1/segments/

["T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z","T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T0
9:53:03.923Z_1","T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z_10","T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00
.000Z_2018-11-30T09:53:03.923Z_11","T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z_12"]           

2.查詢某個Meta Datasource下某個segment

http://coordinator_hostname:8081/druid/coordinator/v1/metadata/datasources/datasource_name/segments/segment_id
GET http://coordinator_hostname:8062/druid/coordinator/v1/metadata/datasources/T24R16_RATE1/segments/T24R16_RATE1_2018-12-12T00:00:00.000Z_2018-12-13T00:00:00.000Z_2018-12-11T16:02:01.049Z_11

{"dataSource":"T24R16_RATE1","interval":"2018-12-12T00:00:00.000Z/2018-12-13T00:00:00.000Z","version":"2018-12-11T16:02:01.049Z","loadSpec":{"type":"hdfs","path":"hdfs://namenodea.bos.opmbd.com:8020/druid/segments/T24R16_RATE1/20181212T000000.000Z_20181213T000000.000Z/2018-12-11T16_02_01.049Z/11_4a80ec61-cb8e-4fc0-ab0b-802f57fd4b4a_index.zip"},"dimensions":"appName,nodeName,isFundTrans,transType,requestTime,channelSubSystem,errorCode,errorMessage,hour,day,year,month","metrics":"TotalTransCount,SuccessTransCount,FaildTransCount,MaxProcessTime,MinProcessTime,TotalProcessTime","shardSpec":{"type":"numbered","partitionNum":11,"partitions":0},"binaryVersion":9,"size":3569916,"identifier":"T24R16_RATE1_2018-12-12T00:00:00.000Z_2018-12-13T00:00:00.000Z_2018-12-11T16:02:01.049Z_11"}           

3.删除某個Datasource下的某個segment

DELETE

4.停止流任務

POST

http://overlord_hostname:8090/druid/indexer/v1/supervisor/datasource_name/shutdown

5.檢視流任務狀态

http://overlord_hostname:8090/druid/indexer/v1/supervisor/datasource_name/status
GET  http://overlord_hostname:8065/druid/indexer/v1/supervisor/T24R16_RATE1/status

{"id":"T24R16_RATE1","generationTime":"2018-12-12T10:27:17.774Z","payload":{"dataSource":"T24R16_RATE1","topic":"T24R16APP4","partitions":1,"replicas":1,"durationSeconds":3600,"activeTasks":[{"id":"index_kafka_T24R16_RATE1_aad49f137ceda5f_habbdajf","startingOffsets":{"0":256596818},"startTime":"2018-12-12T09:27:57.321Z","remainingSeconds":39,"type":"ACTIVE","currentOffsets":{"0":257093461},"lag":{"0":0}}],"publishingTasks":[],"latestOffsets":{"0":257093461},"minimumLag":{"0":0},"aggregateLag":0,"offsetsLastUpdated":"2018-12-12T10:26:58.085Z"}}           

6.檢視Meta Datasource資訊

http://coordinator_hostname:8081/druid/coordinator/v1/metadata/datasources/datasource_name/
GET http://coordinator_hostname:8062/druid/coordinator/v1/metadata/datasources/T24R16_RATE1

{"name":"T24R16_RATE1","properties":{"created":"2018-12-12T10:27:44.208Z"},"segments":[{"dataSource":"T24R16_RATE1","interval":"2018-11-27T00:00:00.000Z/2018-11-28T00:00:00.000Z","version":"2018-11-30T09:53:03.923Z","loadSpec":{"type":"hdfs","path":"hdfs://namenodea.bos.opmbd.com:8020/druid/segments/T24R16_RATE1/20181127T000000.000Z_20181128T000000.000Z/2018-11-30T09_53_03.923Z/0_aedd22eb-1c30-428c-9ab4-e346d84150e0_index.zip"},"dimensions":"appName,nodeName,isFundTrans,transType,requestTime,channelSubSystem,errorCode,errorMessage","metrics":"TotalTransCount,SuccessTransCount,FaildTransCount,MaxProcessTime,MinProcessTime,TotalProcessTime","shardSpec":{"type":"numbered","partitionNum":0,"partitions":0},"binaryVersion":9,"size":3603204,"identifier":"T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z"},{"dataSource":"T24R16_RATE1","interval":"2018-11-27T00:00:00.000Z/2018-11-28T00:00:00.000Z","version":"2018-11-30T09:53:03.923Z","loadSpec":{"type":"hdfs","path":"hdfs://namenodea.bos.opmbd.com:8020/druid/segments/T24R16_RATE1/20181127T000000.000Z_20181128T000000.000Z/2018-11-30T09_53_03.923Z/1_34ff3724-af5d-43ea-903d-e2ec7c0d3ccd_index.zip"},"dimensions":"appName,nodeName,isFundTrans,transType,requestTime,channelSubSystem,errorCode,errorMessage","metrics":"TotalTransCount,SuccessTransCount,FaildTransCount,MaxProcessTime,MinProcessTime,TotalProcessTime","shardSpec":{"type":"numbered","partitionNum":1,"partitions":0},"binaryVersion":9,"size":3609845,"identifier":"T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z_1"}]}           

7.檢視DataSource Rule

http://coordinator_hostname:8081/druid/coordinator/v1/rules/datasource_name>
GET http://coordinator_hostname:8062/druid/coordinator/v1/rules

{"_default":[{"tieredReplicants":{"_default_tier":1},"type":"loadForever"},{"type":"dropForever"}],"APP_T24_HOUR":[],"T24R16_TransMonitor":[],"APP_T24_MINUTE":[]}

GET http://coordinator_hostname:8062/druid/coordinator/v1/rules/T24R16_RATE1
[]
           

8.檢視Datasource資訊

http://coordinator_hostname:8081/druid/coordinator/v1/datasources/datasource_name
GET http://coordinator_hostname:8062/druid/coordinator/v1/datasources/T24R16_RATE1

{"tiers":{"_default_tier":{"size":3658919489,"segmentCount":1163}},"segments":{"maxTime":"2018-12-13T00:00:00.000Z","size":3658919489,"minTime":"2018-11-27T00:00:00.000Z","count":1163}}           

9.檢視某個Datasource下所有的segments

http://coordinator_hostname:8081/druid/coordinator/v1/datasources/datasource_name/segments
GET http://coordinator_hostname:8062/druid/coordinator/v1/datasources/T24R16_RATE1/segments

["T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z","T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z_1","T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z_10"]           

10.檢視某個Datasource下某個segment

http://coordinator_hostname:8081/druid/coordinator/v1/datasources/datasource_name/segments/
GET http://coordinator_hostname:8062/druid/coordinator/v1/datasources/T24R16_RATE1/segments/T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z

{"metadata":{"dataSource":"T24R16_RATE1","interval":"2018-11-27T00:00:00.000Z/2018-11-28T00:00:00.000Z","version":"2018-11-30T09:53:03.923Z","loadSpec":{"type":"hdfs","path":"hdfs://namenodea.bos.opmbd.com:8020/druid/segments/T24R16_RATE1/20181127T000000.000Z_20181128T000000.000Z/2018-11-30T09_53_03.923Z/0_aedd22eb-1c30-428c-9ab4-e346d84150e0_index.zip"},"dimensions":"appName,nodeName,isFundTrans,transType,requestTime,channelSubSystem,errorCode,errorMessage","metrics":"TotalTransCount,SuccessTransCount,FaildTransCount,MaxProcessTime,MinProcessTime,TotalProcessTime","shardSpec":{"type":"numbered","partitionNum":0,"partitions":0},"binaryVersion":9,"size":3603204,"identifier":"T24R16_RATE1_2018-11-27T00:00:00.000Z_2018-11-28T00:00:00.000Z_2018-11-30T09:53:03.923Z"},"servers":["datanode3.bos.opmbd.com:8063"]}           

11.删除Task任務狀态

http://overlord_hostname:8090/druid/indexer/v1/task/taskId/shutdown

12.檢視Task任務狀态

http://overlord_hostname:8090/druid/indexer/v1/task/taskId/status
GET  http://overlord_hostname:8065/druid/indexer/v1/task/index_kafka_APP_T24_HOUR_d95f44c20fab354_pinifbki/status

{"task":"index_kafka_APP_T24_HOUR_d95f44c20fab354_pinifbki","status":{"id":"index_kafka_APP_T24_HOUR_d95f44c20fab354_pinifbki","status":"RUNNING","duration":-1}}           

13.檢視Task任務的所有segments

http://overlord_hostname:8090/druid/indexer/v1/task/taskId/segments
GET  http://overlord_hostname:8065/druid/indexer/v1/task/index_kafka_APP_T24_MINUTE_54cae6981ec8880_cfigommg/segments

[{"dataSource":"APP_T24_MINUTE","interval":"2018-12-12T00:00:00.000Z/2018-12-13T00:00:00.000Z","version":"2018-12-11T16:02:01.042Z","loadSpec":{"type":"hdfs","path":"hdfs://namenodea.bos.opmbd.com:8020/druid/segments/APP_T24_MINUTE/20181212T000000.000Z_20181213T000000.000Z/2018-12-11T16_02_01.042Z/18_76923693-dc73-4a05-931d-fe0488be7cbd_index.zip"},"dimensions":"appName,nodeName,isFundTrans,transType","metrics":"TotalTransCount,SuccessTransCount,FaildTransCount,MaxProcessTime,MinProcessTime,TotalProcessTime","shardSpec":{"type":"numbered","partitionNum":18,"partitions":0},"binaryVersion":9,"size":109031,"identifier":"APP_T24_MINUTE_2018-12-12T00:00:00.000Z_2018-12-13T00:00:00.000Z_2018-12-11T16:02:01.042Z_18"}]           

14.檢視正在進行的任務

http://overlord_hostname:8090/druid/indexer/v1/runningTasks
GET  http://overlord_hostname:8065/druid/indexer/v1/runningTasks

[{"id":"index_kafka_APP_T24_HOUR_d95f44c20fab354_pinifbki","createdTime":"2018-12-12T06:04:32.957Z","queueInsertionTime":"2018-12-12T06:04:32.960Z","statusCode":null,"duration":null,"location":{"host":"datanode3.bos.opmbd.com","port":8103,"tlsPort":-1}},{"id":"index_kafka_APP_T24_MINUTE_d3b476e5aca2159_mohihhoi","createdTime":"2018-12-12T10:37:47.789Z","queueInsertionTime":"2018-12-12T10:37:47.791Z","statusCode":null,"duration":null,"location":{"host":"datanode3.bos.opmbd.com","port":8102,"tlsPort":-1}},{"id":"index_kafka_T24R16_RATE1_1a2bfc23f45339e_mijfgcje","createdTime":"2018-12-12T10:27:58.430Z","queueInsertionTime":"2018-12-12T10:27:58.432Z","statusCode":null,"duration":null,"location":{"host":"datanode3.bos.opmbd.com","port":8101,"tlsPort":-1}},{"id":"index_kafka_T24R16_TransMonitor_df0b26842cf98c8_llfmpjpg","createdTime":"2018-12-12T10:38:28.626Z","queueInsertionTime":"2018-12-12T10:38:28.628Z","statusCode":null,"duration":null,"location":{"host":"datanode3.bos.opmbd.com","port":8104,"tlsPort":-1}}]           

15.檢視正在等待的任務

http://overlord_hostname:8090/druid/indexer/v1/waitingTasks
GET  http://localhost:8065/druid/indexer/v1/waitingTasks           

16.檢視正在挂起的任務

http://overlord_hostname:8090/druid/indexer/v1/pendingTasks
GET  http://localhost:8065/druid/indexer/v1/pendingTasks           

17.檢視所有Datasources

http://coordinator_hostname:8081/druid/coordinator/v1/datasources/
GET http://coordinator_hostname:8062/druid/coordinator/v1/datasources/

["APP_T24_HOUR","APP_T24_MINUTE","T24R16_RATE1","T24R16_TransMonitor","wikiticker"]           

18.檢視完成的任務

http://overlord_hostname:8090/druid/indexer/v1/completeTasks
GET  http://overlord_hostname:8065/druid/indexer/v1/completeTasks

[{"id":"index_kafka_T24R16_TransMonitor_ec92905e89f1403_eaaplohe","createdTime":"2018-12-12T09:38:18.598Z","queueInsertionTime":"1970-01-01T00:00:00.000Z","statusCode":"SUCCESS","duration":3670040,"location":{"host":null,"port":-1,"tlsPort":-1}},{"id":"index_kafka_APP_T24_MINUTE_54cae6981ec8880_cfigommg","createdTime":"2018-12-12T09:37:38.075Z","queueInsertionTime":"1970-01-01T00:00:00.000Z","statusCode":"SUCCESS","duration":3729859,"location":{"host":null,"port":-1,"tlsPort":-1}},{"id":"index_kafka_T24R16_RATE1_aad49f137ceda5f_habbdajf","createdTime":"2018-12-12T09:27:48.518Z","queueInsertionTime":"1970-01-01T00:00:00.000Z","statusCode":"SUCCESS","duration":3729979,"location":{"host":null,"port":-1,"tlsPort":-1}},{"id":"index_kafka_T24R16_TransMonitor_58f6e0029909c7e_ldnbhmff","createdTime":"2018-12-12T08:38:08.720Z","queueInsertionTime":"1970-01-01T00:00:00.000Z","statusCode":"SUCCESS","duration":3669990,"location":{"host":null,"port":-1,"tlsPort":-1}},{"id":"index_kafka_APP_T24_MINUTE_48ae762357d6961_fkgeeied","createdTime":"2018-12-12T08:37:28.253Z","queueInsertionTime":"1970-01-01T00:00:00.000Z","statusCode":"SUCCESS","duration":3669934,"location":{"host":null,"port":-1,"tlsPort":-1}}]           

19.檢視叢集所有節點資訊

http://coordinator_hostname:8081/druid/coordinator/v1/servers?simple
GET http://coordinator_hostname:8062/druid/coordinator/v1/servers?simple

[{"host":"datanode3.bos.opmbd.com:8102","tier":"_default_tier","type":"indexer-executor","priority":0,"currSize":0,"maxSize":0},{"host":"datanode3.bos.opmbd.com:8101","tier":"_default_tier","type":"indexer-executor","priority":0,"currSize":0,"maxSize":0},{"host":"datanode3.bos.opmbd.com:8104","tier":"_default_tier","type":"indexer-executor","priority":0,"currSize":0,"maxSize":0},{"host":"datanode3.bos.opmbd.com:8103","tier":"_default_tier","type":"indexer-executor","priority":0,"currSize":0,"maxSize":0},{"host":"datanode3.bos.opmbd.com:8063","tier":"_default_tier","type":"historical","priority":0,"currSize":3794792640,"maxSize":130000000000}]           

20.重新開機任務

curl -X 'POST' -H 'Content-Type:application/json' -d @supervisor/T24R16-rate-index.json overlord_hostname:8065/druid/indexer/v1/supervisor