Trigger for Cloud Logs
Alert
Trigger for Cloud Logs is outdated. Use triggers for Cloud Logging.
A trigger for Cloud Logs runs a function when messages are received in a log group. The trigger must be in the same folder as the log groups to which it is subscribed.
Alert
Triggers for Cloud Logs may skip messages under increased load. To make sure you do not lose them, in the trigger settings for Cloud Logs, specify DLQ and process messages from there with a trigger for Message Queue.
A trigger for Cloud Logs needs a service account to call the function.
For more information about creating a trigger for Cloud Logs, see Creating a trigger for Cloud Logs.
Batching
Batching settings allow you to send multiple messages to a function at the same time. They set a top limit on a message batch size and its accumulation time. For example, if the message batch size is 3, the function can receive batches containing from 1 to 3 messages.
Roles required for the proper operation of a trigger for Cloud Logs
- To create a trigger, you need a permission for a service account that runs the trigger executing the operation. This permission is included in the iam.serviceAccounts.user and editor roles and higher.
- For the trigger to fire, the service account needs the
functions.functionInvoker
role for the folder containing the function called by the trigger.
Read more about access management.
Cloud Logs trigger message format
After the trigger is fired, it sends the following message to the function:
{
"messages": [
{
"event_metadata": {
"event_id": "564ab7ff-5890-4eca-b8ab-************",
"event_type": "yandex.cloud.events.serverless.triggers.CloudLogsMessageBatch",
"created_at": {
"seconds": 1599563113,
"nanos": 647071528
}
},
"details": {
"messages": [
{
"log_group_id": "eol1fphr************",
"log_stream_name": "log-stream-name",
"message": "message-1",
"timestamp": "2020-09-08T11:05:10Z"
},
{
"log_group_id": "eol1fphr************",
"log_stream_name": "log-stream-name",
"message": "message-2",
"timestamp": "2020-09-08T11:05:10Z"
}
]
}
}
]
}