Siddhi query for event prior to another within time limit
I am trying to write a Siddhi query to detect if an event didn't happen prior to another within a time limit. The query I have to detect if 'X' didn't ever happen prior to 'Y' in the entire life of the siddhi application is:
from stream[value == 'Y']
and not stream[value == 'X']
I assumed adding a time constraint would work:
from stream[value == 'Y']
and not stream[value == 'X'] for 5 min
However, the 'for' statement never has any effect that I can see. This query is still triggered whether 'X' was 4 minutes ago or 6 minutes ago. I understand that a similar effect can be achieved by checking if 'Y' comes after 'X' within a time limit, but for my purposes I need to know the other way around.
Is this possible with Siddhi? If so can someone please provide a sample query that could achieve this?
cep siddhi stream-processing complex-event-processing
add a comment |
I am trying to write a Siddhi query to detect if an event didn't happen prior to another within a time limit. The query I have to detect if 'X' didn't ever happen prior to 'Y' in the entire life of the siddhi application is:
from stream[value == 'Y']
and not stream[value == 'X']
I assumed adding a time constraint would work:
from stream[value == 'Y']
and not stream[value == 'X'] for 5 min
However, the 'for' statement never has any effect that I can see. This query is still triggered whether 'X' was 4 minutes ago or 6 minutes ago. I understand that a similar effect can be achieved by checking if 'Y' comes after 'X' within a time limit, but for my purposes I need to know the other way around.
Is this possible with Siddhi? If so can someone please provide a sample query that could achieve this?
cep siddhi stream-processing complex-event-processing
I do not understand why "checking if 'Y' comes after 'X' within a time limit" does not achieve your requirement. It is the proper way to write this plus you will get the same result. Can you please explain?
– Tishan
Nov 17 '18 at 18:17
@Tishan Because if X happens Y may or may not happen. But if Y happens X must have happened.
– wearebob
Nov 18 '18 at 19:43
Yes I understand that. Yet you only need to identify if there is a 'X' prior to 'Y'. In other words for every 'Y' you need to check for a prior 'X' and if 'X' is there emit a result. If you can confirm above is the requirement we can do it using a pattern query. Upon confirmation Ill post an answer with a sample query
– Tishan
Nov 19 '18 at 9:16
It might help if I explain the use case. We are trying to use Siddhi to loosely model a state machine by mostly using sequence queries. But to make sure a user doesn't enter the state machine at some random state in the middle, we need to verify for each state whether the previous state happened within some time limit. If our state machine is 'X' -> 'Y' then the only way we can verify they didn't start at 'Y' is making sure 'X' already happened.
– wearebob
Nov 19 '18 at 14:58
add a comment |
I am trying to write a Siddhi query to detect if an event didn't happen prior to another within a time limit. The query I have to detect if 'X' didn't ever happen prior to 'Y' in the entire life of the siddhi application is:
from stream[value == 'Y']
and not stream[value == 'X']
I assumed adding a time constraint would work:
from stream[value == 'Y']
and not stream[value == 'X'] for 5 min
However, the 'for' statement never has any effect that I can see. This query is still triggered whether 'X' was 4 minutes ago or 6 minutes ago. I understand that a similar effect can be achieved by checking if 'Y' comes after 'X' within a time limit, but for my purposes I need to know the other way around.
Is this possible with Siddhi? If so can someone please provide a sample query that could achieve this?
cep siddhi stream-processing complex-event-processing
I am trying to write a Siddhi query to detect if an event didn't happen prior to another within a time limit. The query I have to detect if 'X' didn't ever happen prior to 'Y' in the entire life of the siddhi application is:
from stream[value == 'Y']
and not stream[value == 'X']
I assumed adding a time constraint would work:
from stream[value == 'Y']
and not stream[value == 'X'] for 5 min
However, the 'for' statement never has any effect that I can see. This query is still triggered whether 'X' was 4 minutes ago or 6 minutes ago. I understand that a similar effect can be achieved by checking if 'Y' comes after 'X' within a time limit, but for my purposes I need to know the other way around.
Is this possible with Siddhi? If so can someone please provide a sample query that could achieve this?
cep siddhi stream-processing complex-event-processing
cep siddhi stream-processing complex-event-processing
asked Nov 16 '18 at 23:55
wearebobwearebob
156
156
I do not understand why "checking if 'Y' comes after 'X' within a time limit" does not achieve your requirement. It is the proper way to write this plus you will get the same result. Can you please explain?
– Tishan
Nov 17 '18 at 18:17
@Tishan Because if X happens Y may or may not happen. But if Y happens X must have happened.
– wearebob
Nov 18 '18 at 19:43
Yes I understand that. Yet you only need to identify if there is a 'X' prior to 'Y'. In other words for every 'Y' you need to check for a prior 'X' and if 'X' is there emit a result. If you can confirm above is the requirement we can do it using a pattern query. Upon confirmation Ill post an answer with a sample query
– Tishan
Nov 19 '18 at 9:16
It might help if I explain the use case. We are trying to use Siddhi to loosely model a state machine by mostly using sequence queries. But to make sure a user doesn't enter the state machine at some random state in the middle, we need to verify for each state whether the previous state happened within some time limit. If our state machine is 'X' -> 'Y' then the only way we can verify they didn't start at 'Y' is making sure 'X' already happened.
– wearebob
Nov 19 '18 at 14:58
add a comment |
I do not understand why "checking if 'Y' comes after 'X' within a time limit" does not achieve your requirement. It is the proper way to write this plus you will get the same result. Can you please explain?
– Tishan
Nov 17 '18 at 18:17
@Tishan Because if X happens Y may or may not happen. But if Y happens X must have happened.
– wearebob
Nov 18 '18 at 19:43
Yes I understand that. Yet you only need to identify if there is a 'X' prior to 'Y'. In other words for every 'Y' you need to check for a prior 'X' and if 'X' is there emit a result. If you can confirm above is the requirement we can do it using a pattern query. Upon confirmation Ill post an answer with a sample query
– Tishan
Nov 19 '18 at 9:16
It might help if I explain the use case. We are trying to use Siddhi to loosely model a state machine by mostly using sequence queries. But to make sure a user doesn't enter the state machine at some random state in the middle, we need to verify for each state whether the previous state happened within some time limit. If our state machine is 'X' -> 'Y' then the only way we can verify they didn't start at 'Y' is making sure 'X' already happened.
– wearebob
Nov 19 '18 at 14:58
I do not understand why "checking if 'Y' comes after 'X' within a time limit" does not achieve your requirement. It is the proper way to write this plus you will get the same result. Can you please explain?
– Tishan
Nov 17 '18 at 18:17
I do not understand why "checking if 'Y' comes after 'X' within a time limit" does not achieve your requirement. It is the proper way to write this plus you will get the same result. Can you please explain?
– Tishan
Nov 17 '18 at 18:17
@Tishan Because if X happens Y may or may not happen. But if Y happens X must have happened.
– wearebob
Nov 18 '18 at 19:43
@Tishan Because if X happens Y may or may not happen. But if Y happens X must have happened.
– wearebob
Nov 18 '18 at 19:43
Yes I understand that. Yet you only need to identify if there is a 'X' prior to 'Y'. In other words for every 'Y' you need to check for a prior 'X' and if 'X' is there emit a result. If you can confirm above is the requirement we can do it using a pattern query. Upon confirmation Ill post an answer with a sample query
– Tishan
Nov 19 '18 at 9:16
Yes I understand that. Yet you only need to identify if there is a 'X' prior to 'Y'. In other words for every 'Y' you need to check for a prior 'X' and if 'X' is there emit a result. If you can confirm above is the requirement we can do it using a pattern query. Upon confirmation Ill post an answer with a sample query
– Tishan
Nov 19 '18 at 9:16
It might help if I explain the use case. We are trying to use Siddhi to loosely model a state machine by mostly using sequence queries. But to make sure a user doesn't enter the state machine at some random state in the middle, we need to verify for each state whether the previous state happened within some time limit. If our state machine is 'X' -> 'Y' then the only way we can verify they didn't start at 'Y' is making sure 'X' already happened.
– wearebob
Nov 19 '18 at 14:58
It might help if I explain the use case. We are trying to use Siddhi to loosely model a state machine by mostly using sequence queries. But to make sure a user doesn't enter the state machine at some random state in the middle, we need to verify for each state whether the previous state happened within some time limit. If our state machine is 'X' -> 'Y' then the only way we can verify they didn't start at 'Y' is making sure 'X' already happened.
– wearebob
Nov 19 '18 at 14:58
add a comment |
1 Answer
1
active
oldest
votes
Based on your comment I am composing below answer.
Sequence construct in Siddhi will guarantee that no one can enter the state flow at a random point. As an example let's take below sample sequence query.
from every e1=InputStream[state='X'], e2=InputStream[state'Y']
select e1.state as initialState, e2.state as finalState
insert into NextStream;
So in here we are mandating X followed by a consecutive Y. If Y occurs before X sequence construct will handle that and discard Y. So whatever goes into NextStream is guaranteed to satisfy x -> Y state transition.
More relaxed construct of sequence is pattern. It is same as sequence while relaxing the consecutive arrival requirement. Hope this helps!!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346871%2fsiddhi-query-for-event-prior-to-another-within-time-limit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Based on your comment I am composing below answer.
Sequence construct in Siddhi will guarantee that no one can enter the state flow at a random point. As an example let's take below sample sequence query.
from every e1=InputStream[state='X'], e2=InputStream[state'Y']
select e1.state as initialState, e2.state as finalState
insert into NextStream;
So in here we are mandating X followed by a consecutive Y. If Y occurs before X sequence construct will handle that and discard Y. So whatever goes into NextStream is guaranteed to satisfy x -> Y state transition.
More relaxed construct of sequence is pattern. It is same as sequence while relaxing the consecutive arrival requirement. Hope this helps!!
add a comment |
Based on your comment I am composing below answer.
Sequence construct in Siddhi will guarantee that no one can enter the state flow at a random point. As an example let's take below sample sequence query.
from every e1=InputStream[state='X'], e2=InputStream[state'Y']
select e1.state as initialState, e2.state as finalState
insert into NextStream;
So in here we are mandating X followed by a consecutive Y. If Y occurs before X sequence construct will handle that and discard Y. So whatever goes into NextStream is guaranteed to satisfy x -> Y state transition.
More relaxed construct of sequence is pattern. It is same as sequence while relaxing the consecutive arrival requirement. Hope this helps!!
add a comment |
Based on your comment I am composing below answer.
Sequence construct in Siddhi will guarantee that no one can enter the state flow at a random point. As an example let's take below sample sequence query.
from every e1=InputStream[state='X'], e2=InputStream[state'Y']
select e1.state as initialState, e2.state as finalState
insert into NextStream;
So in here we are mandating X followed by a consecutive Y. If Y occurs before X sequence construct will handle that and discard Y. So whatever goes into NextStream is guaranteed to satisfy x -> Y state transition.
More relaxed construct of sequence is pattern. It is same as sequence while relaxing the consecutive arrival requirement. Hope this helps!!
Based on your comment I am composing below answer.
Sequence construct in Siddhi will guarantee that no one can enter the state flow at a random point. As an example let's take below sample sequence query.
from every e1=InputStream[state='X'], e2=InputStream[state'Y']
select e1.state as initialState, e2.state as finalState
insert into NextStream;
So in here we are mandating X followed by a consecutive Y. If Y occurs before X sequence construct will handle that and discard Y. So whatever goes into NextStream is guaranteed to satisfy x -> Y state transition.
More relaxed construct of sequence is pattern. It is same as sequence while relaxing the consecutive arrival requirement. Hope this helps!!
answered Nov 20 '18 at 9:23
TishanTishan
68049
68049
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346871%2fsiddhi-query-for-event-prior-to-another-within-time-limit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I do not understand why "checking if 'Y' comes after 'X' within a time limit" does not achieve your requirement. It is the proper way to write this plus you will get the same result. Can you please explain?
– Tishan
Nov 17 '18 at 18:17
@Tishan Because if X happens Y may or may not happen. But if Y happens X must have happened.
– wearebob
Nov 18 '18 at 19:43
Yes I understand that. Yet you only need to identify if there is a 'X' prior to 'Y'. In other words for every 'Y' you need to check for a prior 'X' and if 'X' is there emit a result. If you can confirm above is the requirement we can do it using a pattern query. Upon confirmation Ill post an answer with a sample query
– Tishan
Nov 19 '18 at 9:16
It might help if I explain the use case. We are trying to use Siddhi to loosely model a state machine by mostly using sequence queries. But to make sure a user doesn't enter the state machine at some random state in the middle, we need to verify for each state whether the previous state happened within some time limit. If our state machine is 'X' -> 'Y' then the only way we can verify they didn't start at 'Y' is making sure 'X' already happened.
– wearebob
Nov 19 '18 at 14:58