Using Anonymous Write to Collect Logs
Use the anonymous write function to collect and analyze user information, such as browser details, browsing/purchase behaviors, and stay duration, from browsers and applets. You only need to enable anonymous write on the log stream page to upload user behavior data to the log stream.

This function is available only to whitelisted users in regions CN North-Beijing4, CN East-Shanghai1, and CN South-Guangzhou. To use it, submit a service ticket.
Background
- Details about the browsers, OSs, and resolutions used by users
- User browsing behaviors, for example, click and purchase activities on websites
- User information in applets, such as user stay durations and activeness
Enabling Anonymous Write
- Log in to the LTS console.
- Click
on the left of the target log group.
- Click Create Log Stream. On the page displayed, set the parameters by referring to Table 1 and enable Anonymous Write. This function is applicable to scenarios where devices report logs via SDKs. By enabling it, you grant the log stream permission for anonymous writing, which means no valid authentication will be performed. This may lead to the generation of dirty data.
Figure 1 Creating a log stream
Table 1 Log stream parameters Parameter
Description
Log Group Name
Defaults to name of the log group to which the log stream belongs and be unmodifiable.
Stream Type
NOTE:This function is available only to whitelisted users. To use it, submit a service ticket.
Select a log stream type as required.
- Standard log streams support all LTS functions and are designed to build a complete observability system.
- Search log streams support only keyword-based search. They do not support quick analysis, statistical charts, log analysis, and SQL alarms. They are ideal for log search scenarios. They offer a cost advantage, with index traffic fees reduced by 69% compared to standard log streams. For details, see Billing Items.
Log Stream Name
LTS automatically generates a default log stream name. You are advised to customize one based on your service. You can also change it after the log stream is created. The naming rules are as follows:
- Use only letters, digits, hyphens (-), underscores (_), and periods (.). Do not start with a period or underscore or end with a period.
- Enter 1 to 64 characters.
- Each log stream name must be unique.
Enterprise Project Name
Select the required enterprise project. The default value is default. You can click View Enterprise Projects to view all enterprise projects.
- You can use enterprise projects only after enabling the enterprise project function. For details, see Enabling the Enterprise Project Function.
- You can remove resources from an enterprise project. For details, see Removing Resources from an Enterprise Project. If you select multiple log streams when creating a log transfer task, these selected log streams cannot be removed.
Log Storage
If this function is disabled, Log Retention (Days) cannot be enabled.
- If this function is enabled, logs will be stored in the search engine and all log functions are available.
- If this function is disabled, logs will not be stored to LTS. This saves on index traffic and storage costs, but disables log search, analysis, alarm, consumption, and processing. You will only be allowed to use metric generation and log transfer functions.
Log Retention (Days)
Specify the log retention period for the log stream, that is, how many days the logs will be stored in LTS after being reported to LTS.
By default, logs are retained for 30 days. You can set the retention period to one to 365 days.
- If you enable Log Retention (Days) for the log stream, logs are retained for the period set for the log stream.
- If you disable Log Retention (Days) for the log stream, logs are retained for the period set for the log group.
- The logs that exceed the retention period will be automatically deleted. You can transfer logs to OBS buckets for long-term storage.
NOTE:Currently, only whitelisted users can submit service tickets to apply for extending the log retention period to 1,095 days. A test is required to evaluate whether the underlying resources in your regions support 1,095-day retention.
Cold Tiered Storage
Intelligent cold storage, which is available to whitelisted users. Set it as required after enabling Log Retention (Days). For details, see Intelligent Cold Storage.
This function is available only when Log Retention (Days) is set to more than seven days.
Standard Storage (Days)
Specify how long data will be retrained in standard storage. This option is mandatory if Cold Tiered Storage is enabled.
Data in the standard storage must be stored for at least seven days before being transitioned to intelligent cold storage. Log data stored beyond Standard Storage (Days) but within Log Retention (Days) will be automatically transitioned to intelligent cold storage.
Anonymous Write
Anonymous write is disabled by default. Only logs reported by Android, iOS, applets, and browsers can be written anonymously.
This function is available only to whitelisted users. To use it, submit a service ticket.
If anonymous write is enabled for a log stream, no valid authentication is required, which may lead to the generation of dirty data. For details about how to use SDKs, see Using SDKs to Ingest Logs to LTS.
NOTE:The function of using anonymous write to collect logs is available only to whitelisted users in regions CN North-Beijing4, CN East-Shanghai1, and CN South-Guangzhou. To use it, submit a service ticket.
Shards
This parameter is valid only for log consumption. Each shard has a limit of 5 MB/s for writes and 10 MB/s for reads. When the log read/write traffic exceeds these limits, LTS automatically adds more shards. You can also manually add shards. The value ranges from 1 to 64.
Click View Shard Details to view the shards' statuses and creation time.
NOTE:This function is available only to whitelisted users. To use it, submit a service ticket.
Tag
Tag the log stream as required. Click Add and enter a tag key and value. To add more tags, repeat this step. A maximum of 20 tags can be added.
Tag key restrictions:
- A tag key can contain letters, digits, spaces, and special characters (_.:=+-@), but cannot start or end with a space or start with _sys_.
- A tag key can contain up to 128 characters.
- Each tag key must be unique.
Tag value restrictions:
- A tag value can contain letters, digits, spaces, and the following special characters: _.:=+-@
- A tag value can contain up to 255 characters.
Tag policies:
If your organization has configured tag policies for LTS, follow the policies when adding tags to log groups, log streams, log ingestion configurations, and host groups. Non-compliant tags may cause the creation of these resources to fail. Contact your administrator to learn more about the tag policies. For details about tag policies, see Overview of a Tag Policy. For details about tag management, see Managing Tags.
Deleting a tag:
Click Delete in the Operation column of the tag.
WARNING:Deleted tags cannot be recovered.
If a tag is used by a transfer task, you need to modify the task configuration after deleting the tag. For details about transfer, see Transferring Logs to OBS.
Remark
Enter remarks. The value contains up to 1,024 characters.
- Click OK.
Using Anonymous Write to Report Logs
LTS supports anonymous log writing via client SDKs and HTTP GET requests.
- Client SDKs: uploads custom logs, such as form submission, page submission, and exception reports, to LTS via the web SDK, applet SDK, or quick app SDK. For details about how SDKs report logs, see Using SDKs to Ingest Logs to LTS.
Figure 2 Client SDKs
- HTTP GET requests: sends GET requests in the frontend code of a website to upload logs to LTS. This method is suitable for simple log collection. For details, see Uploading Logs Using HTTP GET Requests.
Figure 3 HTTP GET requests
Uploading Logs Using HTTP GET Requests
After anonymous write is enabled, you can upload logs to log streams via HTTP GET requests.
HTTP GET requests are available only to whitelisted users. To use this function, submit a service ticket to technical support to enable it and obtain the corresponding endpoint address.
/v3/{project_id}/lts/groups/{log_group_id}/streams/{log_stream_id}/struct/logs?key1=val1&key2=val2
The GET API has a data volume limit of 16 KB. Exceeding this limit may result in data reporting failures. Compression is not supported.
- Parameter description
Table 2 Configuration parameters Parameter
Mandatory
Type
Description
project_id
Yes
String
Project ID. For details about how to obtain it, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID.
log_group_id
Yes
String
Log group ID. For details about how to obtain it, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID.
log_stream_id
Yes
String
Log stream ID. For details about how to obtain it, see Obtaining the Account ID, Project ID, Log Group ID, and Log Stream ID.
key1=val1&key2=val2
Yes
String
Key-value pairs to be uploaded to LTS. Separate them using ampersands (&). Ensure that each log does not exceed 16 KB.
- Use URL encoding for special characters in reported logs to avoid garbled characters and log reporting failures.
- After URL encoding, the log size must not exceed 16 KB. For example, a 13 KB log that becomes 17 KB when encoded exceeds the limit.
- Response parameters
When the status code is 200, the response parameters are as follows:
Table 3 Response body parameters Parameter
Type
Description
errorCode
String
Error code.
errorMessage
String
Error message.
result
String
Response result.
- Example request
curl -k "https://lts-access.cn-north-4.myhuaweicloud.com:443/v3/xxxxxxProject_id/lts/groups/xxxxxxLog_group_id/streams/xxxxxxxLog_stream_id/struct/logs?key1=val1&key2=val2"
You can specify a port number after the domain name of the public network address for reporting logs. In this example, port 443 is used.- In public network scenarios, use port 443 when using SDK to report logs to LTS across clouds or from local servers.
- In Huawei Cloud intranet scenarios, if the Huawei Cloud host whose logs are to be collected and LTS are in the same region, use port 8102.
- Example response
Example response with status code 200:
Logs are reported.
{ "errorCode": "SVCSTG.ALS.200.200", "errorMessage": "Report success.", "result": null }
- Status codes
Table 4 Status codes Status Code
Description
200
The request is successful.
400
The request is invalid. Modify the request based on the description in error_msg before a retry.
401
The authorization information provided by the client is incorrect or invalid.
403
The request is denied. The server has received the request and understood it, but refuses to respond to it. The client should not repeat the request without modifications.
500
An internal error occurred.
503
The requested service is unavailable.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot