Log Server Operations
AddLogServer
API Request
URLs
POST zstack/v1/log/serversHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"name": "log-server",
"description": "log server",
"category": "ManagementNodeLog",
"type": "Log4j2",
"level": "ALL",
"configuration": "{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"log-server","description":"log server","category":"ManagementNodeLog","type":"Log4j2","level":"ALL","configuration":"{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"}}' \
http://localhost:8080/zstack/v1/log/serversRequest Parameters
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| name | String | body (container in the params structure) | The resource name. | 5.3.28 | |
| description | String | body (container in the params structure) | Optional. The resource description. | 5.3.28 | |
| category | String | body (container in the params structure) | The log category. |
|
5.3.28 |
| type | String | body (container in the params structure) | The log type. |
|
5.3.28 |
| level (可选) | String | body (container in the params structure) | Optional. The log severity level. |
|
5.3.28 |
| configuration | String | body (container in the params structure) | The log configurations. | 5.3.28 | |
| resourceUuid | String | body (container in the params structure) | Optional. The resource UUID. | 5.3.28 | |
| tagUuids | List | body (container in the params structure) | Optional. The tag UUID list. | 5.3.28 | |
| systemTags | List | body | Optional. The system tags. | 5.3.28 | |
| userTags | List | body | Optional. The user tags. | 5.3.28 |
API Response
Sample Response
{
"inventory": {}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 5.3.28 | |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error | 5.3.28 |
| inventory | LogServerInventory | See inventory | 5.3.28 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 5.3.28 |
| description | String | The brief description of the error. | 5.3.28 |
| details | String | The details about the error. | 5.3.28 |
| elaboration | String | The reserved field. Default value: null. | 5.3.28 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 5.3.28 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 5.3.28 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.3.28 |
| name | String | The resource name. | 5.3.28 |
| description | String | The resource description. | 5.3.28 |
| configuration | String | 5.3.28 | |
| createDate | Timestamp | The creation time. | 5.3.28 |
| lastOpDate | Timestamp | The last operation time. | 5.3.28 |
| category | LogCategory | See category | 5.3.28 |
| type | LogType | See type | 5.3.28 |
| level | LogLevel | See level | 5.3.28 |
#category
| Name | Type | Description | Starting Version |
|---|---|---|---|
| ManagementNodeLog | LogCategory | 5.3.28 | |
| PlatformOperationLog | LogCategory | 5.3.28 |
#type
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Log4j2 | LogType | 5.3.28 | |
| FluentBit | LogType | 5.3.28 |
#level
| Name | Type | Description | Starting Version |
|---|---|---|---|
| OFF | LogLevel | 5.3.28 | |
| FATAL | LogLevel | 5.3.28 | |
| ERROR | LogLevel | 5.3.28 | |
| WARN | LogLevel | 5.3.28 | |
| INFO | LogLevel | 5.3.28 | |
| DEBUG | LogLevel | 5.3.28 | |
| TRACE | LogLevel | 5.3.28 | |
| ALL | LogLevel | 5.3.28 |
SDK示例
Java
SDK
AddLogServerAction action = new AddLogServerAction();
action.name = "log-server";
action.description = "log server";
action.category = "ManagementNodeLog";
action.type = "Log4j2";
action.level = "ALL";
action.configuration = "{
"appenderType": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddLogServerAction.Result res = action.call();Python
SDK
AddLogServerAction action = AddLogServerAction()
action.name = "log-server"
action.description = "log server"
action.category = "ManagementNodeLog"
action.type = "Log4j2"
action.level = "ALL"
action.configuration = "{
"appenderType": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddLogServerAction.Result res = action.call()DeleteLogSever
API Request
URLs
DELETE zstack/v1/log/serversHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/log/serversRequest Parameters
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | body | The resource UUID. | 5.3.28 | |
| systemTags | List | body | Optional. The system tags. | 5.3.28 | |
| userTags | List | body | Optional. The user tags. | 5.3.28 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
DeleteLogServerAction action = new DeleteLogServerAction();
action.uuid = "cdc213d6ba25367ea6c4d201491d900c";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteLogServerAction.Result res = action.call();Python
SDK
DeleteLogServerAction action = DeleteLogServerAction()
action.uuid = "cdc213d6ba25367ea6c4d201491d900c"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteLogServerAction.Result res = action.call()QueryLogServer
API Request
URLs
GET zstack/v1/log/serversGET zstack/v1/log/servers/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/log/servers?q=uuid=xxx&q=name=xxxcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/log/servers/9699713cfb583c70b749adca2c01a77bQueryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryLdapServer, and pressing the Tab key.
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
QueryLogServerAction action = new QueryLogServerAction();
action.conditions = asList("uuid=xxx","name=xxx");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryLogServerAction.Result res = action.call();Python
SDK
QueryLogServerAction action = QueryLogServerAction()
action.conditions = ["uuid=xxx","name=xxx"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryLogServerAction.Result res = action.call()UpdateLogServer
API Request
URLs
PUT zstack/v1/log/serversHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"updateLogServer": {
"uuid": "10bf3f837edf37a0be99a84d1edafb6b",
"name": "example"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateLogServer":{"uuid":"10bf3f837edf37a0be99a84d1edafb6b","name":"example"}}' \
http://localhost:8080/zstack/v1/log/serversRequest Parameters
| Name | Type | Location | Description | Valid Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | body (container in the updateLogServer structure) | The resource UUID. | 5.3.28 | |
| name | String | body (container in the updateLogServer structure) | Optional. The resource name. | 5.3.28 | |
| description | String | body (container in the updateLogServer structure) | Optional. The resource description. | 5.3.28 | |
| systemTags | List | body | Optional. The system tags. | 5.3.28 | |
| userTags | List | body | Optional. The user tags. | 5.3.28 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
UpdateLogServerAction action = new UpdateLogServerAction();
action.uuid = "10bf3f837edf37a0be99a84d1edafb6b";
action.name = "example";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateLogServerAction.Result res = action.call();Python
SDK
UpdateLogServerAction action = UpdateLogServerAction()
action.uuid = "10bf3f837edf37a0be99a84d1edafb6b"
action.name = "example"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateLogServerAction.Result res = action.call()