put-user-defined-log-fields-config

Updated at:

Configures user-defined log fields in real-time, allowing for the addition of custom request headers or query parameters as log fields to facilitate subsequent request data analysis.

Notes

By default, an Alibaba Cloud account has the permissions to configure custom log fields. Configuring as a RAM user or by using Security Token Service (STS) requires the oss:PutUserDefinedLogFieldsConfig permission. For further instructions, see grant custom policy to RAM user.

Syntax

ossutil api put-user-defined-log-fields-config --bucket value --user-defined-log-fields-configuration value [flags]

Parameter

Type

Description

--bucket

string

Bucket name.

--user-defined-log-fields-configuration

string

The container that stores the specified log configuration.

Note

The put-user-defined-log-fields-config command corresponds to the API interface PutUserDefinedLogFieldsConfig. For the specific meanings of parameters in the API, see PutUserDefinedLogFieldsConfig.

--user-defined-log-fields-configuration

The --user-defined-log-fields-configuration option supports both XML and JSON syntax. If the value of the option contains the "file://" prefix, the configurations are loaded from a specific file.

  • XML syntax:

    <HeaderSet>
      <header>string</header>
      ...
    </HeaderSet>
    <ParamSet>
      <parameter>string</parameter>
      ...
    </ParamSet>
  • JSON syntax:

    {
      "HeaderSet": {
        "header": ["string", ...]
      },
      "ParamSet": {
        "parameter": ["string", ...]
      }
    }
Note

For supported global command line options, see supported global command line options.

Examples

Customize the user_defined_log_fields field in real-time by adding custom request headers or query parameters for subsequent analysis of requests to examplebucket.

  • Create a configuration file named user-defined-log-fields-configuration.xml and add the following code to the configuration file:

    <?xml version="1.0" encoding="UTF-8"?>
    <UserDefinedLogFieldsConfiguration>
      <HeaderSet>
         <header>header1</header>
         <header>header2</header>
         <header>header3</header>
      </HeaderSet>
      <ParamSet>
         <parameter>param1</parameter>
         <parameter>param2</parameter>
      </ParamSet>
    </UserDefinedLogFieldsConfiguration>

    Example:

    ossutil api put-user-defined-log-fields-config --bucket examplebucket --user-defined-log-fields-configuration file://user-defined-log-fields-configuration.xml
  • Create a configuration file named user-defined-log-fields-configuration.json and add the following code to the configuration file:

    {
      "HeaderSet": {
        "header": [
          "header1",
          "header2",
          "header3"
        ]
      },
      "ParamSet": {
        "parameter": [
          "param1",
          "param2"
        ]
      }
    }

    Example:

    ossutil api put-user-defined-log-fields-config --bucket examplebucket --user-defined-log-fields-configuration file://user-defined-log-fields-configuration.json
  • Configure parameters in the following command in the JSON format:

    ossutil api put-user-defined-log-fields-config --bucket examplebucket --user-defined-log-fields-configuration "{\"HeaderSet\":{\"header\":[\"header1\",\"header2\",\"header3\"]},\"ParamSet\":{\"parameter\":[\"param1\",\"param2\"]}}"