How do i get absolute values for a series set in bosun? - bosun

I have following series set which has negative values, how do i convert them positive values? Not all values in the series are negative so multiplying with -1 may be the option

If using master you can do the following:
$q = q("avg:rate:os.cpu{host=*bosun*}", "5m", "")
map($q, expr(abs(v())))
Since 0.6.0 is not released yet, this hasn't been published to our documentation. But you can find the documentation about map in https://raw.githubusercontent.com/bosun-monitor/bosun/master/docs/expressions.md .

Related

calculate an exponent from another column

Does anyone know if DynamoDB supports calculating exponents in an UpdateExpression?
I know I can add or subtract from a column, but that seems to be the mathematical limit on updates that I can find.
I am trying to take and existing column value, take 2 to the power of that column value, and then update a second column.
Thanks
Unfortunately, you can only add/subtract. From the docs for Update Expressions:
Incrementing and Decrementing Numeric Attributes
You can add to or subtract from an existing numeric attribute. To do this, > use the + (plus) and - (minus) operators.
You'll need to perform the exponent function in your application code after reading the item.

Return peak heights in find_peaks

I am using scipy.signal.find_peaks in a 8x150 array "signal" to find relative minima.
for example for row 1, I use
peaks = find_peaks(signal[1,:],distance=8,height=-1.6)
This realiably gives me the indices in a ndarray that has the indices and the peak_heights as a property arrary.
Now I would like to return the peak heights in a list or so, so that I can save them for later use.
I have tried
signal[1,peaks]
but that gives me an index error.
How do I convert peaks to a proper indice? Or is there a way to directly access the peak_heigts from find_peaks?
I just found that signal[0] seems to do the job!
Thanks!

Grafana dividing 2 series

I'm trying to divide 2 series to get their ratio.
For example I'm got sites (a.com, b.com, c.com) as * (All sites)
Each of them has total sections count and errors occurred stats. I'm wanna to show as bars errors/sections where section > errors for each site to each erros for this site. Here I'm whant to got 3 bars.
So:
A parser.*.sections.total
B parser.*.errors.total
X-Axis Mode:Series
Display:DrawMode: Bars
When i'm trying to use divideSeries I'm always got VallueError(divideSeries second argument must reference exactly 1 series)
A new function divideSeriesLists was introduced in Graphite 1.0.2 for dividing one series with another. Both the series should be of same length.
You can use mapSeries with divideSeries to do vector matching of series in Graphite (or maybe asPercent depending on which version of graphite you are using).
An example query:
aliasByNode(reduceSeries(mapSeries(groupByNodes(parser.*.{sections,errors}.total, 'maxSeries', 1, 2), 0), 'asPercent', 1, 'sections', 'errors'), 0)
I'm not sure what aggregation function you are using so substitute maxSeries for the function you need.
Check out this blog post about using mapSeries with divideSeries for more explanation.
Here is an example from our system in the Grafana query editor:

Time to maturity (TTM) shifted for day conversion using RQuantlib in R

I'm using RQuantlib package in R to calculate the implied volatility. As a input to the function EuropeanOptionImpliedVolatility I use TTM days divided by 365. But if I use the output implied volatility to calculate the option price back using hand crafted Black Scholes function, I end with a different values.
I found the cause to be in the europeanOptionImpliedVolatilityEngine, which converts the input fractional year by using the conversion
int(maturity*360 + 0.5);
Source: RQuantlib github
So this ends up shifting the TTM values passed on to the C code function with difference of 1 day in some cases, about 70% of the data got date shifted in my case.
x=OptGreeks$TTM/365
y=floor(x*360+0.5)
z=OptGreeks$TTM - y
table(z)
Output
z
0 1
2636 4910
Any idea why this is being done and any measure the get the correct days (TTM) passed instead of this anomaly? Hope someone listens.
The function should probably be extended so that one can choose a day-count convention, and that's the way to go if you're familiar with C++ and can patch and recompile RQuantLib.
In the meantime, I'm afraid that the way to work around the problem is for you to use days/360, too. This means you'll also have to adjust your input rates and the output volatility; the relations you want to satisfy are r360 t360 = r365 t365 (from which you'll get the r360 to pass as input, given your r365) and sigma2360 t360 = sigma2365 t365 (from which you'll get sigma365 given the returned sigma360).

Limiting Window Size and/or Removing Specific Rows of Time Values In R

I'm trying to figure out how to observe just one particular section of the data in the graph below (e.g. 5pm onwards). I know there are basically two methods of doing this:
1) Method 1: Limiting the window size, which requires the following function:
< symbols(Data$Times, Data$y, circles=Data$z, xlim=c("5:00pm","10:00pm"))
The problem is, I get an "invalid 'xlim' value" error when I try to input the two time endpoints.
2) Method 2: Clearing out the rows in Data$Times that have values over 5pm.
The problem here is that I'm not sure how to sort the rows by earliest time -> latest time OR how to define a new variable such that TimesPM <- Data$Times>"5pm" (what I typed just now obviously did not work.)
Any ideas? Thanks in advance.
ETA: This is what I plotted:
Times<-strptime(DATA$Time,format="%I:%M%p")
symbols(Times, y, circles=z, xaxt='n', inches=.4, fg="3", bg=(a), xlab="Times", ylab="y")
axis.POSIXct(1, at=Times, format="%I:%M%p")
Both approaches have the problem that in all likelihood your datetime format will not equal the values expressed just as a character vector like "5:00pm" even after coercion with the ">" comparison operator. To get the best advice you need to present str(DATA$Times) or dput(head(DATA$Times)) or class(Data$Times) . Generally plotting functions recognize either valid date or datetime classes or their numeric representation. If the ordering operation is not working, then it raises the question whether you have a proper class. But you appear to have an axis labeling that suggests a date-time format of some sort, and that we just need to figure out what class it really is.
Because you are creating a character vector from you Time column, you probably want to apply the restriction before you send the DATA$Time vector to strptime(). You still have not offered the requested clarifications, so I have no way to give tested or even very specific code, but you might be doing something like
Times<-strptime(DATA$Time[ as.POSIXlt(DATA$Time)$hour >= 17 &
as.POSIXlt(DATA$Time)$hour <= 22 ] ,
format="%I:%M%p")

Resources