A large number of logs are generated when OSS resources are accessed. OSS uses Log Service to help you query and collect statistics for OSS access logs and audit access to OSS in the OSS console, track exception events, and troubleshoot problems. This helps you improve work efficiency and make informed decisions.
Prerequisites
Log Service is authorized to access OSS.If you have not authorized Log Service to access OSS, follow the instructions on the Cloud Resource Access Authorization page to complete the authorization.
Benefits
- Pushes logs to Log Service within three minutes and allows you to view real-time logs in the OSS console.
- Provides log analysis and common analysis reports so that you can easily query data.
- Allows you to query and analyze raw logs in real time and filter logs by bucket, object name, API operation, or time.
Billing rules
- If you store no more than 900 GB of logs per day (approximately 900 million 1-KB log entries) and the logs are stored for no more than seven days, you are not charged for log storage and index traffic. You are charged the storage and index traffic fees for the logs that exceed the threshold.
- You are charged when you read data from a dedicated Logstore over the Internet. You are also charged when you transform and ship data.
- You can use a maximum of 16 × 31 shard days in a dedicated Logstore to store and query OSS logs free of charge. You are charged for excess shard days and the charges are included into your Log Service bills.
For more information, see Billable items.
Enable real-time log query
You can enable real-time log query when you create a bucket or for an existing bucket.
Enable real-time log query when you create a bucket
- Log on to the OSS console.
- In the left-side navigation pane, click Buckets. On the Buckets page, click Create Bucket.
- In the Create Bucket panel, turn on Real-time Log Query. For more information about other parameters, see Create buckets.
- Click OK.
Enable real-time log query for an existing bucket
- Log on to the OSS console.
- In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the desired bucket.
- In the left-side navigation tree, choose .
- Click Activate Now.
Real-time log query allows you to query logs within the previous seven days free of charge. You can click Config Log Retention Time in the upper-right corner to modify the retention period for logs.
Query real-time logs
You can use one of the following methods to query real-time logs:
Method 1: Query real-time logs on the Raw Logs tab
- Log on to the OSS console.
- In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the desired bucket.
- In the left-side navigation tree, choose .
- On the Raw Logs tab, analyze logs. You can specify the time range and query statement in real-time log queries. For example, you can analyze the distribution of a specified field such as an API operation within a specified time range. You can also filter the query results by conditions to view the required access records.
Method 2: Query real-time logs on the LogReduce tab
- Log on to the OSS console.
- In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the desired bucket.
- In the left-side navigation tree, choose .
- Click the LogReduce tab. If you have not enabled LogReduce, click Enable LogReduce.
For more information about the LogReduce feature, see LogReduce.
Disable real-time log query
If you no longer need to retain log data, perform the following steps to disable real-time log query:
- Log on to the OSS console.
- In the left-side navigation pane, click Buckets. On the Buckets page, click the name of the desired bucket.
- In the left-side navigation tree, choose .
- Click Disable Real-time Log Query in the upper-right corner. Important When you enable real-time log query, Log Service projects are automatically created. However, the projects are not automatically deleted when you disable real-time log query. We recommend that you delete the projects that are automatically created to avoid unexpected charges. For more information about how to delete Log Service projects, see Delete a project.