Custom properties
Dynatrace extensions enable you to send custom properties for a monitored technology on both, device and device group levels. The property has the form of a key-value pair, where both are strings.
To send a property, use the report_property(key="Key", value="Value") method:
group.report_property(key='Group version', value="0.5")
or
node.report_property(key='Device version', value="2.3")
The following example presents the complete extension code:
import jsonimport requestsfrom ruxit.api.base_plugin import RemoteBasePluginimport logginglogger = logging.getLogger(__name__)class DemoPluginRemote(RemoteBasePlugin):def initialize(self, **kwargs):config = kwargs['config']logger.info("Config: %s", config)self.url = config["url"]def query(self, **kwargs):# Collect statsstats = json.loads(requests.get(self.url).content.decode())# Create group - provide group id used to calculate unique entity id in dynatrace# and display name for UI presentationgroup = self.topology_builder.create_group(identifier="DemoGroup",group_name="ActiveGate Demo Group")# report group custom property - any string-string values pair. It is added to device group metadata displayed in dynatrace UIgroup.report_property(key='Group custom property: version', value=stats['version'])logger.info("1. Group custom property")# Create node - provide node id used to calculate unique entity id in dynatrace# and display name for UI presentationnode = group.create_element(identifier="DemoNode",element_name="ActiveGate Demo Node")logger.info("Topology: group name=%s, node name=%s", group.name, node.name)# report property - any string-string values pair. It is added to device metadata displayed in dynatrace UInode.report_property(key='Device custom property: version', value=stats['version'])logger.info("2. Device custom property")
There are no specific edits required in the plugin.json
file.
See an example of custom properties reported on the device group and device levels:
The ActiveGate plugin module limits the amount of data (custom properties and too long strings) sent to Dynatrace Server . The limit is set at 100 custom properties sent in a 24 hour time frame. Single property key string can't be longer than 50 characters. Single property value string can't be longer that 140 characters. The properties are reported in packages, a single package can't be longer than 5120 characters.