15 Apr 2025 12:35 AM
How can I tie prometheus extension metrics to a host entity? I have looked at tons of examples and cant seem to figure this out.
The goal is to display the collected metrics on a specific host's unified analysis screen. The chart gets displayed but it is filtered for the host so it doesn't show any metrics.
I am in the beginning stages of figuring this out so any help is greatly appreciated!
Example of yaml -
name: custom:promethius.genai.extension
version: 0.0.13
minDynatraceVersion: "1.307.0"
author:
name: JR
prometheus:
- group: metrics
metrics:
- key: go_gc_cycles_automatic_gc_cycles_total.count
value: metric:go_gc_cycles_automatic_gc_cycles_total
type: count
metrics:
- key: go_gc_cycles_automatic_gc_cycles_total.count
metadata:
displayName: Go Gc Cycles Automatic Gc Cycles Total
description: Count of completed GC cycles generated by the Go runtime.
unit: Unspecified
screens:
- entityType: HOST
detailsInjections:
- type: CHART_GROUP
key: genai_metrics
conditions:
- entityAttribute|detectedName=hostname.domain.com
chartsCards:
- key: genai_metrics
mode: NORMAL
displayName: Metrics Scraped from hostname:port/metrics
numberOfVisibleCharts: 1
charts:
- displayName: GO GC Metrics
visualizationType: GRAPH_CHART
graphChartConfig:
metrics:
- metricSelector: go_gc_cycles_automatic_gc_cycles_total.count
Solved! Go to Solution.
23 Apr 2025 04:08 PM
This line looks odd to me:
- entityAttribute|detectedName=hostname.domain.com
There shouldn't be any reason to include conditions for a hardcoded name. If you want to ensure that this card is only displayed on hosts with data there are better conditions e.g this one to filter to only hosts that had this metric.
- metricAvailable|metric=go_gc_cycles_automatic_gc_cycles_total.count:filter(in("dt.entity.host", entitySelector("entityId($(entityId))")))|lastWrittenWithinDays=5
Assuming you're doing the 'local' activation (i.e. running from the OA host not an ActiveGate) the host dimensions are added automatically which is what 'ties' them to a host. You shouldn't need to do anything else.
Do you see this (with the Host entity as a populated dimension) in the Data Explorer? If that is there it should satisfy the requirements to be displayed.