cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to report Event in extensions: report_dt_event()

guptasahil942
Participant

I have an entity custom:host  , which is mapped to Host entity so that data can be displayed on OOTB Host screen .

I am unable to report the event using below code for self.report_dt_event()

host_entity_id = data['dt.entity.host']
 
self.report_dt_event(description="One or more processes are unavailable", title="Test Host Unhealthy", entity_selector= f"type(test:host),entityID(\"{host_entity_id}\")")
 
types:
    - name: test:host
      displayName: Test Host
      rules:
        - idPattern: Test_host_{host}
          instanceNamePattern: "{host}"
          iconPattern: host
          attributes:
            - key: test_host
              displayName: Test_Host
              pattern: "{host}"
            - key: test_host_id
              displayName: Test_Host_ID
              pattern: "{host_id}"
          sources:
            - sourceType: Metrics
              condition: $prefix(test.)
relationships:
    - sources:
      - sourceType: Metrics
        condition: $prefix(test.)
      fromType: test:host
      toType: host
      typeOfRelation: SAME_AS
    - sources:
        - sourceType: Entities
          mappingRules:
            - sourceProperty: test_host_id
              sourceTransformation: To lower case
              destinationProperty: entityId
              destinationTransformation: To lower case
            - sourceProperty: test_host
              sourceTransformation: To lower case
              destinationProperty: displayName
              destinationTransformation: To lower case
      fromType: test:host
      typeOfRelation: SAME_AS
      toType: host
 
Also, for an event, do we need to make an entry in extension.yaml too ?
1 REPLY 1

JamesKitson
Dynatrace Guru
Dynatrace Guru

I can't tell everything from your post, but it seems like you're trying to use the entity ID of the built-in host entity type as a filter on your custom host entity in the selector which will not work. Having a 'same as' relationship won't allow you to automatically be able to use the attributes of that other entity. For attributes only the attributes on your custom entity would be available.

You can use relationships as filters in entity selectors too so if you have the relationship working and showing up properly you could use that: https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-api/environment-api/entity-v...

Lastly, if this is a local activation of an extension running on a OneAgent monitored host there shouldn't be any need for this extra entity type. You'd be able to report all this directly to the OA monitored host. We only do something like this for remote activations of extension.

 

Featured Posts