Triggers for Cloud Logs
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 it is subscribed to.
A trigger for Cloud Logs needs a service account to invoke the function.
Batching
Batching can be used to send several messages to the function simultaneously. Batch options set an upper limit for message group size and accumulation time.
For example, if you set the batch size as 3, function could receive message groups of size from 1 to 3.
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 roles iam.serviceAccounts.user, editor, and higher.
- To run a trigger, the service account needs the
serverless.functions.invoker
role for the folder containing the function called by the trigger.
Learn more about access management.
Trigger message format Cloud Logs
After the trigger is activated, 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"
}
]
}
}
]
}