Push problems and events from an ActiveGate plugin

Refer to Problem detection and analysis description to understand the problem and event concepts in Dynatrace.

How to push problems and events from an ActiveGate plugin

ActiveGate plugins enable you to push the infrastructure problems and events for a monitored technology on a device level. Problems and events for a device group are not available.

You can use the following API methods to report problems:

  • report_performance_event
  • report_error_event
  • report_availability_event
  • report_resource_contention_event

You can use the following API methods to send the events:

  • report_custom_info_event
  • report_custom_deployment_event
  • report_custom_annotation_event

Problems and events are made up of the title, description, and a set of custom key-value properties that report important context information. See ActiveGate plugins reference.

To send a problem or event, execute the following steps in the plugin source code:

  1. Create a topology group.
  2. Create an element (device) in this group.
  3. Push problem or event using one of the methods mentioned above.

There's no need to define anything specific in the plugin.json file.

Limitations

There are some restrictions with regard to event reporting to protect the server against data flood:

  • Max length of Title string cannot be larger than 1024 characters; longer strings will be trimmed.
  • Max length of Description string cannot be larger than 10240 characters; longer strings will be trimmed.
  • Max number of elements in the properties dictionary cannot be larger than 100. If more elements are passed to the method, it will be automatically trimmed to 100.
  • Max length of KEY string cannot be larger than 100; longer stings will be trimmed.
  • Max length of VALUE string cannot be larger than 4000; longer stings will be trimmed.

Working example

The following example shows how to push problems and events from a plugin:

Example Python file
Download
from ruxit.api.base_plugin import RemoteBasePlugin
import logging

logger = 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):
        # 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="DemoGroup",
                                                   group_name="ActiveGate Demo Group")

        # Create node - provide node id used to calculate unique entity id in dynatrace
        #   and display name for UI presentation
        node = group.create_element(identifier="DemoNode",
                                    element_name="ActiveGate Demo Node")

        logger.info("Topology: group name=%s, node name=%s", group.name, node.name)

        # Push infrastructure problems
        node.report_performance_event(title="Performance Event",
                                      description="Use it to focus on some performance issue",
                                      properties={"property_key": "property_value"})

        node.report_error_event(title="Error Event",
                                description="Use it to report some error",
                                properties={"property_key": "property_value"})

        node.report_availability_event(title="Availability Event",
                                       description="Use it to focus on some availability issue",
                                       properties={"property_key": "property_value"})

        node.report_resource_contention_event(title="Resources Contention Event",
                                              description="Use it to focus on some resource contention issue",
                                              properties={"property_key": "property_value"})

        # Push custom info events
        node.report_custom_info_event(title="Custom Info Event",
                                      description="Use it to report some custom info",
                                      properties={"property_key": "property_value"})

        node.report_custom_deployment_event(source="demo source",
                                            project="demo plugin",
                                            version="1.001",
                                            ci_link=self.url + "/deployment",
                                            remediation_action_link=self.url + "/remediation",
                                            deployment_name="Demo deployment",
                                            properties={"property_key": "property_value"})

        node.report_custom_annotation_event(description="Annotation event",
                                            annotation_type="demo",
                                            source="demo source",
                                            properties={"property_key": "property_value"})
 

Example JSON file
Download
{
	"name": "custom.remote.python.demo_events",
	"version": "1.009",
	"type": "python",
	"entity": "CUSTOM_DEVICE",
	"processTypeNames": ["PYTHON"],
	"technologies": ["ActiveGate Demo Technology"],
	"favicon": "https://lh3.googleusercontent.com/gN6iBKP1b2GTXZZoCxhyXiYIAh8QJ_8xzlhEK6csyDadA4GdkEdIEy9Bc8s5jozt1g=w300",
	"source": {
		"package": "demo_activegate_plugin_events",
		"className": "DemoPluginRemote",
		"install_requires": ["requests>=2.6.0"],
		"activation": "Remote"
	},
	"configUI": {
		"displayName": "ActiveGate Demo Plugin - Events",
		"properties": [{
			"key": "url",
			"displayName": "URL",
			"displayHint": "http://localhost:8769"
		}]
	},
	"properties": [{
		"key": "url",
		"type": "String",
        "defaultValue": "http://localhost:8769"
	}],
	"metrics": [{
			"entity": "CUSTOM_DEVICE",
			"timeseries": {
				"key": "counter",
				"unit": "Count",
				"displayname": "Counter"
			}
		}
	],
	"ui": {

	}
}

This plugin pushes all the problems and events every minute.

This example is included in Plugin SDK and can be installed using oneagent_build_plugin script.