Create a new Alert for high consumption - ServicePoint level

#1

Hi, I created a new Alert based on a metric that return 0 or 1 based on the control of value consumption. I tesed the metric and it works fine.

Then I created an Alert at ServicePoint level to write a new record in ServicePointConsumptionAlert (type that extends Alert).

I have defined:

  1. DFE
  2. CompoundDFE
  3. Analytic
  4. The Analytic js process

If I tested from the console the Alert works fine (it inserts new record in the ServicePointConsumptionAlert when the metric returns 1).

AnalyticsContainer.fireAnalytics([{typeId:
Tag.getTypeId('MY_TENANT','ServicePoint'),objId:
'ServicePoint_ID',timeRanges: [{start: '2016-02-22T00:00:00', end:
'2016-02-29T10:00:00'}]}], ['AnalyticAlertId'],
{forceReEval: true})

Now I would like to know if the Analytic will be triggered automatically from the system when new data will be loaded in the Platform. How it works ?

Thanks,
Laura

0 Likes

#2

Yes, an analytic is triggered when new data comes in for the metric you have defined as the input to your DFE.

If your DFE definition looks like this:

@dfe(period="30DAY", interval="DAY", metric="MyBinaryMetric")
type MyBinaryMetricDFE mixes TSDataFlowEvent<ServicePoint>

then anytime new data for the input of MyBinaryMetric comes in, your analytic will be triggered.

For debugging purposes you can also take a look at these functions:

  • AnalyticsContainer.fireAnalytics
  • AnalyticsContainer.invalidateSources
  • AnalyticsQueue.invalidateSources
0 Likes

#3

Ok, thanks.
Is it possible to use the same DFE / CompoundDFE / Analytic for plus than one metrics?

For example, can I define more than one metric here?

> @DFE(interval='Hour', period='Hour', metric='METRIC_1', 'METRIC_2')

0 Likes

#4

There’s a 1:1 relationship between TSDataFlowEvents and metrics so you can’t do what you suggested, but the purpose of a CompoundDFE is to combine multiple simple DFEs

@dfe(period="30DAY", interval="DAY", metric="MyBinaryMetric")
type MyBinaryMetricDFE mixes TSDataFlowEvent<ServicePoint>
@dfe(period="30DAY", interval="DAY", metric="SomeSimpleMetric")
type SomeOtherSimpleDFE mixes TSDataFlowEvent<ServicePoint>
@DFE(interval='DAY', period='30Day', includeSpec='id,assetStatus.value')
type MyClassifierAnalyticInput mixes CompoundDataFlowEvent<ServicePoint> {
  simpleDfeOne: MyBinaryMetricDFE
  simpleDFETwo: SomeOtherSimpleDFE
}

A compound DFE will be triggered by any of its input simple DFEs firing.

1 Like

#5

Oh great!
Now I’m trying to test the alert inserting new values that should trigger the alarm, I see that are incresing in AnalyticsQueue the elements under columns “failed” and “unreviewedFailed” without the creation of the alarm. How can I see what goes wrong? If I launch the alert with fireAnalytics it works fine

0 Likes

#6

I launched the command
c3Grid(InvalidationQueueError.fetch({filter:"targetObjId=='ENGIEID_RMRIB_ELE_1'"}))

I tried to trigger the alarm several times and in the log I have different errors for each attempt, for example
errorMsg: unable to preprocess sources for 6 DFEs: C3RuntimeException: unable to load metric 'NaturalGasConsumptionInterval' for ID ENGIEID_RMRIB_ELE_1 (start 2016-10-01T00:00:00.000Z, end 2016-11-01T00:00:00.000Z): C3RuntimeException: c3.love.exceptions.C3RuntimeException: c3.love.exceptions.C3RuntimeException: MetricEngine error : c3.love.exceptions.C3RuntimeException: Error c3.love.exceptions.C3RuntimeException: Error ,msg Evaluating action 'null': c3.love.exceptions.C3RuntimeException: MetricEngine error : Metric with name 'IsBaseDD' for type 'BillingAccount' not found! Check seed data!

Or
errorMsg: unable to preprocess sources for 6 DFEs: C3RuntimeException: unable to load metric 'ProjectedBilledElectricitySpend' for ID ENGIEID_RMRIB_ELE_1 (start 2016-10-01T00:00:00.000Z, end 2016-11-01T00:00:00.000Z): C3RuntimeException: c3.love.exceptions.C3RuntimeException: c3.love.exceptions.C3RuntimeException: MetricEngine error : c3.love.exceptions.C3RuntimeException: Error c3.love.exceptions.C3RuntimeException: Error ,msg Evaluating action 'null': c3.love.exceptions.C3RuntimeException: MetricEngine error : Metric with name 'IsBaseDD' for type 'BillingAccount' not found! Check seed data!

And so on. Why is thrown an exception that does not seem to be connected to my alert metric ? I tryied to define IsBaseDD for BillingAccont, but I receive the same error…

1 Like

#7

Calling:
c3Grid(AnalyticsContainer.allDFEs())
I see all the DFE defined on my env.

Calling
c3Grid(AnalyticsContainer.allAnalytics())
I see all the Analytics defined on my env.

There is a way to enable / disable a specific Analytic ? If yes, which is the command?

0 Likes

#8

Check out this community post on the tenant config ACE-AnalyticsWhitelist. Unfortunately there is only an analytics whitelist at the moment; there isn’t any blacklist so if you want to disable a single analytic you have to set this whihtelist to be all analytics besides the one you want enabled.

0 Likes

#9

I tryed to set only my Analytics throught
TenantConfig.upsert({"id": "ACE-AnalyticWhiteList", value:"ConsumptionTooHighServicePointAlert"})

Now I can see the record in TenantConfig, but adding a new measure (that shoud be trigger my Alert) I receive an error regarding another Analytic.
errorMsg: unable to preprocess sources for 6 DFEs: C3RuntimeException: unable to load metric 'NaturalGasConsumptionInterval' for ID ENGIEID_RMRIB_ELE_1 (start 2016-10-01T00:00:00.000Z, end 2016-11-01T00:00:00.000Z): C3RuntimeException: c3.love.exceptions.C3RuntimeException: c3.love.exceptions.C3RuntimeException: MetricEngine error : c3.love.exceptions.C3RuntimeException: Error c3.love.exceptions.C3RuntimeException: Error ,msg Evaluating action 'null': c3.love.exceptions.C3RuntimeException: MetricEngine error : Metric with name 'IsBaseDD' for type 'BillingAccount' not found! Check seed data! from action BillingAccount.evalMetrics from env_server.js, line 128 126 if (C3._context.locale) 127 options.language = C3._context.locale; > 128 return C3.typesys.fromJava(c3CallAction(target, args, options)); 129 } 130 from typesys.js, line 1403 1401 1402 // call the server to execute this function as an action > 1403 response = c3Call(this, name, args); 1404 } 1405 from BillingAccount_trainElectricityModel.js, line 1673 1671 1672 // Evaluate the expressions written above. > 1673 evalMetricsOutput = sourceType.evalMetrics({ 1674 ids: [source.id], 1675 expressions: [consumptionExpr, hrsAvailExpr, hrsAvailWor... from

I have to refresh something ? I tryed to do
TenantConfig.refreshAnalytics()

But I have the error yet.

0 Likes

#10

I have a question regarding period and interval.
If I have two TSDataFlowEvent, one with
@DFE(interval='Month', period='Month', metric='Metric_One')
And another with
@DFE(interval='Day', period='Day', metric='Metric_Two')

In the CompoundDataFlowEvent (where I inserted a reference to the two DFEs) how can I say that the first DFE have interval and period equal to Month and the second DFE have interval and period equal to Day ? I saw that we define even in the CompoundDataFlowEvent the @DFE , but if I refer to different DFEs like my case how can I do?

0 Likes

#11

Any news about this topic? I would disable alerts but configuring TenantConfig with ACE-AnalyticWhiteList it seems not work. Furthermore I would know if I can have in the same CompoundDFE two different interval and period (having 2 DFE, one with interval and period equal to Day and the other with interval and period equal to Month).

Thanks,
Laura

0 Likes

#12
  1. ACE-AnalyticWhiteList value is array of strings with analytic names. You might need to have ACE-AnalyticGroups set up as well to make RefreshAnalytics work only seleceted analytics to be triggered.
  2. You can not have two different interval and period dfes on same compound dfe.
0 Likes

#13

Ok, thanks for the reply. I have fixed the problem with AnalyticWhiteList but I have a problem with the Alert: if I trigger it from the console it works, if I insert a new value as measure it doesn’t work. Could be related about the c3Type on which I defined the TSDFE and CompoundDFE ?
I defined my elements at FixedAsset level, the metrics called in the metricAlert are defined even at FixedAsset level, like
> “id”: “MeasuredElectricityDailyActiveEnergyConsumption_FixedAsset”,

      "name": "MeasuredElectricityDailyActiveEnergyConsumption",
      "srcType": {
        "moduleName": "structure",
        "typeName": "FixedAsset"
      },
      "expression": "sum(sum(normalized.data.quantity))",
      "path": "denormChildren.to.servicePoints.measurements.(measurementType == 'MeasuredElectricityDailyActiveEnergyConsumption')"

Now I want that if I insert a new measure related to a mesurementSeries with measurementType = “MeasuredElectricityDailyActiveEnergyConsumption” the alert starts and computes.

Defining an Alert at BasePhysicalMeasurementSeries level it works, maybe depends on the c3Type? Or it should work even at FixedAsset level (even if the measurement are not directly related to this object) ?

Thanks for the support!
Laura

0 Likes

#14

If the series header can be reached from path defined in metric, a TSDfe is defined for this metic and that dfe is used in an Analytic input, it should trigger invalidation.

0 Likes

#15

It doesn’t work. I defined the simple metric

{
“id”: “MeasuredElectricityDailyActiveEnergyConsumption_FixedAsset”,
“name”: “MeasuredElectricityDailyActiveEnergyConsumption”,
“srcType”: {
“moduleName”: “structure”,
“typeName”: “FixedAsset”
},
“expression”: “sum(sum(normalized.data.quantity))”,
“path”: “denormChildren.to.servicePoints.measurements.(measurementType == ‘MeasuredElectricityDailyActiveEnergyConsumption’)”,
“description”: “Measured Electricity Daily Active Energy Consumption”
},
{
“id”: “MeasuredElectricityDailyActiveEnergyConsumption_MeasurementSeries”,
“name”: “MeasuredElectricityDailyActiveEnergyConsumption”,
“srcType”: {
“moduleName”: “structure”,
“typeName”: “BasePhysicalMeasurementSeries”
},
“expression”: “max(normalized.data.quantity)”,
“path”: “self.(measurementType == ‘MeasuredElectricityDailyActiveEnergyConsumption’)”,
“description”: “Measured Electricity Daily Active Energy Consumption”
}

And a relative Compound metric that call the Simple, with the same “id”.

Then defined TS DFE

@DFE(period=‘HOUR’, interval=‘HOUR’, metric=‘MeasuredElectricityDailyActiveEnergyConsumption’)
type FAConsumptionAlarm mixes TSDataFlowEvent< FixedAsset >

Compound DFE

@DFE(period=‘HOUR’, interval=‘HOUR’)
type FAConsumptionAlarmInput mixes CompoundDataFlowEvent< FixedAsset > {
value : FAConsumptionAlarm
}

Analytic

type FAConsumptionAlarmAlert mixes Analytic< FAConsumptionAlarmInput, Void >{
process : ~ js server
}

And relative js process. Defining the same TS DFE , CompoundDFE , Analytic on BasePhysicalMeasurementSeries (instead of FixedAsset), if I insert a new value, the trigger works and I see a new alarm record in my table. For those TS DFE , CompoundDFE , Analytic at FixedAsset level (like shown previously) I have not a new record in Alarm table when I insert a new value. If I launch the metric it works at Facility/FixedAsset level, so I should have an alarm. Am I doing something wrong?

0 Likes

#16

may be the metric dependency were not updated correctly…which should have been done on metric updates or entity relation updates.
try FixedAsset.refreshDeps()

0 Likes

#17

Nothing. Actually I’m testing a measurementSeries of type “PhysicalMeasurementSeries” and doesn’t work. If I try to do the same on a measurement series of type “PointPhysicalMeasurementSeries” it seems to work! But we want that it works on all types, is this a bug? The decl of the two types are:

PointPhysicalMeasurementSeries
Mixes:
Persistable< PointPhysicalMeasurementSeries >
BasePhysicalMeasurementSeries
TimedDataHeader< PointMeasurement >

PhysicalMeasurementSeries
Mixes:
Persistable< PhysicalMeasurementSeries >
BasePhysicalMeasurementSeries
TimeseriesHeader< Measurement >

0 Likes