Logs commands

The logs commands are used to view the logs of a function.

⚠️ Note: Before you use this feature, you must activate Log Service and configure related log projects.

Command description

You can run the logs -h or logs --help command to obtain the help document.

Parameter description

ParameterAbbreviationRequired in YAML modeRequired in CLI modeDescription
region-NoYesThe name of the region. Valid values: cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, ap-south-1.
service-name-NoYesThe name of the service.
function-name-NoYesThe name of the function.
type-NoNoThe log type to query. Valid values: success, fail
request-id-NoNoQuery according to requestId within the time interval.
start-timesNoNoThe start time of the query, which must be UTC time or a timestamp. Example: 2021-06-07T02:54:59+08:001611827290000
end-timeeNoNoThe end time of the query, which must be UTC time or a timestamp. Example: 2021-06-07T02:54:59+08:001611827290000
tail-NoNoOutputs the result in the tail mode.
instance-id-NoNoQuery according to instanceId within the time interval
qualifier-NoNoQuery the specified version or alias
match-NoNoThe matched character is highlighted

The current command also supports some global parameters (such as -a/--access, --debug, etc.). For details, please refer to Serverless Devs global parameters document

Examples

  • **If a resource description file (YAML) is available, **you can run the s logs command to view logs of online functions.
  • In CLI mode (no YAML), you must specify the region in which the service resides and names of the service and function. Example: s cli fc logs --region cn-hangzhou --service-name fc-deploy-service --function-name http-trigger-py36

Sample output:

FunctionCompute python3 runtime inited.

FC Invoke Start RequestId: 84d6ae81-02ff-4011-b3ca-45e65b210cc3
FC Invoke End RequestId: 84d6ae81-02ff-4011-b3ca-45e65b210cc3

FC Invoke Start RequestId: de4812be-9137-4a33-9869-370cb61ac427
FC Invoke End RequestId: de4812be-9137-4a33-9869-370cb61ac427

You can add the --tail parameter to view logs in the tail mode. Example: s logs --tail.

You can add the --start-time and --end-time parameters to view the logs in a specified period. Example: s logs -s 2021-11-04T15:40:00 -e 2021-11-04T15:45:00.

Permissions and policies

  • Maximum permissions: AliyunFCReadOnlyAccess, and AliyunLogReadOnlyAccess

  • Minimum permissions: AliyunFCReadOnlyAccess and permissions related to some API operations:

    {
        "Version": "1",
        "Statement": [
            {
                "Action": "log:GetLogStoreLogs",
                "Effect": "Allow",
                "Resource": "acs:log:<region>:<account-id>:project/<project>/logstore/<logstore>"
            }
        ]
    }
    
Edit this page on GitHub Updated at Fri, Nov 24, 2023