Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Cloud Functions
  • Getting started
    • Overview
    • Creating and executing functions
    • Creating a timer
    • Creating a trigger for Yandex Message Queue
    • Creating a trigger for Object Storage
    • Creating a trigger for Container Registry
    • Creating a trigger for Cloud Logs
    • Creating a trigger for IoT Core
  • Step-by-step instructions
    • All instructions
    • Using functions to get an IAM token for a service account
    • Managing rights to access functions
    • Managing functions
      • Creating a function
      • Managing function versions
      • Working in the code editor
      • Invoking a function
      • Updating a function
      • Viewing monitoring charts
      • Viewing the execution log
      • Deleting a function
    • Managing triggers
      • Getting information about a trigger
      • Creating a timer
      • Creating a trigger for Message Queue
      • Creating a trigger for Object Storage
      • Creating a trigger for Container Registry
      • Creating a trigger for Cloud Logs
      • Creating a trigger for Yandex IoT Core
      • Updating a trigger
      • Deleting a trigger
  • Concepts
    • Overview
    • Functions
    • Invoking a function
    • Runtime environment
      • Overview
      • Environment
      • Execution context
    • Builder
    • Triggers
      • Overview
      • Timer
      • Trigger for Message Queue
      • Trigger for Object Storage
      • Trigger for Container Registry
      • Trigger for Cloud Logs
      • Trigger for Yandex IoT Core
    • Log groups
    • Monitoring
    • Backups
    • Quotas and limits
  • Developing in Node.js
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Python
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Go
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in PHP
    • Overview
    • Managing dependencies
    • Request handlers
    • Invocation context
    • Logging
    • Handling errors
  • Developing in Bash
    • Overview
    • Request handlers
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Java
    • Overview
    • Java programming model
      • Overview
      • Using the Function interface to set a handler function
      • Using the YcFunction interface to set a handler function
      • Using the HttpServlet class to set a handler
      • Using the SpringBootApplication annotation to set a handler
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in R
    • Overview
    • R programming model
    • Building and managing dependencies
    • Request handler
    • context.md
    • Logging
    • Handling errors
  • Developing in C#
    • Overview
    • C# programming model
      • Overview
      • Using the Function interface to set a handler function
      • Using the YcFunction interface to set a handler function
    • Building and managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Use cases
    • Creating skills for Alice
  • Pricing policy
  • Access management
  • API Functions reference
    • Authentication in the API
    • gRPC
      • Overview
      • FunctionService
      • OperationService
    • REST
      • Overview
      • Function
        • Overview
        • create
        • createVersion
        • delete
        • get
        • getVersion
        • getVersionByTag
        • list
        • listAccessBindings
        • listOperations
        • listRuntimes
        • listTagHistory
        • listVersions
        • removeTag
        • setAccessBindings
        • setTag
        • update
        • updateAccessBindings
  • API Triggers reference
    • Authentication in the API
    • gRPC
      • Overview
      • TriggerService
      • OperationService
    • REST
      • Overview
      • Trigger
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • pause
        • resume
        • update
  • Questions and answers
  1. Getting started
  2. Creating a trigger for Cloud Logs

Creating a trigger for Yandex Cloud Logs

  • Before you start
  • Create a trigger
  • What's next

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:

  1. Service account with rights for function call. If you don't have a service account, create one.
  2. Functions that the trigger will call. If you don't have a function:
    • Create a function.
    • Create a version of the function and upload the function code to it.

Create a trigger

Note

The trigger is initiated within 5 minutes of being created.

Web console
CLI

To create a trigger:

  1. Open Cloud Functions in the folder where you want to create a trigger for Cloud Logs.
  2. Go to the Triggers tab.
  3. Click Create trigger.
  4. Under Basic parameters:
    • Enter a name and description for the trigger.
    • In the Type field, select Cloud Logs.
  5. 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.
  6. Under Repeat request settings:
    • In the Interval field, specify 5 seconds.
    • In the Message batch size field, enter 5.
  7. 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.
  8. 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.
In this article:
  • Before you start
  • Create a trigger
  • What's next
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC