Grafana alert feature is not working and throwing the error message “The data source does not support alerting queries”

This is an adapter that is configured with a connection string, there are no config file parameters for this feature.

Open the openHistorian UI Manager (not the web interface) and navigate to Actions > Manage Custom Actions then go to the last page of actions, i.e., click the >> button on the bottom right of the page. Now click Add New button and select E-Mail Notifier from the Type list.

This will create an e-mail based on a custom boolean expression, for example:

VariableList={x = PPA:1; y = PPA:2};
ExpressionText=x+y > 0

You will also need to set all the e-mail parameters…

Thanks,
Ritchie

Here is another article you might find useful for dynamic expressions like those used in the 'E-Mail Notifier`:

Hi Ritchie,

Thanks for your clarification and able to configure the email alert message successfully.

I have some additional queries, please clarify

  1. How to use actual variable in email body?

VariableList= {x = PPA:20274};

I need to use variable X in email body

  1. How to add current time as part of email body?
  2. If I need to send message for each measurement independently, what is the procedure?
    E.g.
  3. PPA:20274
  4. PPA:20275

If PPA: 20274 > 0 then I need to send email to different set of receipts (like A, B and C)
If PPA: 20275 > 20 then I need to send email to different set of receipts (like P, Q and R)

Can we use single email notification configuration, or do I need to setup independent alarm for each measurement and set separate email notifier?

Please clarify.

Thanks & Regards
Logu

So it didn’t have that feature, but it was super easy to add - so I put that option in the code:

So now you can have a body like the following:

Body={This is my e-mail text. The value of x is: {x}. The local time is: {LOCALTIME}}; 

I would use different adapter instances for different measurements.

FYI - this change will be in next nightly build which happens around midnight or so in the US Eastern time zone. Once built, you can download and install from here:
https://gridprotectionalliance.org/NightlyBuilds/openHistorian/Beta/openHistorian.Installs.zip

Thanks,
Ritchie

By the way, this supports string formatting like the following:

Body={This is my e-mail text.
The value of x is: {x:N3}.
The local time is: {LOCALTIME:yyyy-MM-dd HH:mm:ss.fff}}; 

Hi ritchi,

Thanks for your quick response.

When alarm is raised, email notifier is keep sending lot of emails per minute.

We have configured an alarm and it was raised only 2 times for the past 24 hrs, but we received around 3000 emails.

Am I missing any configuration?

Please clarify

Thanks & Regards
Logu

Are you sure you are alarming off of the alarm measurement? You’ll need to give me some more context, like alarming parameters, frequency of alarm input, e-mail adapter connection string, etc.

Hi Ritchie,

Please find all settings,

Alarm Settings:

  1. • Tag Name: AL-HIGH: ABCX !TP!ABC:FREQ
  2. • Operation: Greater than
  3. • Alarm point: 50.05
  4. • Hysteresis: 5
  5. • Severity :HIGH
  6. • Load order 0
  7. • Enabled : Yes
  8. • Create Associated Measurement: Yes
    Alarm Service connection String
    • Name: Alarm ! Services
    • Connection String : useAlarmLog=True; FramesPerSecond=30

Email Notifier connection string
From=abc@Test.com.au; SmtpServer=Test; Subject=OpenHistorian Alarm; Body={The value of x is: {x}.}; ToRecipients=abc@Test.com.au; VariableList={x = PPA:20274}; ExpressionText=x > 50.050; FramesPerSecond=1

Please review it and let us know, where it needs to be corrected?

You need to use both the alarm value (for the trigger - set to ‘x’) and the include the frequency value (for the e-mail - set to ‘y’). You then need to set the e-mail condition trigger to only evaluate when the alarm is triggered, i.e., ExpressionText=x > 0.

You will need to process values continuously to pull this off, so frame rate will need to match frequency rate, e.g., 30, and you will need to set UseLatestVaues to false so that measurements are processed at their native rate.

Also, since the alarm value will arrive rarely and the frequency value will arrive consistently, the alarm value will be substituted with a sentinel value which defaults to NaN. We set sentinel value to -1 instead to produce a cleaner negative answer to the expression condition of x > 0 which will be evaluated with each received frequency. See updates to connection string below:

Email Notifier connection string

From=abc@Test.com.au; SmtpServer=Test; Subject=OpenHistorian Alarm;
Body={The frequency value (y) is {y:N3}.}; ToRecipients=abc@Test.com.au;
VariableList={x = AL-HIGH:ABCX!TP!ABC:FREQ; y = PPA:20274};
ExpressionText=x > 0; FramesPerSecond=30; LeadTime=5.0; LagTime=5.0;
UseLatestValues=false; SentinelValue=-1.0

Hi Ritchi,

Thanks for your reply.

I’m using below connection string for email notifier,

From=abc@Test.com.au; SmtpServer=Test; Subject=OpenHistorian Alarm; Body={The value of x is: {x}.}; ToRecipients=abc@Test.com.au; VariableList={x = AL-HIGH:NOJA_AZURE!EQL!NP!ECROWE:FREQ; y = PPA:20274}; ExpressionText=x > 0; FramesPerSecond=30; LagTime=5; UseLatestValues=False; SentinelValue=-1.0

But I’m getting below error while specifying the alarm tag as part of expression. I’m using openHistorian 2.6.x. Is there any limitation?

[6/19/2020 11:56:28 AM] [Action Adapter Collection] Failed to initialize adapter ALERT_EMAIL_NOTIFIER: The value is not in the correct format for a MeasurementKey value

[6/19/2020 11:56:28 AM] (Inner Exception)
Date and Time: 6/19/2020 11:56:28 AM
Machine Name: NOJA-180
Machine IP: fe80::341b:7fcc:e46d:cc2c%12
Machine OS: Microsoft Windows NT 6.2.9200.0

Application Domain: openHistorian.exe
Assembly Codebase: C:/Program Files/openHistorian/openHistorian.exe
Assembly Full Name: openHistorian, Version=2.6.30.2, Culture=neutral, PublicKeyToken=null
Assembly Version: 2.6.30.2
Assembly Build Date: 3/31/2020 5:29:18 PM
.Net Runtime Version: 4.0.30319.42000

Exception Source: GSF.TimeSeries
Exception Type: System.FormatException
Exception Message: The value is not in the correct format for a MeasurementKey value
Exception Target Site: Parse

---- Stack Trace ----
GSF.TimeSeries.MeasurementKey.Parse(value As String)
openHistorian.exe: N 00094
DynamicCalculator.DynamicCalculator.GetKey(token As String)
openHistorian.exe: N 00048
DynamicCalculator.DynamicCalculator.AddAliasedVariable(token As String)
openHistorian.exe: N 00108
DynamicCalculator.DynamicCalculator.set_VariableList(value As String)
openHistorian.exe: N 00280
DynamicCalculator.DynamicCalculator.Initialize()
openHistorian.exe: N 00151
DynamicCalculator.EmailNotifier.Initialize()
openHistorian.exe: N 00378
GSF.TimeSeries.Adapters.AdapterCollectionBase`1.Initialize(item As T)
openHistorian.exe: N 00359

You can’t use the point tag for variables. You’ll need to use the measurement key of that alarm measurement. You can find it on the Manage Measurements page in the ID column. It has the format STAT:###.

Hi Stephen,

Earlier I used VariableList={x = PPA:20274};, but it was keep sending the email, more than 1500 per events.

Ritchi suggested to use
VariableList={x = AL-HIGH:ABCX!TP!ABC:FREQ; y = PPA:20274};
But I’m getting initialization error.

Is there any problem with openHistorian 2.6.x?

No, the problem is x = AL-HIGH:ABCX!TP!ABC:FREQ. You need to go to the Manage Measurements page, search for that measurement, record what’s in the ID column, and then use that in your variable list instead.

Hi Stephen,


Here PPA11:20274 is the key.
Please tell me, how should I write?
VariableList={x = AL-HIGH:NOJA_AZURE!EQL!NP!ECROWE:FREQ; y = PPA:20274};

Logu

Looks to me like it should be VariableList={ x=STAT:20371; y=PPA:20274 }.

Ok thanks. Let me check

Thanks Stephen,
Its working fine now.
Also printing actual measurement value as part of email body using {y}, is not working. I believe it has been implemented couple of days before. Please confirm.
Because I can not use latest version as of now.

Yes, the feature Ritchie implemented to display measurement values in the body of the email was added to version 2.7.219, which was built around 30 minutes after midnight (US Eastern Time) on June 17.

Hi Stephen,

I configured alarm with below configuration.

If FREQ > 50 then raise alarm.

Email is configured below manner:

From=abc@Test.com.au; SmtpServer=Test; Subject=OpenHistorian Alarm; Body={The value of x is: {x}.}; ToRecipients=abc@Test.com.au; VariableList={x=STAT:20371; y=PPA:20274}; ExpressionText=x > 0; FramesPerSecond=30; LagTime=5; UseLatestValues=False; SentinelValue=-1.0

Actual output:
When FREQ become 50.1, alarm was raised one time and received one email and FREQ was above 50 for another 2 mins, but I received 1 email at the first time.

Can you please clarify.
How will Alarm notification engine work? will it keep notify or will do at fist time ?
again going back to below 50 then again come back to above 50 then will It raise?

Logu

Hi Logu,

When the alarm adapter starts, all alarms assume the Cleared state.

The Operation, Alarm Point, and Delay define the conditions under which the alarm will enter the Raised state. Using your alarm as an example, and assuming your Delay is unset, the alarm will enter the Raised state the moment the frequency reaches a value above 50.05.

Once the value is in the Raised state, the Operation, Alarm Point, and Hysteresis define the conditions under which the alarm will enter the Cleared state. Again using your alarm as an example, the alarm will enter the Cleared state the moment the frequency reaches a value at or below 45.05.

Alarm measurements signal state changes in the alarms. When an alarm enters the Raised state, the system generates an alarm measurement with a value of 1. Conversely, when an alarm enters the Cleared state, the system generates an alarm measurement with a value of 0.

Since alarm measurements are only generated when alarm state changes, it’s easier to control when emails get sent out if we use alarm measurements. In your case, we used the condition x > 0, which evaluates to true when the alarm measurement enters the Raised state.

Thanks,
Stephen