I have to compare two values changing in both directions (rising and falling) within an hour (items amount, for example). What formula may I use to calculate if the amount drops or rises on more than 20%? Does Zabbix calculated value support if conditions to support positive and negative change or it's possible to bypass it?
I'm trying to write something like this:
{api20prod:mysql.get_active_offers.count(0)}/{api20prod:mysql.get_active_offers.count(,,,1h)}*100 > 20
but what if mysql.get_active_offers.count(0) more than mysql.get_active_offers.count(,,,1h) ?
You cannot use a "Simple Change" preprocessor because:
If the current value is smaller than the previous value, Zabbix
discards that difference (stores nothing) and waits for another value.
If you set the item with a 1h check interval (or with scheduled intervals at a specific minute of every hour), you can do the trick with the last() function.
Let's say that at 12:00 your item equals 25 and at 13:00 it equals 38:
At 13:00 invoking last() without parameters will return 38
At 13:00 invoking last(#2) will return 25
You can calculate the hourly readings delta % with:
100 * ({api20prod:mysql.get_active_offers.last()} - {api20prod:mysql.get_active_offers.last(#2)}) / {api20prod:mysql.get_active_offers.last(#2)}
This syntax should work either in a trigger or in a calculated item, choose the one that suits you better: I suggest a calculated item.
Of course, your trigger will have a double condition: you need to match "> 20" OR "< -20"
If you don't want to change the item's check interval you can use the avg() function, see the documentation.
Related
At the picture from Wavefront below I see that at between 11:13 and 11:14 there was one request to my api.
I need to display request per second graph. When I try to use rate() I have the next graph
The request point in the Y axis has value 0.1 but I expect 1 request. And if I change scale the Y value changes as well.
From the rate() doc
rate() finds the per-second rate of change between pairs of adjacent (successively reported) data values, where the later value is greater than the earlier value. The rate of change between a pair of increasing data values is computed as follows: 1. Subtract the earlier data value from the later value. 2. Divide the difference by the number of seconds in the reporting interval.
How can I get the reporting interval in the query to make it show the requests count correctly?
It looks like align() + ratediff() do what I want
Specifically the Interval Properties.
No matter what I do I don't get the desired result.
I need to color in 3 shifts of 8h each.
My Chart has the X-Values ranging from 0 to 23.
My earliest shift starts at 5am.
I get the length and offset of each shift through an SQL Query in minutes.
Example Shift 1:
offset = Datediff from 0 to shiftstart -> 300 min
length = Datediff from shiftstart to shiftend -> 480 min
My intuition tells me that since I have 24 X-Values in my chart, I need to set intervalType to hours or days with either 24 or 1 as value.
I interpret it as "Every Day/24h begin drawing the specified Stripline at its offset-Value with the specified length".
intervalOffsetType would be Minutes.
In my mind, the Offset works in conjunction with the selected IntervalType and since my shift starts at 5am each day, I suspect that intervalOffset needs to be 300.
Which would mean: "Begin drawing the stripline at 5am".
the striplineWidth-property then determines the the width, or rather length of the shift and its type, again, works in conjunction with the IntervalType.
Evidently this is not the case though.
My Settings:
My Result:
Can someone explain to me how the Interval Properties work?
I can't find any proper documentation on them either.
The solution to my problem was on the axis-options.
(rightclick x-axis -> properties)
Switching from category to scalar and setting the intervalType produces the desired result.
I'd need to test it further but for now I think having axis-type set to category applies the stripline to each member of a categorygroup in a chart.
I have recently been putting together an SSRS report that will run every 15 minutes for the previous 15 minute 'chunk' of time. In essence a very straight forward and simple report that will run via an automated subscription.
I was using Microsoft SQL Server 12 Report Builder Version 3.
I was alerted to an issue with the output csv when my recipient reported being sent blank files, most odd considering the report generated as expected when run manually.
Long story short, it was the expressions I was using to generate the From and To dates. Manual runs produced data, subscription runs did not.
Original parameters
FromDate
dateadd(DateInterval.Second, (second(now()) + 900) * -1, dateadd(Dateinterval.Minute, (minute(now()) mod 15) * -1, now()))
ToDate
dateadd(DateInterval.Second, (second(now()) + 1) * -1, dateadd(Dateinterval.Minute, (minute(now()) mod 15) * -1, now()))
New Parameters
FromDate
dateadd(DateInterval.Minute, -15, dateadd(DateInterval.Minute, cint(datediff(DateInterval.Minute,today(),now()) / 15) * 15, today()))
ToDate
dateadd(DateInterval.Second, 899,Parameters!FromDate.Value)
Thought I would post this here for two reasons
Theories as to why
It might help someone in the future
Your original parameters take Now and subtract the minutes to arrive at a 15-minutes time, then they take the seconds of another Now (which is later and could be in the next second or even minute) and subtract that value to arrive at a 0-second time (or a 59-second time). This could already cause a problem when there is a change of seconds between the first and the second Now, which isn't very unikely, as on my test system there were 0.59 seconds between the two evaluations of Now in the FromDate parameter. Also, the Now value is more accurate than just a second, and your formula does not respect that. Therefore, if the records you are trying to process in your report happen to have a time of exactly a quarter of an hour, the first parameter is for sure greater (by maybe 0.01 second) and so the record is ignored.
Your formula for the "new parameters" does not depend on the seconds of Now() and will always return a time with no fraction of a second, so I guess that that's what makes the difference.
The expression for the FromDate could be simplified a little:
=Today.AddSeconds(900*(DateDiff(DateInterval.Minute, Today, Now)\15-1))
If you do not plan to run the report very short before midnight, there should not be a problem caused by a change of the day during the evaluation of Today and Now, and you could calculate the second parameter in a similar way, independently from the first one:
=Today.AddSeconds(900*(DateDiff(DateInterval.Minute, Today, Now)\15)-1)
The original parameter values were being calculated individually which means they would each have slightly different values for Now(). I know this is a long shot, but it's a theory. If the subscription job fired off a fraction of a second before a 15 minute interval, it's possible that the ToDate returned just before the FromDate. This would result in an invalid date range.
With the new expressions, the ToDate is referencing the FromDate which forces them to be calculated in sequence, not in parallel. Not to mention you're adding to the FromDate which also forces the date range to have a consistent length. However, you may still run into a case where you get the same report twice if the FromDate is calculated on the wrong side of a 15 minute cutoff.
One way to test/avoid this issue would be to offset the subscription time so that it doesn't actually try to fire at the exact 15 minute cutoffs. For example, you could have it scheduled to go off 1 minute afterwards.
Take Datetime and give the half hour band it belongs to, irrespective of the date, just interested in the time.
There is as far as I can see, no time periods in SSRS, I need half hour time periods, that's 48 blocks in a day.
I would like to plot my data in bar chart,the interval for the bar width is along the x axis, the height is the occurrences on the y axis. I need an interval of half hour(the width of the histogram),I don't want to run some IIF/CASE statement, I would rather, convert the DateTime i have to a band on each row of data, what's the best way to output so I get half hour intervals along the X axis.
I don't want to run some IIF/CASE statement
By this I assume you mean you don't want 48 layers of IIF/CASE. Here's an SSRS expression that'll band a datetime just using a single IIF:
=DateAdd(DateInterval.Minute, 0-
IIF(Minute(Fields!DATETIMEFIELD.Value) <= 29, Minute(Fields!DATETIMEFIELD.Value), Minute(Fields!DATETIMEFIELD.Value) -30),
DateAdd(DateInterval.Second, 0-Second(Fields!DATETIMEFIELD.Value) ,Fields!DATETIMEFIELD.Value))
This removes the seconds from the time, and removes as many minutes necessary to get to the previous half-hour. You could likely use the same logic with different syntax as a column in your SQL query, if you prefer.
Use this calculated value for all the relevant parts of your SSRS chart.
I'm trying to calculate time diff between two time fields. Because the fields are just time with no date, I can't use timestampdiff, so I'm using timediff() or subtime(). The only problem with those is when the second time is less than the first time, it returns a negative timediff for me. I understand it's taking the times as the same day times, but is there any way to get a behavior where it always calculates the time forward? For example, I have 23:00:00 and 07:00:00.
timediff('07:00:00','23:00:00') will return a negative value, because 23:00 is greater than 07:00, but I want to get 8 hours as the return. Is there any way I can do that?
You can achieve that with an if statement:
select if(dateA > dateB,
timediff(dateA, dateB),
addtime(timediff(dateA, dateB), '24:00:00.000000'))
This way, if the first date is smaller than the second, you add 24 hours to the difference.