Using an LTS Trigger
For details about the timer event source, see Supported Event Sources.
Prerequisites
- You have created a function on FunctionGraph. For details, see Creating and Initializing a Function.
- You have created a log group, for example, LogGroup1. For details, see Creating a Log Group.
- You have created a log stream, for example, LogStream1. For details, see Creating a Log Stream.
Creating an LTS Trigger
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
- Click the HelloWorld function.
- Choose Configuration > Triggers and click Create Trigger.
- Set the following parameters:
- Trigger Type: Select Log Tank Service (LTS).
- Log Group: Select a log group, for example, LogGroup1.
- Log Stream: Select a log stream, for example, LogStream1.
- Click OK.
Configuring an LTS Event to Trigger the Function
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
- Click the HelloWorld function.
- On the function details page, click the Code tab and select Configure Test Event.
- Set the parameters described in Table 1 and click Save.
Table 1 Test event information Parameter
Description
Configure Test Event
You can choose to create a test event or edit an existing one.
Use the default option Create new test event.
Event Template
Select Log Tank Service (LTS) and use the built-in LTS event template.
Event Name
The event name can contain 1 to 25 characters and must start with a letter and end with a letter or digit. Only letters, digits, underscores (_), and hyphens (-) are allowed. For example, lts-123test.
Event data
The system automatically loads the built-in LTS event template, which is used in this example without modifications.
NoteThe event template is as follows:
{"lts": {"data": "ewogICAgICAgICJsb2dzIjpbewogICAgICAgICAgICAgICAgIm1lc3NhZ2UiOiIyMDE4LTA2LTI2LzE4OjQwOjUzIFtJTkZdIFtjb25maWcuZ286NzJdIFN1Y2Nlc3NmdWxseSBsb2FkZWQgZ2VuZXJhbCBjb25maWd1cmF0aW9uIGZpbGVcXHJcXG4iLAogICAgICAgICAgICAgICAgInRpbWUiOjE1MzAwMDk2NTMwNTksCiAgICAgICAgICAgICAgICAiaG9zdF9uYW1lIjoiZWNzLXRlc3RhZ2VudC5ub3ZhbG9jYWwiLAogICAgICAgICAgICAgICAgImlwIjoiMTkyLjE2OC4xLjk4IiwKICAgICAgICAgICAgICAgICJwYXRoIjoidXNyL2xvY2FsL3RlbGVzY29wZS9sb2cvY29tbW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bmFtZSI6ImVjcy10ZXN0YWdlbnQubm92YWxvY2FsIiwKICAgICAgICAgICAgICAgICJpcCI6IjE5Mi4xNjguMS45OCIsCiAgICAgICAgICAgICAgICAicGF0aCI6Ii91c3IvbG9jYWwvdGVsZXNjb3BlL2xvZy9jb21tb24ubG9nIiwKICAgICAgICAgICAgICAgICJsb2dfdWlkIjoiNjYzZDY5MzAtNzkyZC0xMWU4LThiMGEtMjg2ZWQ0ODhjZTcwIiwKICAgICAgICAgICAgICAgICJsaW5lX25vIjo2MTcKICAgICAgICAgICAgfQogICAgICAgICAgICBdLAogICAgICAgICJvd25lciI6ICI2MjgwZTE3MGJkOTM0ZjYwYTRkODUxY2Y1Y2EwNTEyOSIsCiAgICAgICAgImxvZ19ncm91cF9pZCI6ICI5N2E5ZDI4NC00NDQ4LTExZTgtOGZhNC0yODZlZDQ4OGNlNzAiLAogICAgICAgICJsb2dfdG9waWNfaWQiOiAiMWE5Njc1YTctNzg0ZC0xMWU4LTlmNzAtMjg2ZWQ0ODhjZTcwIgogICAgICAgIH0="}} - Click Test. The function test result is displayed, as shown in Figure 1.
Figure 1 Test result
Parent topic: Getting Started
- Prerequisites
- Creating an LTS Trigger
- Configuring an LTS Event to Trigger the Function