01 Mar 2023
	
		
		07:52 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 - last edited on 
    
	
		
		
		17 May 2023
	
		
		02:15 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 by 
				
		 Michal_Gebacki
		
			Michal_Gebacki
		
		
		
		
		
		
		
		
	
			
		
Hi,
Is it possible to add a graph card to the OOTB host Screen?
I have an extension that gets some additional metrics for some hosts, I want to add a chart to the OOTB host monitoring view.
How do I achieve this?
The "entityType: host" does not exist.
Extension:
name: custom:dt.extension.prometheus-nc-alertmanager version: 0.0.8 minDynatraceVersion: "1.225" author: name: Telenet BVBA #dashboards: # - path: "dashboards/checkmk_network_devices.json" metrics: - key: com.dynatrace.extension.prometheus-nc-alertmanager.alert_state metadata: displayName: tn_nc_alertmanager_alert_state description: tn_nc_alertmanager_alert_state unit: Count prometheus: - group: nc_alertmanager metrics interval: 2m featureSet: all subgroups: - subgroup: nc_alertmanager_alert_state dimensions: - key: host value: label:host - key: event value: label:event - key: env value: label:env - key: severity value: label:severity - key: impact value: label:impact - key: description value: label:description - key: support_team value: label:support metrics: - key: com.dynatrace.extension.prometheus-nc-alertmanager.alert_state value: metric:NC_Alertmanager type: gauge featureSet: global topology: types: - name: custom:dt_extension_prometheus_nc_alertmanager_host displayName: nc_alertmanager Host enabled: true rules: - idPattern: nc_alertmanager_{host} sources: - sourceType: Metrics condition: $prefix(com.dynatrace.extension.prometheus-nc-alertmanager.alert_state) attributes: - pattern: '{host}' key: nc_alertmanager_host displayName: nc_alertmanager_host - pattern: '{support_team}' key: support_team displayName: support_team requiredDimensions: [] instanceNamePattern: '{host}' relationships: - sources: - sourceType: Metrics condition: "$prefix(com.dynatrace.extension.prometheus-nc-alertmanager.alert_state)" fromType: "custom:dt_extension_prometheus_nc_alertmanager_host" toType: "host" typeOfRelation: "PART_OF" screens: - entityType: host chartsCards: - key: "host-ncalertmanager-alerts" displayName: "Generic Host Metrics" numberOfVisibleCharts: 1 charts: - displayName: "NC Alertmanager alerts" visualization: themeColor: BLUE seriesType: AREA metrics: - metricSelector: "com.dynatrace.extension.prometheus-nc-alertmanager.alert_state:SplitBy(description)"
Solved! Go to Solution.
01 Mar 2023 08:17 AM
Hi,
Yes, it is possible. To see how it is done you can have a look at one of the existing extensions which do it such as the f5 or the Elasticsearch one. 
You can download any extension framework 2.0 extension from the versions tab of the public hub, such as this one: https://www.dynatrace.com/hub/detail/f5-big-ip-ltm-1/
Mike
01 Mar 2023 09:47 AM
If I follow the example from F5 I get errors:
Extension validation error\",\"constraintViolations\":[{\"path\":\"$.screens[0].chartsCards[0].charts[0]\",\"message\":\"$.screens[0].chartsCards[0].charts[0].graphChartConfig: is not defined in the schema and the schema does not allow additional properties
Seems like our cluster still follows the old schema, like in the documentation.
Frow which DT cluster version is the new schema (as used in F5) supported for custom extensions?
01 Mar 2023 10:20 AM
The minimum dynatrace version is always in the top of the YAML. You can try to download an older version from the hub tile which fits with your cluster. The injection has been part of the f5 extension for some time.
01 Mar 2023 10:47 AM
Then there is an issue with the Schema validation, when uploading a custom extension.
Will log a case.
24 Mar 2023 10:52 AM
Im still struggling getting it working.
The latest schemas work, but its hard to debug.
UseCase: I want metric "com.dynatrace.extension.prometheus-nc-alertmanager.alert_state" to be available on the host screen.
As I understand from the F5 extension, the way to do this, is to relate the custom created entity to the Onagent host entity in the Topology section. Then in the Screen section call this relationship "isSameAs".
In the F5 example mapping is only done on ip_addresses, can this also be done on dt.entity.host?
As in my use case I only have attribute nc_alertmanager_host=dt.entity.host
An example of a extension, linking a metric to dt.entity.host and showing this in the host screen would be helpfull.
The provided examples are great, but hard to reverse engineer.
name: custom:dt.extension.prometheus-nc-alertmanager
version: 0.0.15
minDynatraceVersion: "1.259"
author:
  name: xxx
#dashboards:
#  - path: "dashboards/checkmk_network_devices.json"
metrics:
  - key: com.dynatrace.extension.prometheus-nc-alertmanager.alert_state
    metadata:
      displayName: tn_nc_alertmanager_alert_state
      description: tn_nc_alertmanager_alert_state
      unit: Count
prometheus:
  - group: nc_alertmanager metrics
    interval:
      minutes: 2
    featureSet: all
    subgroups:
      - subgroup: nc_alertmanager_alert_state
        dimensions:
          - key: host
            value: label:host
          - key: event
            value: label:event
          - key: env
            value: label:env
          - key: severity
            value: label:severity
          - key: impact
            value: label:impact
          - key: description
            value: label:description
          - key: support_team
            value: label:support
        metrics:
          - key: com.dynatrace.extension.prometheus-nc-alertmanager.alert_state
            value: metric:NC_Alertmanager
            type: gauge
            featureSet: global
topology:
  types:
    - name: custom:dt_extension_prometheus_nc_alertmanager_host
      displayName: nc_alertmanager Host
      enabled: true
      rules:
      - idPattern: nc_alertmanager_{host}
        sources:
        - sourceType: Metrics
          condition: $prefix(com.dynatrace.extension.prometheus-nc-alertmanager.alert_state)
        attributes:
        - pattern: '{host}'
          key: nc_alertmanager_host
          displayName: nc_alertmanager_host
        - pattern: '{support_team}'
          key: support_team
          displayName: support_team
        requiredDimensions: []
        instanceNamePattern: '{host}'
  relationships:
    - sources:
        - sourceType: Metrics
          condition: $prefix(com.dynatrace.extension.prometheus-nc-alertmanager.alert_state)
      fromType: "custom:dt_extension_prometheus_nc_alertmanager_host"
      toType: host
      typeOfRelation: SAME_AS
    - sources:
        - sourceType: Entities
          mappingRules:
            - sourceProperty: nc_alertmanager_host
              sourceTransformation: To lower case
              destinationProperty: dt.entity.host
              destinationTransformation: To lower case
      fromType: custom:dt_extension_prometheus_nc_alertmanager_host
      typeOfRelation: SAME_AS
      toType: host
screens:
  - entityType: HOST
    detailsInjections:
      - type: CHART_GROUP
        key: host-ncalertmanager-alerts
        conditions:
          - relatedEntity|entitySelectorTemplate=type(custom:dt_extension_prometheus_nc_alertmanager_host),fromRelationships.isSameAs($(entityConditions))
    chartsCards:
      - key: "host-ncalertmanager-alerts"
        displayName: "NC Alertmanager Alerts"
        numberOfVisibleCharts: 1
        charts:
          - displayName: "NC Alertmanager alerts"
            visualizationType: GRAPH_CHART
            graphChartConfig:
              stacked: false
              metrics:
                - metricSelector: "com.dynatrace.extension.prometheus-nc-alertmanager.alert_state:SplitBy(description)"
                  visualization:
                    displayName: Status
The Graph_chart is added to the host screen, the metric is just not related.
Please help.
24 Mar 2023 11:44 AM
If the metric line has dt.entity.host=HOST-ABCD1234... then you don't need to do any same-as relationships. You can simply add the metric selector to get to the metric into the injected card. You can try the metric selector in the data explorer.
24 Mar 2023 12:23 PM
No the metric does not have the dt.entity.host key, which makes me realize that the relationship should be something like:
- sources: - sourceType: Entities mappingRules: - sourceProperty: nc_alertmanager_host sourceTransformation: To lower case destinationProperty: displayName destinationTransformation: To lower case fromType: custom:dt_extension_prometheus_nc_alertmanager_host typeOfRelation: SAME_AS toType: host
So the link is on hostname not host ID.
I pushed these changes, but same results.
24 Mar 2023 12:25 PM
I think this might need a zoom call with someone on the extensions team to go through it step by step to see where it breaks. You can get redirected to that team via the in-product chat.
31 Mar 2023 12:34 PM
I fixed it like this:
topology:
  types:
    - name: custom:dt_extension_prometheus_nc_alertmanager_host
      displayName: nc_alertmanager Host
      enabled: true
      rules:
      - idPattern: nc_alertmanager_{host}
        sources:
        - sourceType: Metrics
          condition: $prefix(com.dynatrace.extension.prometheus-nc-alertmanager.alert_state)
        attributes:
        - pattern: "{host}"
          key: nc_alertmanager_host
          displayName: nc_alertmanager_host
        - pattern: "{support_team}"
          key: support_team
          displayName: support_team
        requiredDimensions: []
        instanceNamePattern: "{host}"
  relationships:
    - sources:
        - sourceType: Entities
          mappingRules:
            - sourceProperty: nc_alertmanager_host
              sourceTransformation: To lower case
              destinationProperty: displayName
              destinationTransformation: To lower case
      fromType: custom:dt_extension_prometheus_nc_alertmanager_host
      typeOfRelation: SAME_AS
      toType: host
screens:
  - entityType: HOST
    detailsInjections:
      - type: CHART_GROUP
        key: host-ncalertmanager-alerts
        conditions:
          - relatedEntity|entitySelectorTemplate=type(custom:dt_extension_prometheus_nc_alertmanager_host),fromRelationships.isSameAs($(entityConditions))
    chartsCards:
      - key: "host-ncalertmanager-alerts"
        displayName: "NC Alertmanager Alerts"
        numberOfVisibleCharts: 1
        charts:
          - displayName: "NC Alertmanager alerts"
            visualizationType: GRAPH_CHART
            graphChartConfig:
              stacked: false
              metrics:
                - metricSelector: "com.dynatrace.extension.prometheus-nc-alertmanager.alert_state:filter(in(\"dt.entity.custom:dt_extension_prometheus_nc_alertmanager_host\",entitySelector(\"type(custom:dt_extension_prometheus_nc_alertmanager_host),fromRelationships.isSameAs($(entityConditions))\"))):splitBy(\"description\")"
                  visualization:
                    displayName: Status
Result:
To check if your entities are linked, you need too querry the API /api/v2/entities/CUSTOM_DEVICE-******
And then you should see something like:
"fromRelationships": {
    "isSameAs": [
    {
      "id": "HOST-*****",
      "type": "HOST"
    }
    ]
}
