Writing first MQL query to achieve below:
- reads log from a metric “logging.googleapis.com/user/count_verify_country” which has a field COUNTRY
- reads log from another metric “logging.googleapis.com/user/verify_completed” which has a field
MESSAGE - Now, count all occurences with MESSAGE as “VERIFY COMPLETED” for all different COUNTRY
Note: both logs have a common field flowExecutionId whose value remains same for each transaction.
fetch logging.googleapis.com/user/count_verify_country
| filter has(jsonPayload.requestBody.actors.client.verify.country)
| group_by [jsonPayload.requestBody.actors.client.daVinciFlow.flowExecutionId], [country: any(jsonPayload.requestBody.actors.client.verify.country)]
| join (
fetch logging.googleapis.com/user/verify_completed
| filter jsonPayload.requestBody.success.message == "Verify Completed"
| group_by [jsonPayload.requestBody.actors.client.daVinciFlow.flowExecutionId], [success_count: count_true()]
) on jsonPayload.requestBody.actors.client.daVinciFlow.flowExecutionId
| outer_join
| group_by [country], [total_success: sum(success_count)]```
Getting error: Line 5: Expected: ')'. Instead found: 'logging'.
You mentioned you want to count all occurrences of MESSAGE as SUCCESS. But you are giving “Verify Completed” when you are filtering the verify_completed logs. So try using the SUCCESS
in place of Verify Completed
at the line filter jsonPayload.requestBody.success.message == "SUCCESS"
and outer_join is not required.
fetch logging.googleapis.com/user/count_verify_country
| filter has(jsonPayload.requestBody.actors.client.verify.country)
| group_by [jsonPayload.requestBody.actors.client.daVinciFlow.flowExecutionId], [country: any(jsonPayload.requestBody.actors.client.verify.country)]
| join (
fetch logging.googleapis.com/user/verify_completed
| filter jsonPayload.requestBody.success.message == "SUCCESS"
| group_by [jsonPayload.requestBody.actors.client.daVinciFlow.flowExecutionId], [success_count: count()]
) on jsonPayload.requestBody.actors.client.daVinciFlow.flowExecutionId
| group_by [country], [total_success: sum(success_count)]
Refer to this official MQL example document for more information.
5