You can create a new attribute definition. The attribute definition must have a unique ID. If the attribute definition ID already exists, then an error message is received. You can create multiple attribute definitions in a single request.
Request line
Post baseURL/dbapi.do?action=createAttributeDef&dataset=<Datasetname>
Request body
[ { "id":"", "name":"", "type":"" }, { "id":"", "name":"", "type":"" }, { "dynamic":, "id":"", "name":"", "type":"", "unit":"", "bandFactor": } ]
Request example
POST /dbapi.do?action=createAttributeDef&dataset=defaultDs HTTP /1.1 Authorization:Basic ZnJlZDpmcmVk
[ { "id":"numCores", "name":"Number Of Cpu cores", "type":"scalar" }, { "id":"cpuUsage", "name":"cpuUsage", "type":"timeseries" }, { "dynamic":true, "id":"^byteFlow_(\\d{1,5})_(\\d{1,5})_([A-Za-z]*[0-9]*)$", "name":" Network Traffic", "type":"timeseries", "unit":"Bytes", "bandFactor":1 } ]
Request parameters
Parameter | Type | Description |
---|---|---|
action | String | createAttributeDef
Specify the API function to be invoked. |
dataset | String | Dataset name. From 2 to 32 alphanumeric, underscore (_), and hyphen (-) characters are allowed. |
id | Integer | Unique attribute definition ID.
From 2 to 32 alphanumeric, underscore (_), and hyphen (-) characters are allowed. |
name | String | (Optional) Attribute definition name.
From 2 to 128 alphanumeric characters are allowed. Default: Attribute ID |
unit | String | (Optional) Unit of measure.
From 2 to 32 alphanumeric, underscore (_), and hyphen (-) characters are allowed.. Default: Blank |
dynamic | Boolean | (Optional) Specify if this attribute is dynamic or not.
true or false Default: false |
bandFactor | Float | (Optional) Decimal precision for attribute value.
A positive decimal number. Default: 1 |
A resource can have multiple combinations of the same attribute. For example, in the network flow analysis between a pair of IP addresses, a usage metric can be collected for all combinations of source port, destination port, and protocol ( UDP or TCP). Although multiple combinations are possible, only a single definition is maintained for an attribute. These types of attributes are dynamic attributes.
Parameter | Description |
---|---|
dynamic | Indicates that this definition is for a dynamic attribute. |
id |
Dynamic attribute definition ID consists of two parts: static and dynamic, separated by an underscore (_). The dynamic part is optional. Dynamic attribute definition ID must begin with the carat (^) character, followed by the static part. The static part must not have an underscore (_), but can have from 2 to 32 alphanumeric and hyphen (-) characters. The dynamic part must be a valid regular expression following the Java pattern class. For example, ^byteFlow_(\\d{1,5})_(\\d{1,5})_([A-Za-z]*[0-9]*)$ Where, byteFlow is the static part, and (\\d{1,5})_(\\d{1,5})_([A-Za-z]*[0-9]*)$ is the dynamic part. The following instances match the above attribute ID pattern:
|
Response body
{ "created":[ "" ], "failed":[ { "code":"", "id":"", "error":"" } ] }
Response example
{ "created":[ "^byteFlow_(\\d{1,5})_(\\d{1,5})_([A-Za-z]*[0-9]*)$" ], "failed":[ { "code":"41050004", "id":"numCores", "error":"Attribute definition with {id}:[numCores] already exists" }, { "code":"4102000F", "id":"cpuUsage%", "error":"Invalid value specified for parameter {id}. {id} contains invalid characters. Valid characters are [alphanumeric, - and _]." } ] }
Response parameters
Parameter |
Type |
Description |
---|---|---|
created | String[ ] | List of created attribute IDs. |
failed | Object[ ] | List of failed entities. |
failed:code | String | Eight-digit hexadecimal error code. |
failed:id | String | Failed attribute ID. |
failed:error | String | Error message. |
Status codes
Status code |
Message |
Description |
---|---|---|
200 | OK | Request was successful, and the response body contains the requested log details. |
206 | PARTIAL CONTENT | Request is in progress, and the incremental content is available in the response body. |
277 | PARTIAL OK | Request completed successfully with some failures. Check the response body for details. |
400 | BAD REQUEST | Request URL or request body validation failed. Check the response body for details. |
401 | UNAUTHORIZED | Supplied authentication token is invalid or does not have the appropriate credentials to access the resource. |
404 | NOT FOUND | API server could not find a resource matching the request. |
405 | METHOD NOT ALLOWED | Request HTTP method is not allowed for the operation. |
500 | SERVER ERROR | API operation request failed. Check the response body for details. |
Response codes
The following table lists the common API response codes that might be generated through the standard API. If an error response is not listed, examine the HTTP status codes to determine the best method for addressing the issue.
Response code | Message | Condition |
---|---|---|
41050004 | Attribute definition with {id}:[cpuUsage] already exists. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The attribute definition ID already exists in the database. |
4102000F | Invalid value specified for parameter {id}. {id} contains invalid characters. Valid characters are [alphanumeric, - and _]. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The specified attribute definition ID contains invalid characters. |
4102000F | Invalid value specified for parameter {id}. Dynamic attributeId must start with [^]. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The specified dynamic attribute definition ID does not start with ^ . |
4102000F | Invalid value specified for parameter {id}. Specified regular expression is invalid. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The specified dynamic attribute definition ID contains invalid regex. |
41050004 | Attribute definition with {id}:[cpuUsage] already exists. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The specified attribute definition ID is already present with the same ID as the static part of the dynamic attribute definition ID. |
41050004 | Attribute definition with {id}:[^byteFlow_(\\d{1,5})_(\\d{1,5})_([A-Za-z]+[0-9]+)$] already exists. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The dynamic attribute definition is already present with a static part of the dynamic attribute ID, but with different regex. |
4102000F | Invalid value specified for parameter {id}. {id} length must be between 2-32 characters. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The attribute definition ID length is less than 2 or more than 32. |
41020008 | Mandatory parameter {type} not specified. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The parameter type is not specified. |
4102000F | Invalid value specified for parameter {type}. Valid values: scalar and timeseries. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The attribute definition contains an invalid value for the parameter type. |
41020007 | No regular expression is specified. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The dynamic attribute definition contains no regex. |
4102000F | Invalid value specified for parameter {bandFactor}. Band factor must be one of [1.0, 0.1, 0.01, 0.001, 0.0001]. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The attribute definition contains an invalid value for the parameter bandFactor. |
4102000F | Invalid value specified for parameter {unit}. {unit} length must be between 2-32 characters. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The attribute unit length is less than 2 or more than 32. |
4102000F | Invalid value specified for parameter {unit}. {unit} contains invalid characters. Valid characters are [alphanumeric, - and _]. | Minimum of one attribute definition is created and the creation of one or more attribute definitions failed. The specified unit parameter contains invalid characters. |
4102000F | Invalid value specified for parameter {name}. {name} length must be between 2-128 characters. | Minimum of one attribute definition is created and one or more attribute definitions failed as the specified attribute name is not valid in terms of allowed length. |
4102000C | Parameter {bandFactor} not supported. Parameter {bandFactor} is only supported for timeseries attributes. | The parameter bandFactor is specified for the scalar attribute. |
4102000F | Invalid value specified for parameter {id}. Dynamic attributeId must start with [^]. | Invalid value is specified for the dynamic attribute in the id parameter. |
4102000C | Parameter {dynamic} not supported. Parameter {dynamic} is only supported for timeseries attributes. | The dynamic parameter is specified for the scalar attribute. |
41040007 | No Attribute definition is specified. | The attribute definition is not specified for insertion. |
41010002 | Invalid JSON Request. | Specified JSON input is invalid. |
41050008 | Mandatory parameter {id} not specified. | Attribute definition ID is not specified in the id parameter. |
410000E9 | License is not valid. | License is not uploaded, or the uploaded license is invalid or expired. |
410000E9 | Authorization needed. | Request is sent with an invalid authentication token. |
410000E4 | Dataset with {name}:[ds1] does not exist. | Request is sent for a dataset that does not exist. |
410000E0 | HTTP method [PUT] is not supported for action [createAttributeDef]. | Request is sent with an HTTP method other than POST. |
410200E2 | Application encountered an internal error. | API server encountered an unknown error. |