druid如何用利用tranquityserver向druid发送实时数据
程序员文章站
2022-04-12 21:28:23
druid如何用利用tranquityserver向druid发送实时数据。
1. 前提条件
? ?分布式druid系统安装已经完毕。
2. 下载tranquility server...
druid如何用利用tranquityserver向druid发送实时数据。
1. 前提条件
? ?分布式druid系统安装已经完毕。
2. 下载tranquility server
官方下载地址:http://static.druid.io/tranquility/releases/tranquility-distribution-0.8.2.tgz
把 下载好的tar包解压到 /opt/tranquility-distribution-0.8.2
#cd?/opt/tranquility-distribution-0.8.2
# vi conf/server.json
内容如下:
{ "dataSources" : { "mypageviews" : { "spec" : { "dataSchema" : { "dataSource" : "mypageviews", "parser" : { "type" : "string", "parseSpec" : { "timestampSpec" : { "format": "auto", "column": "time" }, "dimensionsSpec" : { "dimensions": ["url", "user"] }, "format" : "json" } }, "granularitySpec" : { "type" : "uniform", "segmentGranularity" : "hour", "queryGranularity" : "none" }, "metricsSpec" : [ {"name": "views", "type": "count"}, {"name": "latencyMs", "type": "doubleSum", "fieldName": "latencyMs"} ] }, "ioConfig" : { "type" : "realtime" }, "tuningConfig" : { "type" : "realtime", "maxRowsInMemory" : "100000", "intermediatePersistPeriod" : "PT1M", "windowPeriod" : "PT10M", "basePersistDirectory": "/data/persist" } }, "properties" : { "task.partitions" : "1", "task.replicants" : "1" } } }, "properties" : { "zookeeper.connect" : "10.70.27.8:2181,10.70.27.10:2181,10.70.27.12:2181", "druid.discovery.curator.path" : "/druid/discovery", "druid.selectors.indexing.serviceName" : "druid/overlord", "http.port" : "8200", "http.threads" : "8" } }
3. 启动?tranquility
nohup bin/tranquility server -configFile conf/server.json > ./tranquit.out 2>&1 &
4. 发送 http post 请求到transquitity server
?可以用postman来发送请求:
地址: http://10.70.27.8:8200/v1/post/mypageviews
方法: post
内容:{"time": "2018-04-02T03:15:17Z", "url": "iroot.com/overea", "user": "today2551", "latencyMs":10}
content type:?application/json
注意:"time"的值得现查系统,可以在linux用下面的命令获得:
# python -c 'import datetime; print(datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"))'
2018-04-02T11:38:08Z