SQL data source reference
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.
Extension security
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:
Use a dedicated database user with read-only permissions in your monitoring configuration to prevent any unintentional changes to your database. Admin or system privileges must not be granted to the user.
Security controls
- Only
SELECT
queries are available- MySQL queries can also begin with
SHOW GLOBAL STATUS
- MySQL queries can also begin with
Only one query can be executed at a time
Queries containing comments are rejected
To prevent data integrity violations (manipulating, changing, or deleting data), the SQL data source executes the queries in rolled-back transactions. For this reason, databases that don't support transactions are not supported as a SQL data source.
Data scope
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.
1name: com.dynatrace.extension.sql-oracle2version: 1.03minDynatraceVersion: '1.239'4author:5 name: Dynatrace67sqlOracle:8 - group: Number of CPU cores9 featureSet: cpu10 query: >11 SELECT value AS cpu_count12 FROM v$parameter13 WHERE name = 'cpu_count'14 metrics:15 - key: com.dynatrace.extension.sql-oracle.cpu.cores16 value: col:cpu_count17 type: gauge18 - group: Background CPU Usage Per CPU Per Sec19 featureSet: cpu20 query: >21 SELECT22 DECODE(metric_name, 'Background CPU Usage Per Sec',23 v$metric.value) AS background_cpu_usage,24 DECODE(metric_name, 'CPU Usage Per Sec',25 v$metric.value) AS foreground_cpu_usage,26 DECODE(metric_name, 'Host CPU Usage Per Sec',27 v$metric.value) AS host_cpu_usage28 FROM v$metric,29 v$metricgroup30 WHERE v$metric.group_id = v$metricgroup.group_id31 AND v$metric.metric_name IN ('Background CPU Usage Per Sec',32 'CPU Usage Per Sec', 'Host CPU Usage Per Sec')33 metrics:34 - key: com.dynatrace.extension.sql-oracle.cpu.backgroundTotal35 value: col:background_cpu_usage36 type: gauge37 - key: com.dynatrace.extension.sql-oracle.cpu.foregroundTotal38 value: col:foreground_cpu_usage39 type: gauge40 - key: com.dynatrace.extension.sql-oracle.cpu.hostTotal41 value: col:host_cpu_usage42 type: 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).
SQL queries
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.
1SELECT value AS cpu_count2FROM v$parameter3WHERE 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.
1sqlOracle:2 - group: Number of CPU cores3 featureSet: cpu4 query:5 SELECT value AS cpu_count6 FROM v$parameter7 WHERE name = 'cpu_count'8 metrics:9 - key: com.dynatrace.extension.sql-oracle.cpu.cores10 value: col:cpu_count11 type: gauge
Interval
The database provider is queried at a fixed interval of one minute. The interval for the SQL data source is not configurable.
Dimensions
For each level (extension, group, subgroup), you can define up to 25 dimensions.
Dimension key
The dimension key string must conform to the metrics ingestion protocol.
Dimension value
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:
1query: >2 SELECT event, wait_class3 FROM v$system_event4dimensions:5 - key: event6 value: col:event7 - key: wait_class8 value: col:wait_class9 - key: stage10 value: const:dev
Metrics
For each level (extension, group, subgroup), you can define up to 100 metrics.
For example:
1sqlOracle:2 - group: Number of CPU cores3 featureSet: cpu4 query:5 SELECT value AS cpu_count6 FROM v$parameter7 WHERE name = 'cpu_count'8 metrics:9 - key: com.dynatrace.extension.sql-oracle.cpu.cores10 value: col:cpu_count11 type: gauge
Metric key
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.
Best practices for metric keys
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.
Metric value
The column value queried from your database.
Type
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.
Metric metadata
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.
1name: custom:example-extension-name2version: 1.0.03minDynatraceVersion: "1.236"4author:5 name: Dynatrace67metrics:8 - key: your.metric.name9 metadata:10 displayName: Display name of the metric visible in Metrics browser11 unit: Count
Feature set
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
.
1sqlOracle:2 - group: Number of CPU cores3 featureSet: cpu4 query:5 SELECT value AS cpu_count6 FROM v$parameter7 WHERE name = 'cpu_count'8 metrics:9 - key: com.dynatrace.extension.sql-oracle.cpu.cores10 value: col:cpu_count11 type: gauge12 - group: Physical read bytes13 featureSet: io14 query: >15 SELECT16 DECODE(name, 'physical read total bytes', value) AS bytes_written,17 DECODE(name, 'physical write total bytes', value) AS bytes_read18 FROM v$sysstat19 WHERE name IN ('physical read total bytes', 'physical write total bytes')20 metrics:21 - key: com.dynatrace.extension.sql-oracle.io.bytesRead22 value: col:bytes_read23 type: count24 - key: com.dynatrace.extension.sql-oracle.io.bytesWritten25 value: col:bytes_written26 type: 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.
Oracle SQL monitoring configuration
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.