How in opentsdb do I add up all datapoints in a specified time range? - opentsdb

I'm using opentsdb. I have ONE time series, with values at 10-minute intervals. I want to specify a start time and an end time, and get back a single number that is the sum of all the values in the specified time range. I tried what I thought to be correct
...start=<start>&end=<end>&m=sum...
but got back all the individual values rather than their sum.

Add the element downsample="0all-sum"; apparently, the "0all" is interpreted as "the interval containing all timestamps".

Related

What are the consequences of choosing different frequencies for ts objects?

To create a ts-object in R, one has to specify a data frame, a start date and the frequency of the time series.
When searching the internet (e.g. Role of frequency parameter in ts), I get the impression that by choosing the frequency, one can emphasise whatever periodic pattern one believes is the most important in the data. However, I doubt that this is actually true. My impression is that it is solely used to compute the dates of the time series on-the-fly. E.g. when I set the start date “2015-08-01”, R automatically transforms it into a decimal date and I get something like 2015.58. If I now choose a frequency of 365 (or 365.25), R divides one unit by 365 and assigns this fraction to each day as one unit ahead, so the entry 366 days later is exactly 2016.58. However, if I choose frequency=7, the fraction assigned to each day is 1/7th, so the date assigned to the 8th day after my start date corresponds to a decimal number between 2016 and 2017. So the only choice for a data set with 365 entries per year is 365, isn’t it? And it is only used to actually create the time series?
Otherwise, if I choose the xts-class, an xts-object is built from a vector and a matrix where the vector has to be created in advance. So here there is no need to compute the date on-the-fly using a start date and a frequency and that is the reason why no frequency has to be assigned at all.
In both cases I can apply forecasting packages to either ts or xts objects (such as ARIMA, ets, stl, bats, bats etc) without specifying anything else so this shows that the frequency is actually not used for anything else. Or am I missing something here?
Thanks in advance for your comments!

How can I fetch a datapoint at certain time every day in Graphite?

I have a series of data that increases by time and resets to zero at 18:00 every day. How can I make a Graphite plot that only contains datapoints at 17:59 in the last 30 days?
I have tried summarize(1d, max, false), but it by default bins data into buckets that are calculated by rounding to the nearest interval to current time. So I cannot specify the beginning time of each bucket to be 18:00.
I couldn't find anything that exactly matches what you want. There are functions like timeSlice and timeStack but they do not really fit.
An alternative is to use the graphite function nonNegativeDerivative. It ignores when counters are reset to zero and only shows counter increments.

What does nPercentile do in Graphite and how it differs from percentileOfSeries?

I read the docs a million times but I can't figure out what it does. What does nPercentile do in Graphite and how it differs from percentileOfSeries?
nPercentile: "Returns n-percent of each series in the seriesList."
This converts every series you give it to a single value*, that is the n-th percentile of that series (but it will output as many series as it was given as input).
*note that as everything in graphite, this single value will be returned as a series, containing many times (as many as needed to fill the requested time-range) the same single value.
percentileOfSeries: "percentileOfSeries returns a single series which is composed of the n-percentile values taken across a wildcard series at each point."
This returns a single series, which, for every timepoint, contains the n-th percentile of the different input series.

Index xts using string and return only observations at that exact time

I have an xts time series in R and am using the very handy function to subset the time series based on a string, for example
time_series["17/06/2006 12:00:00"]
This will return the nearest observation to that date/time - which is very handy in many situations. However, in this particular situation I only want to return the elements of the time series which are at that exact time. Is there a way to do this in xts using a nice date/time string like this?
In a more general case (I don't have this problem immediately now, but suspect I may run into it soon) - is it possible to extract the closest observation within a certain period of time? For example, the closest observation to the given date/time, assuming it is within 10 minutes of the given date/time - otherwise just discard that observation.
I suspect this more general case may require me writing a function to do this - which I am happy to do - I just wanted to check whether the more specific case (or the general case) was already catered for in xts.
AFAIK, the only way to do this is to use a subset that begins at the time you're interested in, then get the first observation of that.
e.g.
first(time_series["2006-06-17 12:00:00/2006-06-17 12:01"])
or, more generally, to get the 12:00 price every day, you can subset down to 1 minute of each day, then split by days and extract the first observation of each.
do.call(rbind, lapply(split(time_series["T12:00:00/T12:01"],'days'), first))
Here's a thread where Jeff (the xts author) contemplates adding the functionality you want
http://r.789695.n4.nabble.com/Find-first-trade-of-day-in-xts-object-td3598441.html#a3599887

How to reference to other periods or columns when using aggregate()

When using aggregate, how can I make reference to a previous period within the function?
For example if aggregating by days how can make reference to the previous day from the next day in order to calculate the function.
For example if I had a one year hourly time series and I like to calculate the maximum of one day minus the minimum of the previous day I could use two different aggregates, shifting one of them and substracting from the other, but how could I do it all from within just one aggregate?
How can I know the number of the piece (here the day) where am I in order to use it inside the function?
cheers
As long as you have it appropriately sorted, you can use the shift() function I provided in response to a (much more specific) question.

Resources