Adding to an Adapter¶
Object Model¶
What is the Object Model?¶
At runtime, Aria Operations Manager creates objects representing data sources in the adapter. Every adapter must include
an object model that provides object types, object properties, and semantic definitions describing resources and the
metric data's meaning. The object model can be defined by using a describe.xml
file, which should be defined in the
conf
directory, or it can be defined using the definition
module
from the Python Adapter Library
by defining the AdapterDefinition object returned by
The get_adapter_definition()
method in app/adapter.py
.
describe.xml vs. AdapterDefinition¶
When running mp-build
, mp-test collect
, or mp-test test
they call the get_adapter_definition()
method
and then generate describe.xml
file with the AdapterDefinition
object. If a describe.xml
file is present in the conf
directory, then the object returned by the get_adapter_definition
method will be ignored.
Defining an Adapter and Adapter Instance in the Object Model¶
To define an adapter in the conf/describe.xml
file use the top-level AdapterKind
element. Only one adapter can be
defined in the object model. The key
will be used
when creating objects (See Creating an object), and must also be present in the manifest.txt
file in the "adapter_kinds"
array. When defining an adapter, we also have to define an adapter instance type. An adapter
instance is a special object in VMware Aria Operations that stores user configuration for a connection. Every adapter
must have exactly one adapter instance type. The Adapter instance type is set by defining a ResourceKind
element with
attribute type=7
. in Python, we can use the AdapterDefinition.
Info
For more information about the supported elements and attributes, see the describe.xml documentation. For more information about the Python module visit Python Adapter Library.
Once an adapter instance is defined, any configuration fields (ResourceIdentifier
element) and credentials (CredentialKind
element)
will be prompted to the user when creating an account in VMware Aria Operations on the Data Sources
→ Integrations
page (See Adding a Configuration Field to an Adapter Instance
and Adding a Credential. After the account has been created, configuration fields will be
available in the input to the collect
, test
, and get_endpoint
methods.
(See Creating an Adapter Instance.)
Adding a Configuration Field to an Adapter Instance in the Object Model¶
Adapter instance identifiers distinguish between adapter instances from the same adapter. They also allow for user configuration.
Info
For more information about the supported elements and attributes, see the describe.xml documentation. For more information about the Python module visit Python Adapter Library.
In the describe.xml
adapter instance identifiers can have an identType
of 1
or 2
. A type of 1
means the
identifier will be used for determining uniqueness, and will show up by default on the configuration page. If the type
is 2
, the identifier is non-identifying, and will show up under the 'advanced' section of the configuration page.
In Python, the Parameter object has an advanced
attribute that
determines identType.
Creating an account from the above xml (plus a credential).
ssl_mode
andmax_events
have an identType of 2, so they are present in 'Advanced Settings'.Note: If there are any existing connections used by the
mp-test
tool before resource identifiers were created or updated, these will need to be deleted or updated.
Once an adapter instance is defined, any configuration fields (ResourceIdentifier
element) will be prompted to the user when
creating an account in VMware Aria Operations on the Data Sources
→ Integrations
page.
After the account has been created, configuration fields will be available to the AdapterInstance
object passed to the
collect
, test
, and get_endpoints
methods defined in adapter.py
. (See Creating an Adapter Instance.)
Defining a Credential in the Object Model¶
In order to connect to most targets a credential is required. If necessary, an adapter can have multiple different credential kinds.
To add a credential to the Adapter using in the conf/describe.xml
, add a CredentialKind
element to AdapterKind/CredentialKinds
.
The CredentialKind
element takes one or more CredentialField
elements which correspond to an individual piece
of data needed for a credential. In Python, we can use the AdapterDefinition.define_credential_type
function
to define a new credential type and add it to the AdapterDefinition
object; then we can specify each credential
field using the returned CredentialType.
A typical credential that requires a username and password might look like this:
Info
For more information about the supported elements and attributes, see the describe.xml documentation. For more information about the Python module visit Python Adapter Library.
When defining a credential in conf/describe.xml
file, it must be added to the Adapter Instance. The adapter
instance is a special ResourceKind
that is used to configure an adapter. It is marked with the xml attribute/value
type="7"
. To add the credential to the adapter instance, add an attribute credentialKind
to the adapter instance's
ResourceKind
element, with a value of the CredentialKind
's key
attribute.
Adding a credential to an adapter instance with the
username
andpassword
fields as defined above. 'Credential name' is always added (by VMware Aria Operations), and allows for credentials to be reused between adapter instances.
Both describe.xml
and AdapterDefinition allow for the
use of multiple credential types.
Note
In the describe.xml credential kind keys are separated by a comma.
Once the credential is defined in the object model, it can be used in the adapter code.
Note
If there are any existing connections used by the mp-test
tool before the credential was created
or updated, these will need to be deleted or updated.
Once an adapter instance is defined, any credential defined in the object model
will be prompted to the user when creating an account in VMware Aria Operations on the Data Sources
→ Integrations
page. After the account has been created, credential fields will be available AdapterInstance
object passed to the
collect
, test
, and get_endpoints
methods.(See Creating an Adapter Instance.)
Using the Python Adapter Library,
the credentials are available in the AdapterInstance object passed to
the collect
, test
, and get_endpoint
methods in app/adapter.py
(See Creating an Adapter Instance.).
If an adapter supports multiple credential types, the AdapterInstance.get_credential_type() function can be used to determine the type of the
credential used by the adapter instance.
Creating an Adapter Instance¶
Using the Python Adapter Library,
the canonical method for creating an adapter instance is using the AdapterInstance
object. Configuration fields and
credentials can be accessed using get_identifier_value
and get_credential_value
, respectively. These methods return
None
if the given key does not exist in the adapter instance.
Note
AdapterInstance.from_input()
can only be called once per collection, test connection, or getEndpointURL invocation.
For other languages, or using Python without the Python Adapter Library module, JSON representing the adapter instance is sent to a named pipe. The second-to-last argument the adapter is invoked with will always be the filename of the named pipe. The adapter instance JSON is described in the VMware Aria Operations Collector Framework OpenAPI Document.
Adding an Object Type to the Object Model¶
An object type is a class of objects (resources) that share the same set of metrics, properties, and identifiers. For
example an adapter might have a 'Database' object kind, and when an adapter instance is created and connects to an
application, several 'database' objects are created representing distinct databases in the application.
To create a new object type in the conf/describe.xml
file, add a ResourceKind
element inside AdapterKind/ResourceKinds
.
A key
attribute is required, and must be unique among other object types within the describe.xml
file.
To create a new object type using the Python Adapter Library
use the AdapterDefinition.define_object_type
function of AdapterDefinition object.
In addition, an object type may have identifiers, which can distinguish between objects of the same type. In the database
example, we may need to know a port
and ip address
to uniquely identify each database. If no identifiers are specified,
an object's name
is used for determining uniqueness. If any identifiers are present (see note), then the name
is
not used for this purpose.
Note
'ResourceIdentifier' element can have an identType
of 1
or 2
. A type of 1
is most common, and means the
identifier will be used for determining uniqueness. If the type is 2
, the identifier is non-identifying, and will
show up in the identifiers of an object but will not cause a new object to be created if it changes. If all
identifiers are non-identifying, then the object's name reverts to determining uniqueness of objects. When using
Python Adapter Library
the define_string_identifier accepts a is_part_of_uniqueness
parameter, which is True by default.
Info
For more information about the supported elements and attributes, see the describe.xml documentation. For more information about the Python module visit Python Adapter Library.
Once the object type is defined in the object model, it can be used in the adapter code. See Creating an object.
Creating an Object¶
Before creating an object, ensure that the object type is present in the object model.
Using the Python Adapter Library, the canonical method for creating a new object is to use the CollectResult object.
Two objects of type 'my_database_resource_kind'. The creation of the db1 object is shown above. This view is found in
Environment
→Inventory
. By default, the identifiers are not shown. They can be enabled by clicking the menu icon in the lower left (not shown in this screenshot) and selecting the identifier columns. Identifiers are ordered in ascendingdispOrder
.
For other languages, or using Python without the VMware Aria Operations Integration module, objects must be returned as JSON, described in the VMware Aria Operations Collector Framework OpenAPI Document .
Defining an Attribute in the Object Model¶
An attribute is a class of metrics or properties similar to how an object type is a class of objects. Attributes can be either a metric or property. * A metric is numeric data that is useful to track over time. Examples: CPU Utilization (%), Used Disk Space (GB) * A property is numeric or string data that rarely changes and only the current (last) value is relevant. Examples: Operating System Name, CPU Count
Note
Properties should not be used for string data that has a large number of possible values. For example, if you
want to have a property that shows the last time an operation was run on a server, it is better to convert that
to a numeric metric such as hours_since_last_operation
, rather than using a string property with a human-readable
timestamp, as large numbers of distinct string values can degrade the performance of VMware Aria Operations.
in the conf/describe.xml
file, attributes can be grouped together in ResourceGroup
elements, which can be nested.
ResourceGroups
can also be instanced.
Info
For more information about the supported elements and attributes, see the describe.xml documentation. For more information about the Python module visit Python Adapter Library.
Once an attribute is defined in the object model, it can be used in the adapter code. See Creating a metric or property.
Creating a Metric or Property¶
Before creating a metric or property, ensure that the attribute describing the data is present in the object model.
Using the Python Adapter Library , metrics and properties can be added using the attribute key and a value. In the case of attributes in groups, the group key(s) and attribute key are separated by a pipe "|" and form the metric or property key.
Result of the above code. Since the numbers and strings are hard-coded, these values will never change. For a real adapter, the values will be the result of querying the target for up-to-date information. Note that there are a number of automatically generated metrics and properties. The metric groups 'Badge', 'VMware Aria Operations Generated', and 'VMware Aria Operations Manager Generated Properties' (and the metrics and properties inside) are present on every object.
For other languages, or using Python without the VMware Aria Operations Integration module, metrics and properties are returned as JSON inside of objects, described in the VMware Aria Operations Collector Framework OpenAPI Document.
Creating an Event¶
Events do not need to be declared in the object model file, and can simply be added to an object at runtime.
Using the Python Adapter Library , events are added to resources. The only required parameter is the message, which describes and uniquely identifies the event.
Result of the above code. Note that the criticality is affecting the health of the db1 object it is attached to.
For other languages, or using Python without the Python Adapter Library module, events are returned as JSON inside of objects, described in the VMware Aria Operations Collector Framework OpenAPI Document .
Creating a Relationship¶
Relationships do not need to be declared in the object model file, and can simply be added between objects at runtime. Relationships are always between a parent and child, and if object1 is a parent of object2, that implies object2 is a child of object1.
Using the Python Adapter Library , relationships are added to resources.
Important: Relationships must not have cycles. A cycle happens when an object's relationships are structured in such a way that it is its own descendant (or ancestor). For example, object1
parentOf
object2, object2parentOf
object3, object3parentOf
object1 creates a cycle. Care should be taken to avoid these, as they can adversely affect VMware Aria Operations' analytics calculations.
Result of the above code. The db1 and db2 objects are both children of the 'instance' object. The health of a child object can impact the health of a parent object.
For other languages, or using Python without the VMware Aria Operations Integration module, relationships are returned as JSON inside a collect result object, described in the VMware Aria Operations Collector Framework OpenAPI Document .