In extensions framework I can’t use groups and devices any more.
Therefor I need to create a topology for the definition here below that I need to add in the extension.yaml file
# report device metrics from the API def reportDeviceMetrics(self, session): # Create group - provide group id used to calculate unique entity id in dynatrace # and display name for UI presentation group = self.topology_builder.create_group(identifier=self.unifisitename, group_name=self.unifisitedesc) response = session.get( url=“{}/api/s/{}/stat/device”.format(self.url, self.unifisitename), headers = self.headers, verify = False, timeout = 1 ) if response.status_code != 200: logger.error("Exception happened during device-basic api call = " + resp.text) devices = response.json().get(“data”) for device in devices: print(device.get(“name”)) # Create device - provide device id used to calculate unique entity id in dynatrace # and display name for UI presentation node = group.create_device(identifier=“unifi-device-{}”.format(device.get(“name”)), display_name=device.get(“name”)) logger.info(“Topology: group name=%s, device name=%s”, group.name, node.name) # report property - any string-string values pair. It is added to device metadata displayed in dynatrace UI node.report_property(key=‘mac’, value=device.get(‘mac’)) node.report_property(key=‘disabled’, value=str(device.get(‘disabled’))) node.report_property(key=‘adopted’, value=str(device.get(‘adopted’))) node.report_property(key=‘type’, value=device.get(‘type’)) node.report_property(key=‘model’, value=device.get(‘model’)) # report state - value must be one from list located in json file. devicestate = ‘OFF’ if device.get(‘state’) == 1: devicestate = ‘ON’ node.state_metric(key=‘state’, value=devicestate)
systemStats = device.get(‘system-stats’) if systemStats is not None: node.absolute(key=‘sys-cpu’, value=float(systemStats.get(“cpu”))) node.absolute(key=‘sys-memory’, value=float(systemStats.get(“mem”)))
Anybody an idea how to do that?