newrelic / infra-integrations-sdk

New Relic Infrastructure Integrations SDK
Apache License 2.0
44 stars 23 forks source link

Field to prevent metrics/events to be attached to the host entity #283

Closed rogercoll closed 2 years ago

rogercoll commented 2 years ago

Problem

The agent has a binary behaviour regarding the metrics from an integration, whether attach them all to the host entity or any (FlagDMRegisterEnable = "dm_register_enabled”). Most of the integrations should be fine without attaching the host entity as the backend perform the entity synthesis but if in the near future we want to decouple core integrations (cpu, mem, etc), the agent should be able to differentiate them.

Feature Description

Add a field to each entity data to let know the agent whether to add the host entity or not. For example, ignore_host_entity defaulting to false:

{
  "protocol_version":"4",                      # protocol version number
  "integration":{                              # this data will be added to all metrics and events as attributes,                                               
                                               # and also sent as inventory
    "name":"integration name",
    "version":"integration version"
  },
  "data":[                                    # List of objects containing entities, metrics, events and inventory
    {
      "ignore_host_entity": true                # don't attach metrics to the host entity
      "metrics":[                             # list of metrics using the dimensional metric format
        {
          "name":"redis.metric1",
          "type":"count",                     # gauge, count, summary, cumulative-count, rate or cumulative-rate
          "value":93, 
          "attributes":{}                     # set of key-value pairs that define the dimensions of the metric
        }
      ],
      "common":{...}                          # Map of dimensions common to every entity metric. Only string supported.
      "inventory":{...},                      # Inventory remains the same
      "events":[...]                          # Events remain the same
    }
  ]
}

Additional context

https://github.com/newrelic/infrastructure-agent/issues/865

gsanchezgavier commented 2 years ago

An important point to take into account mentioned by @roobre is to keep decorating the metrics (not attached to any entity) with the Host metadata taking into account that some of this metadata is decorated in the backend.

davidgit commented 2 years ago

We could not use FlagDMRegisterEnable because the WindowsServices integration would stop working