cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

condition matching in Workflow

roberto_camp1
Visitor

I am trying to create a Workflow that responds to a DQL query where it seems like the metric is occasionally showing an empty records array.

I would like to trigger some specific action if the `"records": [],` is present.

It seems like the fundamental issue is the Workflow condition matcher is not recognizing this syntax:

```
{{ result("httpendpointsuccess").records == [] }}
```


Error evaluating custom condition - Undefined variables in '{{ result("httpendpointsuccess").records }}': records


It is happy with this syntax however:

```
{{ result("httpendpointsuccess") }}

```

In the Result analysis, it purports that result("httpendpointsuccess") returns two items, "0" and "1". (Which is true because these represent looping through a two-item list for AWS accounts)

Item 0 looks like this:

```
{
"types": [],
"records": [], # THIS IS THE PROBLEM I WANT TO TAKE ACTION ON
"metadata": {
"grail": {

"scannedDataPoints": 0,
"executionTimeMilliseconds": 27
},
"metrics": [
{
"fieldName": "deliveryToHttpEndpointSuccessByAccountIdDeliveryStreamNameRegion",
"metric.key": "cloud.aws.firehose.deliveryToHttpEndpointSuccessByAccountIdDeliveryStreamNameRegion"
}
]
}
}
```

Item 1 looks like this:


```
{
"types": [
{
"mappings": {
"interval": {
"type": "duration"
},
"timeframe": {
"type": "timeframe"
},
"aws.region": {
"type": "string"
},
"aws.account.id": {
"type": "string"
},
"deliverystreamname": {
"type": "string"
},
"dt.entity.cloud:aws:region": {
"type": "string"
},
"dt.entity.cloud:aws:account": {
"type": "string"
},
"deliveryToHttpEndpointSuccessByAccountIdDeliveryStreamNameRegion": {
"type": "array",
"types": [
{
"mappings": {
"element": {
"type": "double"
}
},
"indexRange": [
0,
120
]
}
]
}
},
"indexRange": [
0,
0
]
}
],
"records": [
{
"interval": "60000000000",
"timeframe": {
"end": "2024-04-10T16:22:00.000Z",
"start": "2024-04-10T14:21:00.000Z"
},

"deliveryToHttpEndpointSuccessByAccountIdDeliveryStreamNameRegion": [
1,
1,
1,
1,
null,

]
}
],
"metadata": {
"grail": {

"scannedDataPoints": 151,
"executionTimeMilliseconds": 32
},
"metrics": [
{
"fieldName": "deliveryToHttpEndpointSuccessByAccountIdDeliveryStreamNameRegion",
"metric.key": "cloud.aws.firehose.deliveryToHttpEndpointSuccessByAccountIdDeliveryStreamNameRegion"
}
]
}
}
```

My fundamental quest is to match only when the `"records": []`, could I get some help with the condition matching syntax in the Workflow?

1 REPLY 1

Hi @roberto_camp1 

Your syntax {{ result("httpendpointsuccess").records == [] }} in itself is correct, but only if a single object is returned. In your case you need to specify in which object the "result" field you want to check .Here the syntax will depend on what format your two objects are returned in, if in the form of a list it can look like this: {{ result("httpendpointsuccess")[0].records == [] }}

 

Bests
Michal

Featured Posts