Updated on 2024-04-19 GMT+08:00

Logs

Scenarios

You can use logs when you want to know the statuses of messages published to a topic. Protocols including SMS, FunctionGraph (function), email, HTTP and HTTPS are supported. Before configuring logs, you need to interconnect SMN with Log Tank Service (LTS) and have created a log group and log stream to be associated. For details about how to configure and operate LTS, see Log Tank Service User Guide.

Configuring Cloud Logs

  1. Create a log group.
    1. Log in to the management console.
    2. Click on the upper left to select the desired region and project.
    3. In the upper left corner of the page, click . Select Log Tank Service under Management & Governance.

      The LTS console is displayed.

    4. In the navigation pane on the left, choose Log Management.

      The Log Management page is displayed.

    5. Click Create Log Group. In the displayed dialog box, enter a log group name.
    6. Click OK.
  2. Create a log stream.
    1. Locate the created log group and click its name.
    2. Click Create Log Stream. In the displayed dialog box, enter a name for the log stream.
    3. Click OK.

Configuring Message Transmission Logs

On the SMN console, configure logs.

  1. Set this parameter on the Create Topic page.
    1. Log in to the management console.
    2. In the upper left corner of the page, click and select the desired region and project.
    3. In the upper left corner of the page, click . Select Simple Message Notification under Management & Governance.

      The SMN console is displayed.

    4. In the navigation pane on the left, choose Topic Management > Topics.

      The Topics page is displayed.

    5. On the Topics page, click the name of the topic to be configured.
    6. On the displayed page, click the Message Transfer Logs tab, and click Configure Access Logs.

      Figure 1 Message transmission log

    7. Click Start Logging and select the log group and log stream that you have created on the LTS console.

      Figure 2 Configuring logs

    8. Click OK.

Viewing Access Logs

You can view details about logs you configured.

Log format

{"message_id":"$message_id","project_id":"$project_id","topic_urn":"$topic_urn","subscriber_urn":"$subscriber_urn","protocol_name":"$protocol_name","endpoint":"$endpoint","status":"$status","http_code":$http_code,"create_time":"$create_time","send_time":"$send_time"}

The log format cannot be modified. Table 1 describes the log fields.

Table 1 Parameters in a FunctionGraph (function) message

Parameter

Type

Description

message_id

String

Message ID

project_id

String

Project ID

topic_urn

String

Resource identifier of a topic, which is unique

subscriber_urn

String

Resource identifier of a subscription, which is unique

protocol_name

String

Specifies the subscription protocol. (Different protocols indicate different types of endpoints to receive messages.) The following protocols are supported:

Email: The endpoints are email addresses.

SMS: The endpoints are phone numbers.

FunctionGraph: FunctionGraph (function) transmission protocol. The endpoint is a function.

FunctionStage: FunctionStage (workflow) transmission protocol. The endpoint is a function workflow.

HTTP and HTTPS: The endpoints are URLs.

endpoint

String

Message receiving endpoint

status

String

Message status. The options are as follows:

DELIVERED: The message has been delivered.

FAIL_DELIVERED: The message fails to be sent.

REJECTS: The message has been rejected. The flow control mechanism is triggered.

http_code

Integer

HTTP return code. Only HTTP/HTTPS messages are supported.

create_time

String

Time when a message was created. The UTC time is in YYYY-MM-DDTHH:MM:SSZ format.

send_time

String

Specifies the time when the message was sent. The UTC time is in YYYY-MM-DDTHH:MM:SSZ format.

Example Log

{"message_id":"1ae49922602a42fc83acb9689a2eb5f4","project_id":"5a9f32e4f1ec4bbe9695ff9da51c2925","topic_urn":"urn:smn:regionid:5a9f32e4f1ec4bbe9695ff9da51c2925:demo","subscriber_urn":"urn:smn:regionid:5a9f32e4f1ec4bbe9695ff9da51c2925:demo:b55c3c6fa7cd471b9f24818d530a8740","protocol_name":"https","endpoint":"https://127.0.0.1:443/https","status":"DELIVERED","http_code":200,"create_time":"2022-11-01T00:00:00Z","send_time":"2022-11-01T00:00:10Z"}

The following table describes the fields in the log.

Table 2 Example values of fields in the log

Parameter

Example Value

message_id

1ae49922602a42fc83acb9689a2eb5f4

project_id

5a9f32e4f1ec4bbe9695ff9da51c2925

topic_urn

urn:smn:regionid:5a9f32e4f1ec4bbe9695ff9da51c2925:demo

subscriber_urn

urn:smn:regionid:5a9f32e4f1ec4bbe9695ff9da51c2925:demo:b55c3c6fa7cd471b9f24818d530a8740

protocol_name

https

endpoint

https://127.0.0.1:443/https

status

DELIVERED

http_code

200

create_time

2022-11-01T00:00:00Z

send_time

2022-11-01T00:00:10Z