How can I assosiate some metrics collected by WMI extension with a process?

We have a custom WMI extension working, just have a simple question:

Generally, metrics in Dynatrace can be associated with hosts, processes, or more by assigning values to Dynatrace reserved dimensions, as described in the doc of the metrics ingestion protocol: Metric ingestion protocol — Dynatrace Docs

Now, metrics collected using the WMI extension seem to be associated with the host by default. We wish to associate some metrics with a process. This is not documented in the docs for WMI: WMI data source tutorial — Dynatrace Docs.

How can we create this topology?

You’ve got a couple of options here. These are the two easiest ones as they are programmatic.

1: If you can get the process ID through a call, you can add that as a dimension. It’d then be translated to the process instance id and process group id.

For example, this metric line:

<span>myMetric </span><span>dt.process.id=12345 1</span>

would become

<span>myMetric dt.entity.process_group_instance=PROCESS_GROUP_INSTANCE-D337020E5CAE4F0F,dt.entity.process_group=PROCESS_GROUP-D337020E5CAE4F0D 1</span>

Example yaml:

wmi:
  - group: WMIClasses
    interval: 10~
    featureSet: basic
    subgroups:
      - subgroup: ZoomCamera
        wmiNamespace: root\cimv2
        query: SELECT Name, Status, PID FROM Win32_PnPEntity WHERE PNPClass='Camera'
        dimensions:
          - key: camera.name
            value: Name
          - key: camera.status
            value: Status
          - key: dt.process.id
            value: PID

2: If you can define the process detection rule in the same yaml, you can reference that in the wmi section to automatically add the process instance id and process group id.

For example:

processes:
  - name: ZoomTech
    detection:
      - id: zoomtech
        processGroupName: Zoom
        rules:
        - property: executable
          condition: "$prefix(Zoom)"
wmi:
  - group: WMIClasses
    interval: 10~
    featureSet: basic
    subgroups:
      - subgroup: ZoomCamera
        wmiNamespace: root\cimv2
        query: SELECT Name, Status FROM Win32_PnPEntity WHERE PNPClass='Camera'
        dimensions:
          - key: camera.name
            value: Name
          - key: camera.status
            value: Status
          - key: dt.techrule.id
            value: const:zoomtech