It is possible, but hard to understand from Google documentation. The answer is a modification of the answer provided by Naveen Thomas, depending on the log entry you are trying to pass.
For this, you will have to open the log entry in Logs Explorer, and take a look at the fields available.
For example, in Cloud SQL error log, the field which contains the message is "textPayload".
To pass this to the notification, you would create an log-based alert policy and use the "Extract log labels" option (label_extractors in JSON), enter a display name (I used "msg") and enter "textPayload" as "log field name".
Then add $"{log.extracted_label.msg}" to the "Documentation" field, formatting as you see fit.
In JSON, my policy looks like this:
{
"name": "projects/<project_name>/alertPolicies/<Policy_ID>",
"displayName": "<Policy name>",
"documentation": {
"content": "CloudSQL Instance Log-based alert in project <project_name> detected:\n\n${log.extracted_label.msg}",
"mimeType": "text/markdown"
},
"userLabels": {},
"conditions": [
{
"name": "projects/<project_name>/alertPolicies/<Policy_ID>/conditions/<Condition_ID?>",
"displayName": "Log match condition",
"conditionMatchedLog": {
"filter": "resource.type=\"cloudsql_database\"\nresource.labels.database_id=\"<project_name>:<instance_ID>\"\nlogName=\"projects/<project_name>/logs/cloudsql.googleapis.com %2Fsqlserver.err\"\nseverity=(INFO OR ERROR OR CRITICAL OR ALERT OR EMERGENCY)",
"labelExtractors": {
"msg": "EXTRACT(textPayload)"
}
}
}
],
"alertStrategy": {
"notificationRateLimit": {
"period": "300s"
},
"autoClose": "604800s"
},
"combiner": "OR",
"enabled": true,
"notificationChannels": [
"projects/<project_name>/notificationChannels/<notificationChannel_ID>"
],
"creationRecord": {
"mutateTime": "2023-01-01T07:11:53.406233445Z",
"mutatedBy": "<User>"
},
"mutationRecord": {
"mutateTime": "2023-01-01T13:22:19.917589988Z",
"mutatedBy": "<User>"
}
}
References:
https://cloud.google.com/logging/docs/logs-based-metrics/labels
https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars