openTSDB-client:Java库,实现同步的http api,用于放置指标和从OpenTSDB服务器查询数据

  • a0_259231
    了解作者
  • 27.1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-23 00:45
    上传日期
一个简单的OpenTSDB客户端 OpenTSDB客户端是一个Java库,仅实现用于发送指标和查询OpenTSDB服务器的api。 注意此项目仅实现针对/ api / put?的同步http api。 和/ api / query,如果愿意,请随意为其他api推送实现pr。 发送指标 通过使用MetricBuilder完成指标的发送。 您只需添加一个指标,与该指标关联的标签以及数据点。 TSDBClient client = new TSDBClient("http://localhost:4242"); MetricBuilder builder = MetricBuilder.getInstance(); builder.addMetric("metric1").addDataPoint(1530247288, 30L) .addTag("tag1", "tab1v
openTSDB-client-master.zip
内容介绍
A Simple OpenTSDB Client ==================== The OpenTSDB client is a Java library that simply implements the api for sending metrics and querying the OpenTSDB server. **NOTE** This project only implements the synchronized http api for /api/put? and /api/query, please feel free to fork and push a implementation pr for other api if you like. ## Sending Metrics Sending metrics is done by using the MetricBuilder. You simply add a metric, the tags associated with the metric, and the data points. TSDBClient client = new TSDBClient("http://localhost:4242"); MetricBuilder builder = MetricBuilder.getInstance(); builder.addMetric("metric1").addDataPoint(1530247288, 30L) .addTag("tag1", "tab1value").addTag("tag2", "tab2value"); builder.addMetric("metric2").addDataPoint(1530247289,44) .addTag("tag1", "tab1value"); try { ErrorOrSuccDetail result= client.pushMetrics(builder, HttpRequest.DETAIL); System.out.println("result is:" + result); } catch (IOException e) { e.printStackTrace(); } finally { client.shutdown(); } ## Query Data Point Probably the most useful endpoint in the API, /api/query enables extracting data from the storage system in various formats determined by the serializer selected. Queries can be submitted via the 1.0 query string format or body content. You can simply use the below api to query data.(More details see http://opentsdb.net/docs/build/html/api_http/query/index.html) TSDBClient client = new TSDBClient("http://localhost:4242"); Date now = new Date(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -1); Date startTime = calendar.getTime(); Query query = Query.timeRange(startTime, now).sub( SubQuery.metric("metric1") .aggregator(Aggregator.SUM) .tag("tag1", "tab1value") .build() ).sub(SubQuery.metric("test1").aggregator(Aggregator.AVG).rate().downsample("none") .tag("tagk1", "tagv1") .tag("tagk2", "tagv2") .realtime(100) .build() ).build(); try { List<QueryResult> result = client.query(query); System.out.println("result is:" + result); } catch (IOException e) { e.printStackTrace(); } finally { client.shutdown(); } ## Copyright and License Copyright 2018 Proofpoint Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
评论
    相关推荐
    • http服务器学习
      学习http的get与post方法的学习,可以参考
    • 个人http服务器
      一款模拟http协议软件,可用于更新软件,网站及共享资源用
    • HTTP傻瓜服务器
      简单、明了的风格所创作的HTTP服务器,针对于大部分HTTP服务器来说,更为简单,容易上手。软件很小,但是web功能非常齐全。
    • http服务器
      http服务器
    • HTTP小型服务器
      HTTP小型服务器 适合局域网用 互传东西特别好用 英文版的
    • http代理服务器
      简单的http代理服务器 蛮好用的 可以在浏览器中测试
    • http服务器
      基于VC的http服务器,适合初学者,基于VC的http服务器,适合初学者
    • http简易服务器
      利用http制作的轻量级服务器项目,亲测可用,。。。。。。
    • http文件服务器
      一款非常不错的http文件服务器http开发必备,推荐下载。
    • 搭建自己的服务器HTTP
      呵呵。。。简单好用的HTTp服务器,软件类的,呵呵。。。抓鸡必备,也可以暂时性的当网站用