How to transmit alert variables by E-mail message - iot

I’m a newbie in AggreGate IoT platform and I’m trying to use its Alerts feature. I need to insert the name of the device that triggered the alert into the email message being sent.
I see some Alert Examples in the documentation but I can’t find the way to extract the context of the current device. I’ve tried to write the Alert Message expression like {env/context} or cell({env/context},"value") but it has no effect.
Please help me to make it work.

You need to send e-mail when Alert rises or deactivates, but with your own subject and message format.
Open "Automatic Corrective Actions" tab
Add action "Execution type" - Rise, "Action" - Send E-mail and click on "Parameters" field.
You should see e-mail sending parameters, such as Recipients, Subject, message, etc. You can write it by yourself or use bindings, in our case we will use bindings.
To get variables from alert we should use an expression for ex. "cell({env/value},"trigger")". This expression will return "Trigger message". You can get any variables that we have in Alert Event (see attached screenshot).
When you get variable value, you can use it with AggreGate expression language. For example, if you get cell({env/value}, "context") it will return context of the device for which this alert was set. You need to get name of this device, using context - you can write expression cell(getVariable(cell({env/value}, "context"),"genericProperties"),"name").

Related

Can grafana include the current timestamp in an alert notification's message?

I’ve a request to include the time when an alert was raised in the message body of the email for that alert.
I’ve checked out Create Alerts and Alert notification templating and it looks like it might be possible, but I can’t find any reference to any list of supported variables.
For reference, we're using Grafana v7.4.0 (c2203b9859) and creating an alarm off a cloudwatch metric query:
REMOVE_EMPTY(SEARCH('{"AWS/ApiGateway","ApiName","Method","Resource","Stage"} MetricName="5XXError"', 'Sum', 60))
So there's nothing in the results we can use for this, unless anyone knows of a way to pull the last timestamp out of one of the datatables ;)
What I’m trying to do is include something like this, in the email being sent out when this alert is triggered (although the actual date format doesn’t matter at all):
Alert raised at 2021-08-26T12:03
Thanks

How to send task name instead of alert id in kapacitor?

when an alert triggered in kapacitor, it sends alert id (name of the alert that's defined in chronograf UI), but I need its task name that's generated automatically.
I'm trying to find out which CLEAR event belongs to which CRITICAL event.
In this image, id field is alert name not alet's auto generated id.
this is debug screenshot
When we use chronograf UI, it generates own TICK script for kapacitor. So it defines alert name as alert id into the frontend. I solved my problem with kapacitor APIs.

Assert_receive to test Genserver message handlers?

I would like to be able to catch messages going to my GenServer's handle_info in tests, to check those are what I intend to.
1/ Is there a way to print somehow every message coming through?
2/ Using assert_receive is there a way to catch those messages? Should I set the assert_receive before or after the call to the external service that will result in the handle_info trigger? What syntax should I use?
I tried many combinations of assert_receive and I tried a receive do... to try and display messages getting in, with no success.
Both ExUnit.Assertions.assert_receive/3 and ExUnit.Assertions.assert_received/2 do assert messages coming into the current process’ mailbox. The former is to be called either before or after the message was actually sent:
Asserts that a message matching pattern was or is going to be received within the timeout period, specified in milliseconds.
the latter is to be called after:
Asserts that a message matching pattern was received and is in the current process’ mailbox.
That said, both are unlikely a good fit to test the existing GenServer. Messages are to arrive at the GenServer’s messagebox, this functionality is provided by OTP and you should not test it. If you need to log messages, add a call to Logger.log/3 to the handle_info/2 and check the log actually happens with ExUnit.CaptureLog.capture_log/2. If it performs some action upon message arrival, test this action.
In general, you should test your code, not OTP.

Passbook Update Notification Message

I have a small problem with the notification message shown on the device when the pass is updated. I want the message to be what I set in the "changeMessage" in one of the Pass Structure Dictionary Keys. Instead what is displayed is what I am assuming to be the default change message which is "Coupon changed". I have "changeMessage" key in the "backFields" key. I have set the value of that key to some text of my own (which does not include "%#" as said in the description of key here).
Due to the requirements I am working on, I cannot use "%#" there, as it will just replace it with the whole value against the "value" key. So any way to accomplish this yet still ?
Unless %# is present in the message, you will only ever see the generic message "Coupon Changed" that you have described.
If you do not want the field value to show then you can include the message you want then pad with spaces before ending in %#. The spaces will ensure that the value is not shown on the lock screen and should help achieve your goal.

Copying a list of subscribed data in System center orchestrator

I'm using System Center Orchestrator 2012, and I have a generic error handler which is connected to all the activities in my runbook.
I have subscribed to a list of published data as a parameter in this error handler, which looks like this:
Activity Name : {Activity Name from "Monitor File"}{Activity Name from "Move file"}.......
What I need to do is copy this list of subscribed data and do a search and replace to change the Activity Name parameter to something else, say Error Message. Whenever I copy this list of variables, I get gibberish when I paste it
\`d.T.~Ed/{598EBDFA-BF5B-4B77-8156-E6FA6ECD0CE1}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{6838D741-DF8E-4C25-8C28-D06A52F67D36}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{D1D9BBE6-5AAF-4D8F-A98A-1A8BDD977E7E}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{9EC92323-1B9B-4D06-88E9-A97BA525CF5A}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{FAD32B4C-92CC-40BD-837A-4C5F22C2E018}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{DFF7A110-ACFD-4377-AFEC-16B5BEC8BFF4}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{139ACC4E-CF6D-4EEE-BD88-9DC1E0FC2038}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{1484789C-BB37-4507-AD21-E367665E0BE6}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{01EA8BD0-69C5-4959-86DB-29FAD34D144A}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{A60C582B-5DD0-41F7-BB0A-B5D71C3B9ECB}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{1FA1E2D6-813D-4A4A-A5CD-07EB2AD4AC9B}.Object.Name\`d.T.~Ed/
Is there a way to simply copy the text? If not, I will have to click on all the activities over and over again to subscribe to different types of data.
Thanks in advance
The gibberish you're seeing is how Orchestrator translates the published data and variables to the database guids. Copying this out will always translate to the DB guids, so there's no way to do a copy/replace with "activity name" for "Error Summary". You'd need to subscribe to each activity's data or look up all of the guids which probably wouldn't be easier.
Unfortunately, setting up the error handling process in SCOrch becomes tedious to be effective.
I use a separate email linked to each activity to give more information based on the error message. I don't like to use generic error emails with published data from multiple activities since it doesn't necessarily give all the useful information you need (or an end user will be able to understand).

Resources