Python Topology
Smartscape topology โ entities created from your extension
Topology works the same as SNMP โ define entity types in extension.yaml. The difference: dimensions come from your report_metric() calls, not OIDs.
topology:
types:
- name: my-api:endpoint
displayName: API Endpoint
rules:
- idPattern: my-api_{endpoint}
instanceNamePattern: "{endpoint}"
iconPattern: api
sources:
- sourceType: Metrics
condition: $prefix(com.dynatrace.extension.my-api)
attributes:
- key: url
displayName: URL
pattern: "{endpoint}"
Reporting Dimensions for Topology
def query(self):
endpoints = ["/api/users", "/api/orders", "/api/health"]
for endpoint in endpoints:
response = requests.get(f"{self.base_url}{endpoint}", timeout=10)
# These dimensions feed the topology idPattern
self.report_metric(
key="com.dynatrace.extension.my-api.response_time",
value=response.elapsed.total_seconds() * 1000,
dimensions={"endpoint": endpoint} # โ creates entity per endpoint
)
โ ๏ธ Dimension keys in report_metric() must exactly match the {placeholder} names in your topology idPattern. Mismatches = no entities.
๐ Try it: After deploying your Python extension, open Smartscape โ look for your custom entity types. Then run fetch dt.entity.YOUR_TYPE | fields entity.name, tags | limit 10 to verify topology creation.