Add Log Server Configuration

POST/zstack/v1/log/configurations

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "syslog",
    "type": "log4j2",
    "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": []
}

The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"syslog","type":"log4j2","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/configurations

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
nameStringbody (contained in the params structure)Resource name 3.10.0
description (optional)Stringbody (contained in the params structure)Detailed description of the resource 3.10.0
typeStringbody (contained in the params structure)  3.10.0
configurationStringbody (contained in the params structure)  3.10.0
resourceUuid (optional)Stringbody (contained in the params structure)Resource UUID 3.10.0
tagUuids (optional)Listbody (contained in the params structure)Tag UUID list 3.10.0
systemTags (optional)ListbodySystem tags 3.10.0
userTags (optional)ListbodyUser tags 3.10.0

API Response

Response Example

{
  "inventory": {
    "id": 0.0,
    "labelKey": "log4j2-f2828a4c39af4605a86a94a36b8f7865",
    "labelValue": "{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"
  }
}
NameTypeDescriptionStarting Version
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. See error3.10.0
inventoryResourceStackInventorySee inventory3.10.0

error

NameTypeDescriptionStarting Version
codeStringError code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.10013.10.0
descriptionStringBrief description of the error3.10.0
detailsStringDetailed error information3.10.0
elaborationStringReserved field. Defaults to null3.10.0
opaqueLinkedHashMapReserved field. Defaults to null3.10.0
causeErrorCodeRoot error. The source error that caused this error. Null if no root cause exists3.10.0

inventory

NameTypeDescriptionStarting Version
idlong 3.10.0
labelKeyString 3.10.0
labelValueString 3.10.0
resourceUuidStringResource UUID3.10.0
createDateTimestampCreation time3.10.0
lastOpDateTimestampLast modification time3.10.0

SDK Examples

Java SDK

AddLogConfigurationAction action = new AddLogConfigurationAction();
action.name = "syslog";
action.type = "log4j2";
action.configuration = "{
"appenderType": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddLogConfigurationAction.Result res = action.call();

Python SDK

AddLogConfigurationAction action = AddLogConfigurationAction()
action.name = "syslog"
action.type = "log4j2"
action.configuration = "{
"appenderType": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddLogConfigurationAction.Result res = action.call()