# newrelic/infrastructure-agent architecture

> Architecture diagram of the GitHub repository newrelic/infrastructure-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/newrelic/infrastructure-agent
- Repository: https://github.com/newrelic/infrastructure-agent

## Overview

New Relic Infrastructure Agent collects host metrics and inventory, runs integrations, and sends telemetry to the New Relic platform. The principal workflow is agent startup and configuration, host and integration data collection, then backend delivery; identity connection and remote command handling are supporting runtime stages. The README documents the product workflow and capabilities; sampled excerpts and the SOURCE INDEX support only some internal links, so unverified runtime relationships are dashed rather than asserted.

Main entry points: [`internal/agent/agent.go`](https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/agent.go) (Agent services), [`cmd/newrelic-infra/newrelic-infra.go`](https://github.com/newrelic/infrastructure-agent/blob/master/cmd/newrelic-infra/newrelic-infra.go) (Agent entry), [`pkg/integrations/v4/manager.go`](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/integrations/v4/manager.go) (Integration manager), [`pkg/plugins/plugins.go`](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/plugins/plugins.go) (Host inventory plugins)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Agent runtime"]
  node_main["Agent entry<br/>[newrelic-infra.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_agent["Agent services<br/>[agent.go]"]
  node_httpapi["Local HTTP API<br/>[httpapi.go]"]
  node_cmdchannel["Command channel<br/>[cmdchannel.go]"]
end

subgraph group_collection["Host collection"]
  node_hostmetrics["Host metrics<br/>[system_sampler.go]"]
  node_storage["Storage metrics<br/>[storage_sampler.go]"]
  node_process["Process metrics<br/>[process.go]"]
  node_hostplugins["Host inventory plugins<br/>[plugins.go]"]
  node_winservices["Windows services<br/>[services.go]"]
  node_inventory["Inventory handler<br/>[handler.go]"]
end

subgraph group_integrations["Integrations"]
  node_integrationmanager["Integration manager<br/>[manager.go]"]
  node_runner["Integration runner<br/>[runner.go]"]
  node_configrequest["Config requests<br/>[handler.go]"]
end

subgraph group_backend["Backend communication"]
  node_connect["Identity connect<br/>[connect_service.go]"]
  node_identityapi["Identity client<br/>[connect_client.go]"]
  node_telemetry["Telemetry API<br/>[harvester.go]"]
  node_ingest["Inventory ingest<br/>[ingestapi.go]"]
end

node_operator(("Operator"))
node_platform(("New Relic platform"))

node_operator -->|"starts agent"| node_main
node_main -.->|"loads settings"| node_config
node_main -.->|"starts runtime"| node_agent
node_main -.->|"starts integrations"| node_integrationmanager
node_main -.->|"exposes API"| node_httpapi
node_agent -.->|"connects identity"| node_connect
node_connect -->|"requests identity"| node_identityapi
node_identityapi -.->|"exchanges identity"| node_platform
node_agent -.->|"collects metrics"| node_hostmetrics
node_agent -.->|"samples storage"| node_storage
node_agent -.->|"samples processes"| node_process
node_agent -.->|"collects inventory"| node_hostplugins
node_hostplugins -.->|"includes services"| node_winservices
node_agent -.->|"handles inventory"| node_inventory
node_inventory -->|"posts deltas"| node_ingest
node_integrationmanager -->|"runs definitions"| node_runner
node_configrequest -.->|"updates definitions"| node_integrationmanager
node_integrationmanager -.->|"handles requests"| node_configrequest
node_agent -.->|"handles commands"| node_cmdchannel
node_telemetry -.->|"sends telemetry"| node_platform
node_ingest -.->|"sends inventory"| node_platform

click node_main "https://github.com/newrelic/infrastructure-agent/blob/master/cmd/newrelic-infra/newrelic-infra.go"
click node_config "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/config/config.go"
click node_agent "https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/agent.go"
click node_httpapi "https://github.com/newrelic/infrastructure-agent/blob/master/internal/httpapi/httpapi.go"
click node_cmdchannel "https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/cmdchannel/cmdchannel.go"
click node_connect "https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/connect_service.go"
click node_identityapi "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/backend/identityapi/connect_client.go"
click node_hostmetrics "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/metrics/system_sampler.go"
click node_storage "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/metrics/storage/storage_sampler.go"
click node_process "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/metrics/process/process.go"
click node_hostplugins "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/plugins/plugins.go"
click node_winservices "https://github.com/newrelic/infrastructure-agent/blob/master/internal/plugins/windows/services.go"
click node_inventory "https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/inventory/handler.go"
click node_integrationmanager "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/integrations/v4/manager.go"
click node_runner "https://github.com/newrelic/infrastructure-agent/blob/master/internal/integrations/v4/runner/runner.go"
click node_configrequest "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/integrations/configrequest/handler.go"
click node_telemetry "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/backend/telemetryapi/harvester.go"
click node_ingest "https://github.com/newrelic/infrastructure-agent/blob/master/pkg/backend/inventoryapi/ingestapi.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_config,node_agent,node_httpapi,node_cmdchannel toneBlue
class node_hostmetrics,node_storage,node_process,node_hostplugins,node_winservices,node_inventory toneAmber
class node_integrationmanager,node_runner,node_configrequest toneMint
class node_connect,node_identityapi,node_telemetry,node_ingest toneRose
class node_operator,node_platform toneIndigo
```

## Components

### Agent runtime

- [Agent entry](https://github.com/newrelic/infrastructure-agent/blob/master/cmd/newrelic-infra/newrelic-infra.go): `cmd/newrelic-infra/newrelic-infra.go`
- [Configuration](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/config/config.go): `pkg/config/config.go`
- [Agent services](https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/agent.go): `internal/agent/agent.go`
- [Local HTTP API](https://github.com/newrelic/infrastructure-agent/blob/master/internal/httpapi/httpapi.go): `internal/httpapi/httpapi.go`
- [Command channel](https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/cmdchannel/cmdchannel.go): `internal/agent/cmdchannel/cmdchannel.go`

### Host collection

- [Host metrics](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/metrics/system_sampler.go): `pkg/metrics/system_sampler.go`
- [Storage metrics](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/metrics/storage/storage_sampler.go): `pkg/metrics/storage/storage_sampler.go`
- [Process metrics](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/metrics/process/process.go): `pkg/metrics/process/process.go`
- [Host inventory plugins](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/plugins/plugins.go): `pkg/plugins/plugins.go`
- [Windows services](https://github.com/newrelic/infrastructure-agent/blob/master/internal/plugins/windows/services.go): `internal/plugins/windows/services.go`
- [Inventory handler](https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/inventory/handler.go): `internal/agent/inventory/handler.go`

### Integrations

- [Integration manager](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/integrations/v4/manager.go): `pkg/integrations/v4/manager.go`
- [Integration runner](https://github.com/newrelic/infrastructure-agent/blob/master/internal/integrations/v4/runner/runner.go): `internal/integrations/v4/runner/runner.go`
- [Config requests](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/integrations/configrequest/handler.go): `pkg/integrations/configrequest/handler.go`

### Backend communication

- [Identity connect](https://github.com/newrelic/infrastructure-agent/blob/master/internal/agent/connect_service.go): `internal/agent/connect_service.go`
- [Identity client](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/backend/identityapi/connect_client.go): `pkg/backend/identityapi/connect_client.go`
- [Telemetry API](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/backend/telemetryapi/harvester.go): `pkg/backend/telemetryapi/harvester.go`
- [Inventory ingest](https://github.com/newrelic/infrastructure-agent/blob/master/pkg/backend/inventoryapi/ingestapi.go): `pkg/backend/inventoryapi/ingestapi.go`

### Other components

- **Operator**
- **New Relic platform**

## Connections

- Operator → Agent entry: starts agent
- Agent entry → Configuration: loads settings
- Agent entry → Agent services: starts runtime
- Agent entry → Integration manager: starts integrations
- Agent entry → Local HTTP API: exposes API
- Agent services → Identity connect: connects identity
- Identity connect → Identity client: requests identity (evidence: `internal/agent/connect_service.go`)
- Identity client → New Relic platform: exchanges identity
- Agent services → Host metrics: collects metrics
- Agent services → Storage metrics: samples storage
- Agent services → Process metrics: samples processes
- Agent services → Host inventory plugins: collects inventory
- Host inventory plugins → Windows services: includes services
- Agent services → Inventory handler: handles inventory
- Inventory handler → Inventory ingest: posts deltas (evidence: `internal/agent/inventory/handler.go`)
- Integration manager → Integration runner: runs definitions (evidence: `pkg/integrations/v4/manager.go`)
- Config requests → Integration manager: updates definitions
- Integration manager → Config requests: handles requests
- Agent services → Command channel: handles commands
- Telemetry API → New Relic platform: sends telemetry
- Inventory ingest → New Relic platform: sends inventory
