Relative/Dynamic lookback time for alerts in InfuxDB - influxdb

I am sending events to InfluxDB which are timestamped. These are basically events to external service. I wanted to set an alert which would execute if the count of such events from 12 AM today to now() extends a certain number, an alert should be raised.
I have checked out Influx but it seems that you can lookback only some constant time such as 5 mins, 10 mins, 1 hr, 12 hr, 1 day etc from now(). But for me the lookback is dynamic.
Please help with some pointers to achieve this.

Related

Schedule notification based on incremental random time interval

How to schedule the notification based on the incremental time span
10 min, 10 hours, 20 hours, 1 day, 5 days, 1 week, 1 month, 5 month, 1 year, 5 years, 10 years.
Notification Message:
for 10 min
You have completed Successfully 10 min
for 10 hours
You have completed Successfully 10 hours
From the little information provided, I would proceed like the following :
Look at NSUserDefaults to see what was the previous iteration
Define a start time based on that previous iteration (if any)
Schedule a local notification using the Local Notifications provided in the iOS SDK.
Save that same date/time in the NSUserDefaults.
Once we reach that time, the notification will be sent (by iOS), and we can execute code to repeat this sequence.

How to trigger esper as soon as the number of events exceed a threshold within time interval

I'd like to trigger esper as soon as it receives X number of events during an interval of Y minutes. I used this query but it triggers esper only 5 minutes after having received the first event and only if it's more then 10:
select count(*) as total
from report.win:time_batch(5 minutes)
where type = 'test_type'
having count(*) >= 10
I'd like to trigger it as soon as it gets 10 messages and of course, it should evaluate an interval of 5 minutes. I do not want to trigger it if, for instance, it receives 1 event every 10 minutes.
Any ideas?
Thanks!
select count(*) as total
from report(type = 'test_type')#time(5 minutes)
having count(*) >= 10
Above query outputs a row each time count 10 or more considering 5 minutes sliding. Add for example "output first every 1 minute" if the desired output is just once every X minutes.

How do I shift Google Sheets duration value from 35:55:00 to 0:35:55?

I have pasted multiple run duration values from Garmin into a Google Sheet. The longer runs (> 1 hour) copy/paste correctly. Eg: 2:10:35. The problem is shorter (< 1 hour) runs. Eg 35:55. The latter are being shown in Google Sheets as 35:55:00. Ie Google assumes 35:55 is 35 hours and 55 mins, not 35 mins and 55 seconds. So for my shorter sub 1 hour durations I need an easy way to convert 35:55:00 to 0:35:55.
As Tom Sharpe said, there is some room for interpretation in the data you have. But assuming that the duration of your runs is always between 10 minutes and 10 hours, we can disambiguate the values as follows:
=if(A1 > 10/24, A1/60, A1)
Numerically, the duration values are measured in days, so A1 > 10/24 means "more than 10 hours". In this case the value gets divided by 60.
Depending on your workout regime you may want to replace the threshold of 10 by another number; perhaps it's safer to say that the runs are always between 5 minutes and 5 hours.

Jenkins polled repository once then never again, though 1 minute interval is set

I've set up a Jenkins job and set the poll interval at 1 minute (I used this syntax 0 * * * *).
Looking in the Polling log I can see its reported that a poll call was made as soon as I saved the changes to the job.
But not over 10 minutes later it hasn't made any other polls.
Any suggestions how I can proceed determining the problem?
You're looking for "* * * * *".
Jenkins gives a warning since every minute can be a bit excessive, but your version control server shouldn't have any problems handling the load.
Your cron syntax is set to poll once per hour, at zero minutes past the hour. From the Jenkins help text:
This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace:
MINUTE HOUR DOM MONTH DOW
MINUTE Minutes within the hour (0-59)
HOUR The hour of the day (0-23)
DOM The day of the month (1-31)
MONTH The month (1-12)
DOW The day of the week (0-7) where 0 and 7 are Sunday.

Appointment Scheduling in ruby/rails

I am working on a call center software in rails and need to schedule appointments for agents that can handle calls for the customers. Having said the call center software, need to make sure that I schedule the appointments utilizing the entire agent's schedule as much as possible, leaving scope for least number of holes (where agent has no appointment).
Given an agent's schedule, for example 9:00AM to 5:30PM for a given day, with a lunch break of 30 minutes between 1:00PM - 1:30PM, I need to schedule appointments of varying length in duration, some 60 minutes and some 90 minutes.
And if some reason, lunch break is leaving some holes in the schedule, I should be able to move lunch break 30minutes +/-, so instead of 1:00PM - 1:30PM it could be moved between 1:30PM - 2:00PM or 12:30PM - 1:00PM.
I started off creating lunch breaks as a kind of appointment which will provide the flexibility of moving the starts_at and finishes_at attributes. And the appointments being either 60 minutes or 90 minutes, which are multiple of 30 minutes and lunch also being 30 minutes, I started off splitting agents schedule into slots of 30 minutes each.
So for a given agent on a given day, looking at his schedule I instantiated an array of slots each with a duration of 30 minutes and starts_at and finishes_at attributes be like 9:00AM - 9:30AM, 9:30AM - 10:00AM, etc.
I need some help on looping through this array of appointment slots and pull either 2 consecutive slots or 3 consecutive slots depending upon 60 or 90 minute duration appointment, keeping in mind that I should be able to move the lunch +/- 30 minutes.
Any help is much appreciated.
Looking at your problem:
Appointments are either 60 or 90 minutes long.
Lunch can vary between a 90 minute interval 12:30-2:00
And we want to minimize the amount of minutes that have no appointments.
Now, you have a time interval to fill, which is 9:00AM to 5:30pm. Assuming appointments fall between 9:00-5:30, we can use a greedy algorithm for interval scheduling based on earliest finish time (source) with your additional constraint.
Basically the algorithm is as follows (in pseudo)
Let R be the set of all appointments
Let R11 be the set of appointments from R before 12:30 that are compatible with 12:30-1:00 and R12 be the set of appointments from R after 1:00 that are compatible with 12:30-1:00
Let R21 be the set of appointments from R before 1:00 that are compatible with 1:00-1:30 and R22 be the set of appointments from R after 1:30 that are compatible with 1:00-1:30
Let R31 be the set of appointments from R before 1:30 that are compatible with 1:30-2:00 and R32 be the set of appointments from R after 2:00 that are compatible with 1:30-2:00
Let R1Comb = findSet(R11) + 12:30-1:00 + findSet(R12)
Let R2Comb = findSet(R21) + 1:00-1:30 + findSet(R22)
Let R3Comb = findSet(R31) + 1:30-2:00 + findSet(R32)
Function findSet(R)
Let A be the time interval to fill
While R is not empty
Choose a request r in R that has the smallest finishes_at
Add r to A
Remove all appointments in R that are not compatible with r
EndWhile
Return A
EndFunction
Return the R that has the smallest amount of holes in R1Comb, R2Comb, R3Comb
This algorithm makes use of a few concepts
An appointment r1 is not compatible with r2 if they overlap.
Because of #1, we know that Ri1/Ri2 for i=1,2,3 will not be conflicting with each other. Because if an appointment in Ri2 is not compatible with Ri1, then it is also not compatible with the lunch period, which is a contradiction because we took out all the non compatible appointments.
Once we split the set of appointments, then it's a matter of solving 2 scheduling problems, which can be solved greedily.
An this algorithm is still O(n log n) because you are doing the greedy algorithm 6 times (a constant), and each greedy iteration is O(n log n), and the first few lines and the last line are all O(n).
People write theses on scheduling and it's not an easy problem. I suggest you looking at http://www.asap.cs.nott.ac.uk/watt/resources/university.html to get a better understanding.
Good luck :)

Resources