Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to create alarm based on message count on Rule Chain #10753

Open
hzmacso opened this issue May 9, 2024 · 0 comments
Open

Is it possible to create alarm based on message count on Rule Chain #10753

hzmacso opened this issue May 9, 2024 · 0 comments
Assignees
Labels
question generic question

Comments

@hzmacso
Copy link

hzmacso commented May 9, 2024

image
I implemented a message count node to count the number of messages coming from the devices, and I want to create a threshold-based alarm after that. However, when I look at the data output of the message count node, I realize that the output is unique to each device (except with the same prefix "messageCount"), and I have also lost information such as the device name after this node:

# message count node
#-------------------------------
# input for device 1 and device 2 
#-------------------------------
{
    "deviceName": "Device1",
    "eventDetection": "true"
}
{
    "deviceName": "Device2",
    "eventDetection": "true"
}
#-------------------------------
# output for device 1 and device 2
#-------------------------------
    "messageCount_tb-rule-engine-0": 1
}

{
    "messageCount_tb-rule-engine-1": 0
}

In the next script node I then wrote a function to generalize all message count output to "messageCount": xxx

# script node
#-------------------------------
# output from message count node 
#-------------------------------
{
    "messageCount_tb-rule-engine-0": 1
}
#-------------------------------
# output from script node  
#-------------------------------
{
    "msg": {
        "messageCount": 1
    },
    "metadata": {
        "delta": "180000"
    },
    "msgType": "POST_TELEMETRY_REQUEST"
}

After that, there is a filter script to return msg.messageCount > 1;.

But then I realized that now the rule chain can't tell which device the messageCount is coming from, so even though there is an alarm raised, it can't be assigned to a particular device.
Is there a way to fix this?

The only reason I want to use the message count is that I want to count the number of messages every day, and after that, the counter should reset to 0. I can't find a way to do that except for using the message count node.

@hzmacso hzmacso added the question generic question label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question generic question
Projects
None yet
Development

No branches or pull requests

2 participants