This is a general description of the SQL data source based extension YAML file and ways to declare metrics and dimensions that you would like to collect using your extension.
While the Extensions 2.0 framework is secure, the security of your extensions also depends on how you develop them and manage them in your Dynatrace environment.
We recommend the following when developing custom SQL extensions:
SELECT
queries are available
SHOW GLOBAL STATUS
Create an inventory of the data you want to query from your database as the source for your metric and dimension values.
In our example, we create a simple extension collecting basic CPU performance details from an Oracle Database.
name: com.dynatrace.extension.sql-oracleversion: 1.0minDynatraceVersion: '1.239'author:name: DynatracesqlOracle:- group: Number of CPU coresfeatureSet: cpuquery: >SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'metrics:- key: com.dynatrace.extension.sql-oracle.cpu.coresvalue: col:cpu_counttype: gauge- group: Background CPU Usage Per CPU Per SecfeatureSet: cpuquery: >SELECTDECODE(metric_name, 'Background CPU Usage Per Sec',v$metric.value) AS background_cpu_usage,DECODE(metric_name, 'CPU Usage Per Sec',v$metric.value) AS foreground_cpu_usage,DECODE(metric_name, 'Host CPU Usage Per Sec',v$metric.value) AS host_cpu_usageFROM v$metric,v$metricgroupWHERE v$metric.group_id = v$metricgroup.group_idAND v$metric.metric_name IN ('Background CPU Usage Per Sec','CPU Usage Per Sec', 'Host CPU Usage Per Sec')metrics:- key: com.dynatrace.extension.sql-oracle.cpu.backgroundTotalvalue: col:background_cpu_usagetype: gauge- key: com.dynatrace.extension.sql-oracle.cpu.foregroundTotalvalue: col:foreground_cpu_usagetype: gauge- key: com.dynatrace.extension.sql-oracle.cpu.hostTotalvalue: col:host_cpu_usagetype: gauge
Depending on the provider, your SQL monitoring scope definition starts with a dedicated YAML node. For Oracle Database, it's sqloracle
. All the settings under the node pertain to the declared data source type (in this case, SQL).
Dynatrace Extensions SQL data source enables you to query any database allowing connections using the JDBC driver on top of all the database vendors supported by default. For such databases, some additional steps are required.
jdbc
node.org.mariadb.jdbc.Driver
.jdbc:driverClassName: “org.mariadb.jdbc.Driver”connectionStringPattern: “jdbc:mariadb:(. |\\s)+$"connectionStringPatternErrorMessage: “This isn't a correct connection string, please start with jdbc:mariadb."validationQuery: “SELECT 1”
Users running your extension will also need to upload a related JDBC driver to an ActiveGate belonging to the group designated to run your extension. For more information, see JDBC monitoring configuration.
SQL extensions rely on SQL queries. The queries declared in your extension retrieve the values for your metrics and dimensions.
For example, the following SQL query returns the number of CPU cores.
SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'
You can use it in your extension and report the value returned by a query as the com.dynatrace.extension.sql-oracle.cpu.cores
metric in Dynatrace.
sqlOracle:- group: Number of CPU coresfeatureSet: cpuquery:SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'metrics:- key: com.dynatrace.extension.sql-oracle.cpu.coresvalue: col:cpu_counttype: gauge
You can set the frequency at which database provider is queried. If you don't set, the database provider is queried every minute by default.
You can use one of the two exclusive properties to control when the database provider is queried, interval
or schedule
. You can define it at the group or subgroup level.
ActiveGate version 1.301+
The interval value accepts an integer value expressing minutes. For example, to query the database provider every 10 minutes, add the following entry:
sqlOracle:- group: Number of CPU coresfeatureSet: cpuinterval:minutes: 10query:SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'metrics:- key: com.dynatrace.extension.sql-oracle.cpu.coresvalue: col:cpu_counttype: gauge
ActiveGate version 1.301+
You can use a cron expression to query your database provider using a schedule of your choice.
The expression must follow the Unix cron format:
# * * * * *# | | | | |# | | | | day of the week (0–6) (Sunday to Saturday)# | | | month (1–12)# | | day of the month (1–31)# | hour (0–23)# minute (0–59)
The values also support lists (1,2,3,4
), steps (0-23/2
), and ranges (2-5
).
The format doesn't support specifying both a day-of-week and a day-of-month value. You must use the ‘?’ character in one of these fields.
For example, to run a query at 12:00 on every week day (Monday-Friday), use the following entry:
sqlOracle:- group: Number of CPU coresfeatureSet: cpuschedule: "0 12 ? * 1-5"query:SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'metrics:- key: com.dynatrace.extension.sql-oracle.cpu.coresvalue: col:cpu_counttype: gauge
ActiveGate version 1.303+
If you want to let your extension users control the frequency at which a database provider is queried, you can use variables instead of fixed values. Users will be able to define the variable value when activating the extensions.
Make sure you describe your variable context in detail, so that users understand how to set the variable value properly. You can also set the pattern to help users validate their entries.
For example, to let user control the interval:
First, declare the variable in your extension YAML file
vars:- id: myIntervaldisplayName: Intervaldescription: Interval at which your database provider is queried in minutes. 10 minutes by default.defaultValue: 10pattern: ^[0-9]+$type: text
Then, reference the variable instead of a fixed value in your extension YAML file
sqlOracle:- group: Number of CPU coresinterval: var:myIntervalfeatureSet: cpuquery:SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'metrics:- key: com.dynatrace.extension.sql-oracle.cpu.coresvalue: col:cpu_counttype: gauge
For more information on using variables, see Extension YAML file
For each level (extension, group, subgroup), you can define up to 25 dimensions.
The dimension key string must conform to the metrics ingestion protocol.
You use an SQL query to retrieve a value for your dimension (prefix with col:
) or use a fixed string (prefix with const:
). For example:
query: >SELECT event, wait_classFROM v$system_eventdimensions:- key: eventvalue: col:event- key: wait_classvalue: col:wait_class- key: stagevalue: const:dev
For each level (extension, group, subgroup), you can define up to 100 metrics.
For example:
sqlOracle:- group: Number of CPU coresfeatureSet: cpuquery:SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'metrics:- key: com.dynatrace.extension.sql-oracle.cpu.coresvalue: col:cpu_counttype: gauge
The metric key string must conform to the metrics ingestion protocol.
For Dynatrace versions 1.215 and 1.217, a metric node requires the id
parameter in place of key
. Starting with Dynatrace version 1.219, you should use the key
parameter, as id
will be considered deprecated.
The metrics you ingest into Dynatrace using your extension are just some of the thousands of metrics, built-in and custom, processed by Dynatrace. To make your metrics keys unique and easy to identify in Dynatrace, the best practice is to prefix the metric name with the extension name. This guarantees that the metric key is unique and you can easily appoint a metric to a particular extension in your environment.
The column value queried from your database.
The Dynatrace Extensions 2.0 framework supports metric payloads in the gauge (gauge
) or count value (count
) formats. For details, see Metric payload. To indicate the metric type, use the type
attribute.
An Extension can define metadata for each metric available in Dynatrace. For example, you might want to add the metric display name and the unit, both of which can be used for filtering in the Metrics browser.
name: custom:example-extension-nameversion: 1.0.0minDynatraceVersion: "1.236"author:name: Dynatracemetrics:- key: your.metric.namemetadata:displayName: Display name of the metric visible in Metrics browserunit: Count
Feature sets are categories into which you organize the data collected by the extension. In this example, we create an Oracle SQL extension collecting metrics related to CPU and Input/Output performance. This is reflected by the metrics organization into related feature sets cpu
and io
.
sqlOracle:- group: Number of CPU coresfeatureSet: cpuquery:SELECT value AS cpu_countFROM v$parameterWHERE name = 'cpu_count'metrics:- key: com.dynatrace.extension.sql-oracle.cpu.coresvalue: col:cpu_counttype: gauge- group: Physical read bytesfeatureSet: ioquery: >SELECTDECODE(name, 'physical read total bytes', value) AS bytes_written,DECODE(name, 'physical write total bytes', value) AS bytes_readFROM v$sysstatWHERE name IN ('physical read total bytes', 'physical write total bytes')metrics:- key: com.dynatrace.extension.sql-oracle.io.bytesReadvalue: col:bytes_readtype: count- key: com.dynatrace.extension.sql-oracle.io.bytesWrittenvalue: col:bytes_writtentype: count
When activating your extension using monitoring configuration, you can limit monitoring to one of the feature sets. To work properly the extension has to collect at least one metric after the activation.
In highly segmented networks, feature sets can reflect the segments of your environment. Then, when you create a monitoring configuration, you can select a feature set and a corresponding ActiveGate group that can connect to this particular segment.
All metrics that aren't categorized into any feature set are considered to be the default and are always reported.
A metric inherits the feature set of a subgroup, which in turn inherits the feature set of a group. Also, the feature set defined on the metric level overrides the feature set defined on the subgroup level, which in turn overrides the feature set defined on the group level.
After you define the scope of your configuration, you need to identify the network devices you'd like to collect data from and identify the ActiveGates that will execute the extension and connect to your devices.
The monitoring configuration format depends on the database provider. For more information, see Oracle Database monitoring configuration.