百度智能云

All Product Document

          Object Storage

          Set Access Log

          Basic Introduction

          To track and visit BOS request, you can enable access log function for bucket. Each access log records the detailed information of a single access request, including requester, bucket name, request time, request operation, etc. The log recording function can be applied in access statistics, security audit, etc. When access log function is enabled for bucket, a log file is generated for the access request of the bucket by hour according to the fixed naming rules, and the file is written into user specified bucket.

          Note: It is a "Best Effort" process to store the access log in the target bucket. In most cases, it takes about sometime ranging from 2 to 3 hours for an access request to be completed from the occurrence of such access request to the storage of corresponding log to the target bucket. However, due to factors such as the network environment, the storage of some logs in the target bucket may be delayed for a long time.

          Operation Method

          You can set the access log through Console Settings and API Realization

          Log Naming Rules

          The naming rules for object of storing access log are <TargetPrefix><SourceBucketName>-YYYY-mm-DD-HH-MM-SS-UniqueString, for example, mylog/mybucket-2016-05-17-10-00-00-00000. Where

          • TargetPrefix is the prefix specified by the user, that is, mylog/in the example;
          • SourceBucketName is the source bucket name, that is, mybucket in the example;
          • YYYY, mm, DD, HH, MM, and SS refer to the year, month, day, hour, minute, and second corresponding to the minimum timestamp in the access request recorded in this log;
          • UniqueString is a string generated by the BOS system. It is used to uniquely identify this log file, that is, 00000 in the example.

          Log Format

          Output field Example Description
          Time 2016-09-05T09:02:03+08:00 Time when the request is made
          bucket Owner 6c47a952db4444c5a097b41be3f24c94 Owner ID of bucket
          bucket samplebucket bucket name requested to access
          Key dir/sample.jpg object name requested to access
          Reserve - Reserved field
          Remote IP 111.30.20.12 Requester IP address
          Requester 6c47a952db4444c5a097b41be3f24c94 Requester ID
          Request ID a94dbe12-717e-4e72-bcf2-0aa4a3100360 It is used to uniquely identify the UUID of the request, same as x-bce-request-id in the Header.
          Operation Getobject API corresponding to the request
          Request Host bj.bcebos.com Host request header for HTTP request
          Request URI "GET/v1/tables.xml" URI in HTTP request needs be to be double quoted.
          HTTP Status 200 HTTP status code returned by BOS
          Error Code InvalidURI Error code returned by BOS
          Bytes Send 2314 Traffic downloaded by user from BOS
          object Size 1024 object size, in Bytes
          Total Time(ms) 11 Total time from the start of receiving the request to the corresponding return, in milliseconds
          Server Cost Time (ms) 10 Total time from receiving all requests to starting to respond to user requests, in milliseconds The value of this field is-
          Referer <https://cloud.baidu.com/product/bos.html> Referer header for HTTP request
          User Agent "curl/7.33.0" User Agent header for HTTP request
          Storage Class STANDARD object storage type
          Multiple Delete "abc%0Adef" object information deleted through Multiple Delete, with '% 0A' as the separator, used to separate multiple objects.
          Reserve - Reserved field
          Reserve - Reserved field

          Log Sample:

          2016-09-05T09:02:03+08:00 e18b593b12d01ae931b4cd938f4967b8 bos-logging - - 127.0.0.1 e18b593b12d01ae931b4cd938f4967b8 98a20094-2002-4950-899d-9347244c71da Getbucket bj.bcebos.com "/bos-logging?delimiter=%2F&maxKeys=1000&prefix=" object="-" 200 success 2335 - 10 - "-" "bce-sdk-python/0.8.9/2.7.3 (default, Jun 24 2016, 15:08:42) [GCC 3.4.5 20051201 (Red Hat 3.4.5-2)]/linux2" - - - -

          Note:

          • Each field in the log is separated by spaces.
          • In BOS Log, some fields may have spaces, and these fields (such as "Referrer") are included externally in quotation marks when generated.
          • The Reserve field is a reserved field and is represented by "-" in Log.
          • BOS generates the Log file accessed by bucket in hours, but this does not mean that all requests for this hour are recorded in the Log file for this hour, and may also appear in the previous or next Log file.
          • BOS generates a Log file that takes up storage space in that target bucket. The log access function is free, but the storage space occupied by the log is still charged as usual. Users can operate log files just like normal object.
          • After the target bucket is generated, BOS will not actively clean up these log files.
          Previous
          View Bucket List
          Next
          Set Bucket Tag