# TsdbComplement **Repository Path**: ItdeerWork/TsdbComplement ## Basic Information - **Project Name**: TsdbComplement - **Description**: TsdbComplement - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-11 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## TsdbComplement 应用程序 启动 [1] 修改配置文件 ``` 配置文件在TsdbComplement-1.0.0.jar 所在目录下的config目录下 注意这里不能改成其他的目录,且配置文件的名称不能改动为application.properties ``` [2] 启动 ``` java -jar TsdbComplement-1.0.0.jar 后台启动 nohup java -jar TsdbComplement-1.0.0.jar & ``` ## TsdbComplement 应用程序 配置详情 [1] Redis相关配置 ``` ## Redis Config ## #Redis集群连接地址 redis.servers=172.24.4.238:9001,172.24.4.238:9002,172.24.4.238:9003,172.24.4.238:9004,172.24.4.238:9005,172.24.4.238:9006 #最大连接数 redis.max.total=500 #最大空闲连接数 redis.max.idle=10 #获取连接最大等待时间 redis.max.wait.millis=5000 #获取连接最大超时时间 redis.max.timeout.millis=5000 #连接失败最大尝试连接次数 redis.max.attempts=10 ``` [2] TSDB相关配置 ``` ## TSDB Config ## #取数频率(默认5000毫秒) tsdb.frequency=5000 #TSDB查询节点连接地址 tsdb.url=http://172.24.4.235:8082/druid/v2/?pretty #查询类型 tsdb.queryType=select #查询结果是否排序 tsdb.descending=false #查询的粒度 tsdb.granularity=all #查询一页返回的最大条数 tsdb.threshold=100000 #过滤器类型 tsdb.filter_type=selector #过滤属性子段名称 tsdb.filter_dimension=tagName #错误信息 tsdb.error_message=query error ... #UTC时间格式 tsdb.Time_Sdf=yyyy-MM-dd'T'HH:mm:ss.SSS'Z' #常规时间格式 tsdb.Query_Sdf=yyyy-MM-dd HH:mm:ss ``` [3] 系统相关配置 ``` #服务启动的端口号 server.port = 3000 ``` ## TsdbComplement 应用程序 提供接口详情 > Redis请求取值接口 [1] 取单值 ``` 请求方式: GET 请求地址: /api/v1/redis/getOne/{key} 请求示例: /api/v1/redis/getOne/A A 为Key 请求结果: a ``` [2] 取多值 ``` 请求方式: GET 请求地址: /api/v1/redis/getMore/{keys} 请求示例: /api/v1/redis/getMore/A,B,C A,B,C 为三个Key,中间用逗号隔开 请求结果: [ "a", "b", "c" ] 请求地址: /api/v1/redis/getMore/{keys} 请求示例: /api/v1/redis/getMore/A A为Key 请求结果: [ "a" ] ``` > TSDB请求取值接口 [1] Select查询接口 ``` 请求方式: GET 请求地址: /api/v1/tc/select/{datasource}/{tagName}/{startTime}/{endTime} 请求示例: /api/v1/tc/select/sundafei/U70HFC60CP13/2018-11-13 13:00:00/2018-11-13 13:00:20 请求结果: [ { "sendTS": "2018-11-13 13:00:05", "tagName": "U70HFC60CP13", "isGood": "true", "timestamp": "2018-11-13T11:45:01.000Z", "value": 13 }, { "sendTS": "2018-11-13 13:00:10", "tagName": "U70HFC60CP13", "isGood": "true", "timestamp": "2018-11-13T11:45:01.000Z", "value": 13 }, { "sendTS": "2018-11-13 13:00:15", "tagName": "U70HFC60CP13", "isGood": "true", "timestamp": "2018-11-13T11:45:01.000Z", "value": 13 }, { "sendTS": "2018-11-13 13:00:20", "tagName": "U70HFC60CP13", "isGood": "true", "timestamp": "2018-11-13T11:45:01.000Z", "value": 13 } ] ``` [2] TopN查询接口 ``` 请求地址: /api/v1/tc/topn/{datasource}/{tagName}/{num} 请求示例: /api/v1/tc/topn/sundafei/U70HFC60CP1/3 请求结果: [ { "sendTS": "2018-11-15 11:19:53", "tagName": "U70HFC60CP1", "isGood": "true", "timestamp": "2018-11-15T11:14:20.000Z", "value": 16 }, { "sendTS": "2018-11-15 11:19:58", "tagName": "U70HFC60CP1", "isGood": "true", "timestamp": "2018-11-15T11:14:20.000Z", "value": 16 }, { "sendTS": "2018-11-15 11:20:03", "tagName": "U70HFC60CP1", "isGood": "true", "timestamp": "2018-11-15T11:14:20.000Z", "value": 16 } ] ``` ## Postman请求案例 ``` POST 172.24.4.235:8082/druid/v2/?pretty Content-Type:application/json { "queryType": "select", "dataSource": "Itdeer_Test", "descending": "true", "granularity": "all", "filter": { "type": "selector", "dimension": "TagName", "value": "U70HFC60CP18" }, "intervals": [ "2018-11-06T11:15:00.000Z/2018-11-06T12:15:00.000Z" ], "pagingSpec":{"pagingIdentifiers": {},"threshold":12} } ``` ## 启动kafka到Druid的任务配置 ``` { "type": "kafka", "ioConfig": { "topic": "sundafei", "consumerProperties": { "bootstrap.servers": "172.24.4.235:6667" }, "taskCount": 1, "taskDuration": "PT1H", "startDelay": "PT5S", "period": "PT30S", "useEarliestOffset": true, "completionTimeout": "PT1H", "replicas": 1 }, "dataSchema": { "dataSource": "sundafei", "granularitySpec": { "type": "uniform", "segmentGranularity": "HOUR", "rollup": false, "queryGranularity": "NONE" }, "parser": { "parseSpec": { "format": "json", "dimensionsSpec": { "dimensions": [ "tagName", "isGood", "sendTS" ] }, "timestampSpec": { "format": "yyyy-MM-dd HH:mm:ss", "column": "piTS" } } }, "metricsSpec": [ { "type": "doubleSum", "name": "value", "fieldName": "value" } ] }, "tuningConfig": { "type": "kafka", "maxRowsInMemory": 75000, "maxRowsPerSegment": 5000000, "intermediatePersistPeriod": "PT10M", "maxPendingPersists": 0, "indexSpec": { "bitmap": { "type": "concise" }, "dimensionCompression": "lz4", "metricCompression": "lz4" }, "buildV9Directly": true, "handoffConditionTimeout": 0, "reportParseExceptions": false } } ```