druid支持两种查询,原生和sql
sql查询大同小异
[ EXPLAIN PLAN FOR ] [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ] SELECT [ ALL | DISTINCT ] { * | exprs } FROM table [ WHERE expr ] [ GROUP BY exprs ] [ HAVING expr ] [ ORDER BY expr [ ASC | DESC ], expr [ ASC | DESC ], ... ] [ LIMIT limit ] [ UNION ALL <another query> ]druid的原生查询采用json方式,通过http传送。
一个druid查询groupby的例子,指定了时间范围,聚合粒度,数据源等。
{ "queryType": "groupBy", "dataSource": "sample_datasource", "granularity": "day", "dimensions": ["country", "device"], "limitSpec": { "type": "default", "limit": 5000, "columns": ["country", "data_transfer"] }, "filter": { "type": "and", "fields": [ { "type": "selector", "dimension": "carrier", "value": "AT&T" }, { "type": "or", "fields": [ { "type": "selector", "dimension": "make", "value": "Apple" }, { "type": "selector", "dimension": "make", "value": "Samsung" } ] } ] }, "aggregations": [ { "type": "longSum", "name": "total_usage", "fieldName": "user_count" }, { "type": "doubleSum", "name": "data_transfer", "fieldName": "data_transfer" } ], "postAggregations": [ { "type": "arithmetic", "name": "avg_usage", "fn": "http://www.likecs.com/", "fields": [ { "type": "fieldAccess", "fieldName": "data_transfer" }, { "type": "fieldAccess", "fieldName": "total_usage" } ] } ], "intervals": [ "2012-01-01T00:00:00.000/2012-01-03T00:00:00.000" ], "having": { "type": "greaterThan", "aggregation": "total_usage", "value": 100 } } 三、应用场景druid常见应用领域包括:
点击流分析(网络和移动分析)
风险/欺诈分析
网络遥测分析(网络性能监控)
服务器指标存储
供应链分析(制造指标)
应用程序性能指标
商业智能/ OLAP
用户行为分析Druid可以用于,点击流,视图流,活动流。
准确地和近似地计算用户指标,计算出日常活动用户之类的平均指标,以查看总体趋势,或者精确计算以呈现给运营部门。
数字营销Druid常用于存储和查询在线广告数据。这些数据通常来自广告服务器,对于衡量和了解广告系列的效果,点击率,转化率(损耗率)等等。
OLAP和BIDruid通常用于BI,与Hive之类的SQL-on-Hadoop引擎不同,Druid专为高并发性和亚秒级查询而设计,可通过UI进行交互式数据探索。
总之,在实时计算应用越来越广泛的今天,druid将凭借着她的高性能和OLAP的优势,在实时的BI已经大屏等领域大放异彩!
大数据流动 专注于大数据实时计算,数据治理,数据可视化等技术分享与实践。
请在后台回复关键字下载相关资料。相关学习交流群已经成立,欢迎加入~