Apache Druid 实时分析数据库
Apache Druid 面向事件数据的实时分析和时序聚合,擅长高并发切片、时间范围查询和预聚合。核心组件:Coordinator、Broker、Historical、MiddleManager/Indexer、Router 和 Deep Storage。
数据按时间分片(segment),支持 rollup 预聚合。适合点击流、监控指标和日志分析,不适合复杂 join 和强事务。
提交批量摄入任务:
curl -X POST http://router:8888/druid/indexer/v1/task \
-H 'Content-Type: application/json' \
-d @ingestion.json
查看任务和数据源:
curl http://router:8888/druid/indexer/v1/tasks
curl http://router:8888/druid/v2/datasources
SQL 查询:
curl -X POST http://router:8888/druid/v2/sql \
-H 'Content-Type: application/json' \
-d '{"query":"SELECT __time, COUNT(*) FROM events GROUP BY 1 ORDER BY 1 DESC LIMIT 10"}'
查看 segment:
curl http://router:8888/druid/coordinator/v1/datasources/events/segments
timestampSpec 不匹配,数据被丢弃。targetPartitionSize。