Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/INTEGRATING_AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ Before AC can create a sub-agent, it must resolve the agent type referenced in y

Only definitions that target the environment of the running binary are considered: the on-host binary only sees `host` definitions matching its operating system, and the Kubernetes binary only sees `kubernetes` definitions (see [Agent Type Metadata](#agent-type-metadata)). A definition that targets a different platform is treated as not found, so the lookup falls through to the next source.

This precedence is what makes the custom directory useful for development: you can add a brand-new agent type, or iterate on and override an existing one, simply by dropping a file there — without rebuilding AC or editing the embedded registry — while still falling back to the built-in and remote sources for everything else. For a step-by-step walkthrough of adding a custom on-host agent type, see the [development guide in the agent type overview](../agent-control/src/agent_type/README.md#development).
This precedence is what makes the custom directory useful for development: you can add a brand-new agent type, or iterate on and override an existing one, simply by dropping a file there — without rebuilding AC or editing the embedded registry — while still falling back to the built-in and remote sources for everything else. For a step-by-step walkthrough of adding a custom on-host agent type, see the [development guide in the agent type overview](./agent_type.md#development-custom-agent-types).

## Applying configurations

Expand Down
61 changes: 60 additions & 1 deletion agent-control/src/agent_type/README.md → docs/agent_type.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,17 @@ deployment:
initial_delay: 10s # Defaults to 30s.
```

## Development
## Development Custom agent types

Agent Control ships a set of embedded agent types (see
[`agent-control/agent-type-registry/newrelic/`](../agent-control/agent-type-registry/newrelic)). You can add your own —
or override an embedded one — by placing the definition YAML in the *dynamic agent types* directory. Custom definitions
take precedence over embedded ones with the same id.
Comment on lines +392 to +395

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Agent Control ships a set of embedded agent types (see
[`agent-control/agent-type-registry/newrelic/`](../agent-control/agent-type-registry/newrelic)). You can add your own —
or override an embedded one — by placing the definition YAML in the *dynamic agent types* directory. Custom definitions
take precedence over embedded ones with the same id.
Agent Control ships a set of embedded agent types (see
[`agent-control/agent-type-registry/newrelic/`](../agent-control/agent-type-registry/newrelic)). You can add your own —
or override an embedded one — by placing the definition YAML in the *dynamic agent types* directory. Custom definitions
take precedence over any other definition with the same id (namespace + name + version).

Should we already consider that this would also override the remote ones?


The current layout expects **a directory** at `/etc/newrelic-agent-control/dynamic-agent-types/` containing one file per
agent type.

### On-host

This guideline shows how to build a custom agent type and integrate it with the agent control on-host. The [telegraf agent](https://www.influxdata.com/time-series-platform/telegraf/) is used as a reference.

Expand Down Expand Up @@ -460,3 +470,52 @@ This guideline shows how to build a custom agent type and integrate it with the
```

5. Restart Agent Control.

### Kubernetes

In-cluster, the same `/etc/newrelic-agent-control/dynamic-agent-types/` directory is populated by mounting a ConfigMap.
Each ConfigMap key becomes a file inside the directory, so a single ConfigMap can carry multiple agent types.

1. Create the ConfigMap in the namespace where Agent Control runs. The `--from-file=<key>=<path>` form names each
entry; that `<key>` is the file name that will appear under the mount:

```sh
kubectl create configmap dynamic-agent \
--from-file=dynamic-agent-type=./agent-control/agent-type-registry/newrelic/kubernetes-com.newrelic.infrastructure-0.1.0.yaml \
-n newrelic-agent-control
```

For multiple types, append more `--from-file=<key>=<path>` — one per file.

2. Mount that ConfigMap on the Agent Control pod through the deployment chart values, matching the layout used in the
dynamic-agent-type k8s e2e ([`test/k8s-e2e/dynamic/ac-values-dynamic.yml`](../test/k8s-e2e/dynamic/ac-values-dynamic.yml)):

```yaml
agentControlDeployment:
chartValues:
# [...]
extraVolumeMounts:
- name: dynamic
mountPath: /etc/newrelic-agent-control/dynamic-agent-types
readOnly: true
extraVolumes:
- name: dynamic
configMap:
name: dynamic-agent
```

3. Reference the type by its id in the AC config and supply variable values through `agentsConfig`. Each key under an
agent's `agentsConfig` entry maps to a variable declared by the type:

```yaml
agentControlDeployment:
chartValues:
config:
agents:
infra:
agent_type: "newrelic/com.newrelic.infrastructure:0.1.0"
# [...]
```

To pick up a fresh ConfigMap, `helm upgrade` (or restart the AC pod).

Loading