Giter Club home page Giter Club logo

opentsdbr's Introduction

opentsdbr

This package provides a read-only interface from R to OpenTSDB. We're using it internally for data analysis on the BEACON project at UC Berkeley. It's not optimized, and only uses HTTP, but could serve as a reference implementation (or straw man) for a faster and/or more fully featured API.

Seeking comment!

Installation

Install directly from GitHub using devtools:

if (!require("devtools")) install.packages("devtools")
library("devtools")
install_github("opentsdbr", "holstius")

Example usage

library(opentsdbr)

metric <- "SHT15_temp_Celsius"
start <- interval(ymd_hms("2013-02-02 00:00:00"), ymd_hms("2013-02-02 23:59:59"), tz="America/Los_Angeles")

# Query the TSD (defaults to localhost:4242)
# Optional: pass verbose=TRUE to see url and timings
(result <- tsd_get(metric, start, tags=c(site="*"), downsample="10m-avg"))
                 metric           timestamp    value       site
  1: SHT15_temp_Celsius 2013-02-02 00:05:35 26.50858 UHall575AB
  2: SHT15_temp_Celsius 2013-02-02 00:15:37 26.50114 UHall575AB
  3: SHT15_temp_Celsius 2013-02-02 00:25:41 26.78675 UHall575AB
  4: SHT15_temp_Celsius 2013-02-02 00:35:46 26.37500 UHall575AB
  5: SHT15_temp_Celsius 2013-02-02 00:45:50 26.67035 UHall575AB
 ---                                                           
240: SHT15_temp_Celsius 2013-02-03 16:07:33 30.83301 UHall575AB
241: SHT15_temp_Celsius 2013-02-03 16:17:35 30.60807 UHall575AB
242: SHT15_temp_Celsius 2013-02-03 16:27:39 31.02158 UHall575AB
243: SHT15_temp_Celsius 2013-02-03 16:37:41 30.87239 UHall575AB
244: SHT15_temp_Celsius 2013-02-03 16:45:27 31.01333 UHall575AB

# Query the TSD through the opentsdb v2 endpoint which means that now it supports non-ascii tags such as UTF-8.
(result <- tsd_req(metric, start, tags=c(site="*"), downsample="10m-avg"))

# Convert to irregular time series, filter, and plot
library(zoo)
z <- with(result, zoo(value, timestamp))
filtered <- rollapply(z, width=7, FUN=median)
plot(merge(z, filtered))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.