The Operation Content and Result Delivery feature provided by Cloud Assistant allows you to deliver O&M task execution records to Object Storage Service (OSS) or Log Service for persistent storage. This topic describes how to configure delivery settings to deliver O&M task execution records to specified OSS buckets or Logstores and how to query delivered execution records.

Background information

Cloud Assistant allows O&M task execution records to be retained but puts limits on the maximum number of execution records retained and their retention periods. For more information, see the "Cloud Assistant limits" section in Limits. If you want to retain a large number of execution records or retain execution records for an extended period of time, we recommend that you use the Operation Content and Result Delivery feature. It allows you to deliver and query O&M task execution records and perform operations on them, such as behavioral or security analysis, resource change tracking, and behavioral compliance audit.

You can perform the following steps to use the Operation Content and Result Delivery feature:
  1. Configure delivery settings. Specify a destination Log Service project and Logstore or a destination OSS bucket.

    For more information, see Configure delivery settings in the ECS console.

  2. Run commands or send files. Then, the corresponding task execution records are automatically delivered to your specified Logstore or OSS bucket.

    For more information, see Immediate execution, Run a command, and Upload files to ECS instances.

  3. Go to the Log Service console or OSS console to query the delivered execution records.

    For more information, see Query O&M task execution records in the Log Service console and Query O&M task execution records in the OSS console.

Configure delivery settings in the ECS console

  1. Log on to the ECS console.
  2. In the left-side navigation pane, click ECS Cloud Assistant.
  3. In the left part of the top navigation bar, select a region.
    Note O&M task execution records cannot be delivered across regions. To deliver O&M task execution records in multiple regions, configure delivery settings for each of these regions.
  4. In the upper-right corner of the Cloud Assistant page, click Operation Content and Result Delivery.
  5. In the Operation Content and Result Delivery dialog box, configure delivery settings.
    delivery-settings
    Note The first time you configure delivery settings, the system grants Cloud Assistant the permissions to access Log Service and OSS resources so that O&M task execution records can be delivered to your specified Logstore or OSS bucket. You can also manually manage the permissions. For more information, see Manage the service-linked role for Operation Content and Result Delivery.
    1. Select Deliver to Log Service. Then, select a created Log Service project from the Project drop-down list and a created Logstore from the Logstore drop-down list.
      If you have not created Log Service projects or Logstores in the selected region, click Log Service Console or Logstores to create projects or Logstores in the Log Service console. After you create projects or Logstores in the selected region, go back to the Operation Content and Result Delivery dialog box and click the refresh icon to obtain the most recent list of projects or Logstores. For more information, see Manage a project and Manage a Logstore.

      Before you can query or analyze logs in Log Service, you must enable indexing. For more information, see Configure indexes.

      Notice The Operation Content and Result Delivery dialog box feature is free to use. However, you are charged for traffic generated when you use Log Service features such as indexing. For more information, see Overview.
    2. Select Deliver to OSS. Then, select a created OSS bucket and specify the root directory in which to store execution records.
      If you have not created OSS buckets in the selected region, click OSS console to create buckets in the OSS console. After you create buckets in the selected region, go back to the Operation Content and Result Delivery dialog box and click the refresh icon to obtain the most recent list of buckets. For more information, see Create buckets.
      Notice The Operation Content and Result Delivery dialog box feature is free to use. However, you are charged for traffic generated when you use OSS features such as object management. For more information, see Overview.
    3. Click OK.

Query O&M task execution records in the Log Service console

This section describes how to access a specified Logstore from the ECS console to query logs about delivered O&M task execution records. Alternatively, you can log on to the Log Service console and access the specified Logstore.

  1. Log on to the ECS console.
  2. In the left-side navigation pane, click ECS Cloud Assistant.
  3. In the top navigation bar, select a region.
  4. In the upper-right corner of the Cloud Assistant page, click Operation Content and Result Delivery.
  5. In the Operation Content and Result Delivery dialog box, click Logstores on the right of the Logstore field.
    For more information about how to query logs, see Query logs.
    The following figures show example logs about O&M task execution records. For information about parameters contained in the execution records, see Parameters contained in O&M task execution records.
    • Example log about one-time execution records (execution records of a command task that runs a command only once)once
    • Example log about recurring execution records (execution records of a command task that runs a command on a recurring schedule)

      The Repeats value indicates the number of times that the command was run.

      sls-timed
    • Example log about file-sending task execution recordssls-sendfile

Query O&M task execution records in the OSS console

This section describes how to access a specified OSS bucket from the ECS console to query objects that contain delivered O&M task execution records. Alternatively, you can log on to the OSS console and access the specified bucket.

  1. Log on to the ECS console.
  2. In the left-side navigation pane, click ECS Cloud Assistant.
  3. In the top navigation bar, select a region.
  4. In the upper-right corner of the Cloud Assistant page, click Operation Content and Result Delivery.
  5. In the Operation Content and Result Delivery dialog box, click OSS Console on the right side of the Bucket field.
  6. Go to the directory in which the object that contains the execution records of an O&M task is stored.
    After you log on to the OSS console, the system directs you to the root directory that you specified when you configured delivery settings in the Operation Content and Result Delivery dialog box. You can go to automatically generated subdirectories based on O&M task types.
    • For a command task, go to the invocationResults/<Execution ID> subdirectory. In this subdirectory, directories that are named after ECS instance IDs and the script of the command are displayed. The script may have one of the following names:
      • commandContent.bat: A batch command is run on specified Windows ECS instances.
      • commandContent.ps1: A PowerShell command is run on specified Windows ECS instances.
      • commandContent.sh: A shell command is run on specified Linux ECS instances.
    • For a file-sending task, go to the sendFileResults/<Execution ID> subdirectory. In this subdirectory, directories that are named after ECS instance IDs and the fileContent.txt file are displayed. The fileContent.txt file contains the sent content.
    The following figure shows an example subdirectory generated for a command task that runs a shell command on Linux ECS instances. oss-dir
  7. Go to the directory that is named after the ID of an ECS instance to query the object that contains the execution records of tasks run on the instance.
    The following figures show example JSON-formatted objects that contain O&M task execution records.
    • Example object that contains one-time execution recordsoss-immediate
    • Example object that contains recurring execution records

      The digits in each object name indicate the number of times that the command was run on the specified instance.

      oss-timed
    • Example object that contains file-sending task execution recordsoss-sendfile
  8. Click View Details in the Actions column corresponding to an object that contains execution records. Then, download the object or copy the object URL and view the object content.
    The following code shows an example object that contains the one-time execution records of a shell command. For information about parameters contained in the execution records, see Parameters contained in O&M task execution records.
    {
        "RegionId":"cn-hangzhou",
        "InstanceId":"i-bp1hd5ztmab9cgc0****",
        "InvokeId":"t-hz01x7rtjfy****",
        "CommandId":"c-hz01x7cn5aj****",
        "CommandName":"cmd-hostname",
        "CommandType":"RunShellScript",
        "CommandContent":"hostname",
        "ResourceOwnerUid":160998252992****,
        "CallerUid":160998252992****,
        "CallerType":"customer",
        "Timeout":60,
        "Frequency":"",
        "Parameters":"{}",
        "Username":"",
        "RepeatMode":"Once",
        "Repeats":1,
        "InvocationStatus":"Success",
        "Dropped":0,
        "Output":"iZbp1hd5ztmab9cgc0****\n",
        "ExitCode":0,
        "CreationTime":"2021-09-26T05:47:20Z",
        "StartTime":"2021-09-26T05:47:20Z",
        "UpdateTime":"2021-09-26T05:47:20Z",
        "FinishedTime":"2021-09-26T05:47:20Z",
        "StopTime":""
    }

Parameters contained in O&M task execution records

The following table describes the parameters contained in the execution records of command tasks. For more information about the parameters such as their valid values, see DescribeCommands and DescribeInvocationResults.
Parameter Example Description
RegionId cn-hangzhou The region ID of the ECS instance on which the command was run.
InstanceId i-bp1hd5ztmab9cgc0**** The ID of the ECS instance.
InvokeId t-hz01x7rtjfy**** The ID of the execution.
CommandId c-hz01x7cn5aj**** The ID of the command.
CommandName cmd-hostname The name of the command.
CommandType RunShellScript The type of the command.
CommandContent hostname The plaintext content of the command.
ResourceOwnerUid 160998252992**** The Alibaba Cloud account ID of the command caller.
CallerUid 160998252992**** The account ID of the command caller.
CallerType customer The call mode of the command caller.
Timeout 60 The timeout period for the command to run on the ECS instance.
Frequency 0 * 14 * * ? The schedule on which the recurring executions of the command took place.
Parameters {} The key-value pairs of custom parameters to be passed in when the command includes custom parameters.
Username root The username used to run the command on the ECS instance.
RepeatMode Period The execution mode of the command.
Repeats 2 The number of times that the command was run on the ECS instance.
InvocationStatus Success The command state on a single ECS instance.
ErrorCode InstanceNotExists The error code returned when the command cannot be sent or run.
ErrorInfo the specified instance does not exists The error message returned when the command cannot be sent or run.
Dropped 0 The size of truncated and discarded text when the size of text in the Output response parameter is larger than 24 KB.
Output iZbp1hd5ztmab9cgc0****\n The command output.
ExitCode 0 The exit code of the command.
CreationTime 2021-09-26T05:47:20Z The creation time of the execution.
StartTime 2021-09-26T05:47:20Z The time when the command started to run on the ECS instance.
UpdateTime 2021-09-26T06:53:00Z The time when the execution state was updated.
FinishedTime 2021-09-26T06:53:00Z The completion time of the execution.
StopTime 2021-09-26T06:53:00Z The time at which the command stopped being run on the ECS instance. If you called the StopInvocation operation to manually stop the execution, the value is the time at which the operation was called.
The following table describes the parameters contained in the execution records of file-sending tasks. For more information about the parameters such as their valid values, see DescribeSendFileResults.
Parameter Example Description
RegionId cn-hangzhou The region ID of the ECS instance to which the file was sent.
InstanceId i-bp1hd5ztmab9cgc0**** The ID of the ECS instance.
InvokeId f-hz01xeva44**** The ID of the execution.
FileName sendfile-test.txt The name of the file.
ContentType Base64 The content type of the file.
Description Used for test The description of the file.
FileContent c2VuZCBmaWxlIHRlc3Q= The content of the file.
FileGroup root The group of the file.
FileMode 0644 The permissions on the file.
FileOwner root The owner of the file.
ResourceOwnerUid 16099825299**** The Alibaba Cloud account ID of the file sender.
CallerUid 16099825299**** The account ID of the file sender.
CallerType customer The call mode of the file sender.
Overwrite true Specifies whether to overwrite a file in the destination directory if the file has the same name as the sent file.
TargetDir /root The destination directory to which the file is sent.
Timeout 60 The timeout period for sending the file.
InvocationStatus Success The state of the file-sending task.
ErrorCode FileAlreadyExists The error code returned when the file cannot be sent to the instance.
ErrorInfo File already exists: sendfile-test.txt The error message returned when the file cannot be sent to the ECS instance or when the file-sending task cannot be executed on the instance.
CreationTime 2021-09-28T05:31:04Z The creation time of the file-sending task.
StartTime 2021-09-28T05:31:04Z The time when the file-sending task started to be executed on the ECS instance.
UpdateTime 2021-09-28T05:31:04Z The time when the state of the file-sending task was updated.
FinishTime 2021-09-28T05:31:04Z The time when the file-sending task finished being executed.