I have developed a Python extension using the 2.0 framework that connects to a Microsoft SQL Server, executes a stored procedure, and reports custom metrics to Dynatrace. I am trying to specify the dt.entity.host dimension for my metrics because the host on which the extension runs is not necessarily the one that should be associated with the metric. The metric does appear in Dynatrace, but it seems as though the dt.entity.host dimension is being overriden by the OneAgent and it always shows host from the endpoint specified in the monitoring configuration.
So far, I have tried hard-coding the dimension as dt.entity.host = HOST-XXXXXXX, where HOST-XXXXXXX is another host’s id as written on Dynatrace:
dimensions = {'job_id':'XXX',
'name': 'XXX',
...
'dt.entity.host': 'HOST-XXXXXXXXXXXXXX'
}
self.report_metric("metric.name", 1, dimensions)
I have also created a host entity in my topology, since I want to specify a “RUNS_ON” relationship for my other entities. Here is the code for the extension.yaml file:
name: custom:foo-extension
version: 0.0.14
minDynatraceVersion: "1.253"
author:
name: "Name"
python:
runtime:
module: foo_extension
version:
min: "3.9"
activation:
remote:
path: activationSchema.json
local:
path: activationSchema.json
featureSets:
- featureSet: Job
metrics:
- key: mssql.job.status
- featureSet: Job Step
metrics:
- key: mssql.jobstep.status
metrics:
- key: mssql.job.status
metadata:
description: last run outcome of the job
displayName: mssql job status
unit: gauge
dimensions:
- key: job_id
displayName: Job ID
- key: job_name
displayName: Job Name
- key: category
displayName: Category
- key: type
displayName: Type
- key: owner
displayName: Owner
- key: current_execution_status
displayName: Current Execution Status
- key: has_step
displayName: Total Number of Steps Per Job
- key: current_execution_step
displayName: Current Execution Step's Name
- key: step_id
displayName: This Step's ID
- key: mssql.jobstep.status
metadata:
description: last run outcome of the job step
displayName: mssql job step status
unit: gauge
dimensions:
- key: job_id
displayName: This Job's ID
- key: job_name
displayName: This Job's Name
- key: step_id
displayName: This Step's ID
- key: step_name
displayName: Step Name
topology:
types:
- enabled: true
name: foo-extension:host
displayName: Host
rules:
- idPattern: "{dt.entity.host}"
instanceNamePattern: "{dt.entity.host}"
iconPattern: azure
attributes:
- key: job_id
displayName: Job ID
pattern: "{job_id}"
- key: name
displayName: Job Name
pattern: "{job_name}"
sources:
- sourceType: Metrics
condition: $prefix(mssql.job.)
- sourceType: Metrics
condition: $prefix(mssql.jobstep.)
role: default
- enabled: true
name: foo-extension:job
displayName: Job
rules:
- idPattern: "{job_id}"
instanceNamePattern: "{job_name}"
iconPattern: mssql
attributes:
- key: type
displayName: Type
pattern: "{type}"
- key: owner
displayName: Owner
pattern: "{owner}"
- key: category
displayName: Category
pattern: "{category}"
sources:
- sourceType: Metrics
condition: $prefix(mssql.job.)
role: default
- enabled: true
name: foo-extension:jobstep
displayName: Job step
rules:
- idPattern: "{job_id}-{step_id}"
instanceNamePattern: "{step_name}"
iconPattern: mssql
attributes:
- key: job_id
displayName: this job's id
pattern: "{job_id}"
- key: job
displayName: this job's name
pattern: "{job_name}"
- key: step_id
displayName: this step's id
pattern: "{step_id}"
sources:
- sourceType: Metrics
condition: $prefix(mssql.jobstep.)
role: default
relationships:
- enabled: true
sources:
- sourceType: Metrics
condition: $prefix(mssql.job.)
- sourceType: Metrics
condition: $prefix(mssql.jobstep.)
fromType: foo-extension:jobstep
typeOfRelation: CHILD_OF
toType: foo-extension:job
- enabled: true
sources:
- sourceType: Metrics
condition: $prefix(mssql.job.)
- sourceType: Metrics
condition: $prefix(mssql.jobstep.)
fromType: foo-extension:job
typeOfRelation: RUNS_ON
toType: foo-extension:host
What can I do to be able to specify a dt.entity.host other than the one the extension is running on? Am I missing some information or is this simply not possible with the use of a OneAgent and I should use an ActiveGate instead?
Any help on the matter is greatly appreciated!
