Grafana 2 queries in same panel but set query interval difference - grafana

I have 2 queries in a grafana panel.
I want to run Query A every 5 min
I want to run Query B every 10 min, so I can check the value difference between each query using transform.
How can I set the query interval, I know I can change scrape interval but my goal here is to check pending messages and if it doesnt change in 10 min trigger an alert. I am trying to get a count at 1st minute and get count again at 10th minute. check the difference using transform and trigger an alert if no change (messages are not getting processed )
using grafana 7
Thanks !

Related

What does Window hopping mean?

I am reading tutorial for beginners in KSQLDb.
I have faced with table query:
CREATE TABLE pageviews_per_region_per_30secs10secs AS
SELECT regionid,
count(*)
FROM pageviews_enriched
WINDOW HOPPING (SIZE 30 SECONDS, ADVANCE BY 10 SECONDS)
WHERE UCASE(gender)='FEMALE' AND LCASE (regionid) LIKE '%_6'
GROUP BY regionid
EMIT CHANGES;
Below is definition query:
The following query is the same query as above that computes the count
for hopping window of 30 seconds that advances by 10 seconds.
Does it mean to take out data during 30 seconds with 10 seconds delay?
When to use WINDOW HOPPING?
Windowing allows you to group records through time. So this works like GROUP BY clauses in queries and provides further grouping.
The difference between a Hopping and Tumbling Window is the end time of the aggregation. With Tumbling Windows, you are grouping from a start time (WINDOWSTART()) to an end time (WINDOWEND()) in fixed intervals. Once the end time occurs, the start time begins again.
With Hopping Windows, the start time does not have to wait for an end time to begin the next window, so windows can overlap. The SIZE on Tumbling and Hopping windows is the same, the size, or length of time of the aggregation. The ADVANCE BY in Hopping Windows is the delay before starting this next aggregation.
So, an example, if you are aggregating the amount of Female users in region 6, with a Hopping Window, an aggregation datapoint, or Female user page view, can belong to two windows. With a Tumbling Window, the window timeframes are distinct and do not overlap, so the datapoints will only be counted once per timeframe.
There are some nice charts in this doc to show how the windows overlap or not through time.

Count and Time window in Esper EPL

I have the following use case, which I'm trying to write in EPL, without success. I'm generating analytics events of different types, generated in different intervals (1min, 5min, 10min, ...). In special kind of analytics, I need to collect 4 specific
Analytics events (from which I will count another analytic event) of different types, returned every interval (1min, 5min, 10min, ...). The condition there is, that on every whole interval, e.g., every whole minute 00:01:00, 00:02:00 I want to have returned either 4 events or nothing if the events don't arrive in some slack period after (e.g., 2s).
case 1: events A,B,C,D arrive at times 00:01:00.500, 00:01:00.600, 00:01:00.700, 00:01:00.800 - right after fourth event arrives to esper, the aggregated event with all 4 events is returned
case 2: slack period is 2seconds, events A,B,C,D arrives at 00:01:00.500, 00:01:00.600, 00:01:00.700, 00:01:02.200 - nothing is arrived, as the last event is out of the slack period
You could create a trigger event every minute like this:
insert into TriggerEvent select * from pattern[timer:schedule(date:'1970-01-01T00:00:00.0Z', period: 1 minute, repetitions: -1)]
The trigger that arrives every minute can kick off a pattern or context. A pattern would seem to be good enough. Here is something like that:
select * from pattern [every TriggerEvent -> (a=A -> b=B -> c=C -> d=D) where timer:within(2 seconds)]

Prometheus / Grafana highest value and time

Is it possible in grafana with a prometheus backend to determine the highest value recorded for the lifetime of a data set, and if so, determine the time that the value occurred?
For example, I'm using site_logged_in as the query in a Singlestat panel to get the current number of logged in users, along with a nice graph of recent activity over the past hour. Wrapping that in a max() seems to do nothing, and a max_over_time(site_logged_in[1y]) gives me a far too low number.
The value is a single gauge value coming from the endpoint like so
# HELP site_logged_in Logged In Members
# TYPE site_logged_in gauge
site_logged_in 583
Is something like determining highest values even a realistic use case for prometheus?
max_over_time(site_logged_in[1y]) is the max over the past year, however this presumes that you have a year worth of data to work from.
The highest value over the specified time range can be obtained with max_over_time() function. For example, the following value would return the maximum value for site_logged_in metric over the last year:
max_over_time(site_logged_in[1y])
Unfortunately Prometheus doesn't provide the function for returning the timestamp for the maximum value. If you need to obtain the timestamp for the maximum value, then you can use tmax_over_time() function from MetricsQL. For example, the following MetricsQL query returns the timestamp in seconds for the maximum value of site_logged_in metric over the last year:
tmax_over_time(site_logged_in[1y])

want to reset values after some time using scheduler or db event

I have a jsp like:
rule 1 : value
rule 2 : value
Time interval in min :value
I am saving these values to DB
depending on the value of time interval field I want to reset the value of rule 1 and rule 2 to a default value in DB
This time interval can be changed any time even before previous interval is not completed,means it needs to be updated dynamically whatever approach I choose
I am using Sprig MVC and oracle
I opted for
ThreadPoolTaskScheduler
but now problem is as soon as I used
threadPoolTaskScheduler.schedule(runnableObj,trigger);
it is getting executed immediately and then executes on proper interval of 1 min but I want to skip first execution for that I have used PeriodicTrigger
which has method named setInitialDelay() but it is not delaying it
Please provide some insight for this kind of problems as I am doing it first time
I think I solved it using ThreadPoolTaskScheduler
For more info visit http://www.baeldung.com/spring-task-scheduler
Some interesting Spring Scheduling information.

Counting the number of times a specific hour appears in a column after extraction in postgresql

after using the extract function to extract an hour value from a timestamp in postgresql, how can I count the number of times each value appears? I'm trying to produce the number of calls coming into a helpdesk based on time of day. So I need to be able to count the number that came in at 2pm, 3pm, 4pm and so on. Thanks for any help.