API Calling Examples
This section describes how to create a log group by calling APIs.
The token obtained from Identity and Access Management (IAM) is valid for only 24 hours. If you want to use the same token for authentication, cache it to avoid frequent calling of the IAM API.
Involved APIs
If you use a token for authentication, you must obtain the token and add X-Auth-Token to the request header when making an API call.
- IAM API used to obtain the token
- LTS API used to create a log group
Procedure
- Obtain the token by referring to .
- Send POST /v2/{project_id}/groups.
- Add Content-Type and X-Auth-Token to the request header.
- Specify the following parameters in the request body:
POST /v2/{project_id}/groups { "log_group_name":"test001", //Log group name (The parameter is mandatory and its value is a string.) "ttl_in_days":"7", //Log expiration time (The value is an integer. Retain the default value.) }
If the request is successful, information about the created log group is returned.
{ "log_group_id":"2a0089e4-3001-11e9-9e9d-286ed48xxx", //Log group ID (The value is a string.) }
If the request fails, an error code and error description are returned. For details, see Error Codes.
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