Here's my Siddhi Code:
@App:name("IsAnalytics_Authentication_Aggregations")
@App:description("Handle Event from IS and save data in a table for Overall
Authentication")
@source(type='inMemory',
topic='IsAnalytics.Authentication.Common.OutputSinkFromProcessedAuthenticationDataStream',
@map(type='passThrough'))
define stream ProcessedAuthenticationDataStream (
meta_tenantId int,
eventId string,
username string,
localUsername string,
userStoreDomain string,
tenantDomain string,
remoteIp string,
region string,
inboundAuthType string,
serviceProvider string,
rememberMeEnabled bool,
forceAuthEnabled bool,
passiveAuthEnabled bool,
rolesCommaSeparated string,
authenticationStep string,
identityProvider string,
authStepSuccess bool,
stepAuthenticator string,
isFirstLogin bool,
successValue int,
failureValue int,
stepSuccessValue int,
firstLoginValue int,
identityProviderType string,
timestamp long
);
define stream PerUserRolesDuplicateEventStream (
meta_tenantId int,
eventId string,
username string,
localUsername string,
userStoreDomain string,
tenantDomain string,
remoteIp string,
region string,
inboundAuthType string,
serviceProvider string,
rememberMeEnabled bool,
forceAuthEnabled bool,
passiveAuthEnabled bool,
rolesCommaSeparated string,
authenticationStep string,
identityProvider string,
authStepSuccess bool,
stepAuthenticator string,
isFirstLogin bool,
successValue int,
failureValue int,
stepSuccessValue int,
firstLoginValue int,
identityProviderType string,
timestamp long,
token string
);
@store(type='rdbms', datasource='IS_ANALYTICS_DB')
define aggregation RoleAggregation
from PerUserRolesDuplicateEventStream
select
meta_tenantId,
username,
serviceProvider,
identityProvider,
token as role,
remoteIp,
region,
userStoreDomain,
sum(successValue) as authSuccessCount,
sum(failureValue) as authFailureCount,
sum(stepSuccessValue) as authStepSuccessCount,
identityProviderType,
timestamp
group by
meta_tenantId,
username,
serviceProvider,
token
aggregate by timestamp every second ... year;
@store(type='rdbms', datasource='IS_ANALYTICS_DB')
define aggregation AuthenticationStatAggregation
from ProcessedAuthenticationDataStream
select
meta_tenantId,
username,
localUsername,
rolesCommaSeparated,
serviceProvider,
identityProvider,
remoteIp,
region,
userStoreDomain,
sum(successValue) as authSuccessCount,
sum(failureValue) as authFailureCount,
sum(stepSuccessValue) as authStepSuccessCount,
sum(firstLoginValue) as authFirstSuccessCount,
identityProviderType,
timestamp
group by
meta_tenantId,
username,
localUsername,
remoteIp,
rolesCommaSeparated
aggregate by timestamp every second ... year;
from ProcessedAuthenticationDataStream#str:tokenize(rolesCommaSeparated,
',')
insert into PerUserRolesDuplicateEventStream;
I have two aggregations, AuthenticationStatAggregation and the
RoleAggregation. I need to retrieve aggregated data from the
AuthenticationStatAggregation, based on the role.
Issue with the "IN" operator is that if we have user roles like "Admin",
"SystemAdmin", "LocalAdmin", etc., query will match "Admin" for all these
entries. One way to overcome this is by storing them with a leading comma,
and search for ",admin,".
On Wed, Aug 8, 2018 at 5:26 PM Sajith Ariyarathna <[email protected]> wrote:
> Can you share your Siddhi code block here?
>
> I feel like what you have request here is similar to the functionality of
> SQL IN operator, rather than a regex.
>
> Also, have you tried to use the regexp function [1]?
>
> [1]
> https://wso2-extensions.github.io/siddhi-execution-string/api/4.0.19/#regexp-function
>
> Thanks.
>
> On Wed, Aug 8, 2018 at 5:16 PM Thisaru Guruge <[email protected]> wrote:
>
>> Hi all,
>>
>> I have a use case where I need to retrieve data from an aggregation using
>> regex.
>>
>> The exact scenario is that I have a comma separated string, where I need
>> to retrieve data if one of the comma separated value is matching a string.
>>
>> I used String tokenizer to tokenize the comma separated values, but then
>> it will create duplicate events, hence aggregate values can be misleading.
>> If we can match regex this can be avoided.
>>
>> I had a discussion with @Niveathika Rajendran <[email protected]> about
>> the matter, and what I learnt is that the "on" clause in siddhi matches the
>> strings using "equals" function in Java, hence regex might not work.
>>
>> Can we enhance it to match regex ? Or is there any workaround for this ?
>>
>> As per my understanding, it will be a huge load in the front end, if we
>> process this in the front-end side. Is it okay to process it in the front
>> end?
>>
>> Please comment.
>>
>> --
>> Thanks and Best Regards,
>> Thisaru Guruge
>> Software Engineer
>> Mobile: +94 71 720 9720
>>
>>
>> WSO2 Inc.: http://www.wso2.com
>>
>>
>>
>
> --
> Sajith Janaprasad Ariyarathna
> Senior Software Engineer; WSO2, Inc.; http://wso2.com/
> <https://wso2.com/signature>
>
--
Thanks and Best Regards,
Thisaru Guruge
Software Engineer
Mobile: +94 71 720 9720
WSO2 Inc.: http://www.wso2.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev