Creating a trigger for Yandex Cloud Logs
Triggers is currently at the Preview stage.
Create a trigger for Cloud Logs, that will run your function when you send messages to log groups.
Before you start
To create a trigger, you need:
- Service account with rights for function call. If you don't have a service account, create one.
- Functions that the trigger will call. If you don't have a function:
Create a trigger
Note
The trigger is initiated within 5 minutes of being created.
Web console
CLI
To create a trigger:
- Open Cloud Functions in the folder where you want to create a trigger for Cloud Logs.
- Go to the Triggers tab.
- Click Create trigger.
- Under Basic parameters:
- Enter a name and description for the trigger.
- In the Type field, select Cloud Logs.
- Under Cloud Logs settings:
- In the Log sources field select log sources. Log groups will be identified automatically.
- In the Waiting time (sec) field select maximum message group accumulation time.
- In the Message batch size field select maximum message group size.
- Under Repeat request settings:
- In the Interval field, specify 5 seconds.
- In the Message batch size field, enter 5.
- Under Function settings:
- Select the function for the trigger to call.
{% note alert %}
Attention! If you select the function which is in the trigger log sources, its invocation can entail the exponential growth of invokes. - Specify the function version tag.
- Specify the service account that will be used to call the function.
- Select the function for the trigger to call.
- Click Create trigger.
Trigger will be created and appear in the Triggers table.
If you don't have the Yandex.Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
Create a trigger:
--name
— Trigger name.--log-groups
— Log group unique identifiers list.--batch-size
— Maximum message group size.--batch-cutoff
— Maximum message group accumulation time.--invoke-function-id
— Unique function ID.--invoke-function-service-account-id
— Service account with rights to call the function.
$ yc serverless trigger create cloud-logs \
--name log-trigger \
--log-groups eolhui6r************,eol7tktt************ \
--batch-size 5 \
--batch-cutoff 10s \
--invoke-function-id b091v4rl************ \
--invoke-function-service-account-id bfbm2ib6************
Result:
id: dd0c6gsr************
folder_id: aoeuooa5************
created_at: "2020-08-13T10:46:55.947Z"
name: log-trigger
rule:
cloud_logs:
log_group_id:
- eolhui6r************
- eol7tktt************
batch_settings:
size: "5"
cutoff: 10s
invoke_function:
function_id: b091v4rl************
function_tag: $latest
service_account_id: bfbm2ib6************
retry_settings:
retry_attempts: "1"
interval: 10s
status: ACTIVE
What's next
- Read about the concept of trigger.
- Read more about the trigger for Cloud Logs.
- For information about what you can do with triggers, see our step-by-step instructions.