You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: agent-control/src/agent_type/README.md
+88-94Lines changed: 88 additions & 94 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Agent Type Definition is a YAML file that defines an agent's configuration and behavior. It consists of three main sections: metadata, deployment, and variables.
4
4
5
-
By defining these three sections, developers can create a customizable and flexible agent type that can be used in various environments.
5
+
By defining these three sections, developers can create a customizable and flexible agent type that can be used in various environments.
6
6
7
7
## Metadata
8
8
@@ -15,31 +15,30 @@ version: 0.0.1
15
15
```
16
16
17
17
The metadata fields can't be empty:
18
+
18
19
* The name and namespace should:
19
-
- Start by an alphabetical character.
20
-
- Only encompass `alphanumeric characters`, `.`, `_` or `-`.
21
-
-Be in lowercase.
20
+
* Start by an alphabetical character.
21
+
* Only encompass `alphanumeric characters`, `.`, `_` or `-`.
22
+
* Be in lowercase.
22
23
* The version field should adhere to [semantic versioning](https://semver.org/).
23
24
24
25
## Variables
25
26
26
-
The variables section allows developers to define variables that end users can set. These variables can adjust the agent's or system's configuration.
27
+
The `variables` section allows developers to define variables that end users can set. These variables can adjust the agent's or system's configuration.
27
28
28
29
```yaml
29
30
variables:
30
31
common:
31
32
config_agent:
32
33
description: "Newrelic infra configuration"
33
-
type: file
34
+
type: yaml
34
35
required: false
35
-
default: ""
36
-
file_path: "newrelic-infra.yml"
36
+
default: {}
37
37
config_integrations:
38
38
description: "map of YAML configs for the OHIs"
39
-
type: map[string]file
39
+
type: map[string]yaml
40
40
required: false
41
41
default: {}
42
-
file_path: "integrations.d"
43
42
on_host:
44
43
backoff_delay:
45
44
description: "seconds until next retry if agent fails to start"
@@ -57,6 +56,7 @@ variables:
57
56
```
58
57
59
58
Variables can be classified based on their applicable environments:
59
+
60
60
* `on_host`: Refers to variables utilized in on host environments.
61
61
* `k8s`: Applies to variables used within Kubernetes clusters.
62
62
* `common`: For variables that are environment-agnostic.
@@ -78,30 +78,24 @@ common:
78
78
79
79
All variables have a few common attributes:
80
80
81
-
* `description`: A brief description of the variable.This is useful for documentation purposes and can help others understand the purpose of the variable.
82
-
* `type`: The data type of the variable. We support several data types, including `string`, `file`, `bool`, `yaml`, and more.
81
+
* `description`: A brief description of the variable.This is useful for documentation purposes and can help others understand the purpose of the variable.
82
+
* `type`: The data type of the variable. We support several data types, including `string`, `file`, `bool`, `yaml`, and more.
83
83
* `variants`: Represents a defined list of acceptable values for the variable. Only values present in the variants list are considered valid.
84
84
* `default`: The default value for the variable if no value is provided.
85
85
* `required`: Whether the variable is mandatory to be provided or not.
86
86
87
-
Moreover, file type variables possess an additional attribute:
88
-
* `file_path`: Indicates where the file(s) is located.
89
-
90
-
In terms of variable types, we currently support the following types listed [here](variable/kind.rs#L14):
87
+
In terms of variable types, we currently support the following types listed in [this source file](./variable/variable_type.rs#L22):
91
88
92
89
* `string`: A string value, such as "Hello, world!"
93
90
* `number`: An numeric value, such as 42 or 0.25
94
91
* `boolean`: A boolean value, which can be either *true* or *false*
95
-
* `file`: It represents a file in the filesystem.
96
92
* `map[string]string`: A dictionary of key-value pairs, associating keys(string) and values(string).
97
-
* `map[string]file`: A dictionary of key-value pairs, associating keys(string) and values(file). Files are stored in the specified folder.
98
93
* `yaml`: The YAML type variable is used to handle multi-line strings that will be parsed as YAML such as Helm Charts values.
99
-
100
-
Note that `file` and `map[string]file` variable types can be used just for `on_host` environments. Files are not supported in Kubernetes.
94
+
* `map[string]yaml`: Handles YAML values that guarantee their top-level fields are strings. Useful for defining file system entries for on-host.
101
95
102
96
## Deployment
103
97
104
-
The deployment section indicates how the agent should be executed and its health should be checked.
98
+
The deployment section indicates how the agent should be executed and how its health should be checked.
105
99
106
100
Note you can reference the variables defined in the `variables` section using `${nr-var:variable_name}`. And this is valid for nested variables as well: following the example above, you would be able to use `${nr-var:log.info}`.
107
101
@@ -123,7 +117,7 @@ multi_line_string: |
123
117
${nr-var:yaml_variable | indent 2 }
124
118
```
125
119
126
-
### OnHost Deployment
120
+
### On Host Deployment
127
121
128
122
For on-host deployment, use the following format:
129
123
@@ -158,7 +152,7 @@ In this section:
158
152
* `health`: The measures used to check the health status of the agent.
159
153
* `version`: The command used to check the version of the binary.
160
154
* `executables`: This outlines the list of binaries the agent supervisor runs. Developers can define:
161
-
- * `id`: Unique identifier for the exec used by the health checker.
155
+
* * `id`: Unique identifier for the exec used by the health checker.
162
156
* `path`: The location of the binary required.
163
157
* `args`: The command-line arguments needed by the binary.
164
158
* `env`: Specifies the required environment variables.
@@ -168,19 +162,19 @@ These diverse options offer extensive customization for your agent's deployment.
168
162
169
163
#### Restart Policy
170
164
171
-
`restart_policy`provides a set of instructions on how and when the agent process should be restarted. It's crucial for maintaining the agent's availability and reliability, particularly in case of unexpected failures or problems.
165
+
`restart_policy`provides a set of instructions on how and when the agent process should be restarted. It's crucial for maintaining the agent's availability and reliability, particularly in case of unexpected failures or problems.
172
166
173
167
In the `backoff_strategy` we have:
174
168
175
-
* `type`: This field can take several forms - _fixed_, _linear_, or _exponential_. It determines the delay timing strategy between retries.
176
-
* _fixed_: Constant delay interval between retries. This is the default type.
177
-
* _linear_: Delay interval increases linearly after each retry.
178
-
* _exponential_: Delay interval doubles after each retry.
179
-
* `backoff_delay`: It defines the duration between retries when a restart is needed. This delay protects against aggressive restarts. Default is _2s_.
180
-
* `max_retries`: This integer value defines the maximum number of retry attempts before exiting the retry mechanism and accepting the failure. Default is _0_.
181
-
* `last_retry_interal`: This is used to store the duration of the last delay. It can especially be relevant in case of _linear_ or _exponential_ backoff strategies where each retry level has a different delay value. Default is _600_.
169
+
* `type`: This field can take several forms - `fixed`, `linear`, or `exponential`. It determines the delay timing strategy between retries.
170
+
* `fixed`: Constant delay interval between retries. This is the default type.
171
+
* `linear`: Delay interval increases linearly after each retry.
172
+
* `exponential`: Delay interval doubles after each retry.
173
+
* `backoff_delay`: It defines the duration between retries when a restart is needed. This delay protects against aggressive restarts. Default is *2s*.
174
+
* `max_retries`: This integer value defines the maximum number of retry attempts before exiting the retry mechanism and accepting the failure. Default is *0*.
175
+
* `last_retry_interal`: This is used to store the duration of the last delay. It can especially be relevant in case of *linear* or *exponential* back-off strategies where each retry level has a different delay value. Default is *600*.
182
176
183
-
#### OnHost Health
177
+
#### On Host Health
184
178
185
179
The `health` section in the deployment configuration is where you can specify how to monitor the health status of the agent. This is critical for maintaining the reliability of your agent and ensuring that it's functioning correctly. Here's how you can define it in the `executables` block:
186
180
@@ -196,10 +190,10 @@ health:
196
190
197
191
In this configuration:
198
192
199
-
* `interval`: This parameter specifies the frequency at which health checks should be performed.
200
-
* `timeout`: This is the maximum time the agent should wait for a health check response.
193
+
* `interval`: This parameter specifies the frequency at which health checks should be performed.
194
+
* `timeout`: This is the maximum time the agent should wait for a health check response.
201
195
* `http`: This section is for when agents expose their status through an HTTP endpoint. If this method is used, the `path` and `port` should be specified.
202
-
* `path`: This is the API endpoint for the health check. Typically it's a URI where the agent returns its current health status.
196
+
* `path`: This is the API endpoint for the health check. Typically, it's a URI where the agent returns its current health status.
203
197
* `port`: This is the port on which the agent's health check endpoint is listening.
204
198
* `healthy_codes`: This is a list of the HTTP codes the SA will consider as valid ones.
205
199
@@ -217,6 +211,7 @@ health:
217
211
healthy_codes: [0]
218
212
unhealthy_string: ".*(unhealthy|fatal|error).*"
219
213
```
214
+
220
215
```yaml
221
216
# ...
222
217
health:
@@ -228,7 +223,7 @@ health:
228
223
unhealthy_string: ".*(unhealthy|fatal|error).*"
229
224
```
230
225
231
-
#### OnHost Version
226
+
#### On Host Version
232
227
233
228
The `version` section in the deployment configuration is where you can specify how to obtain the version of the binary running. Here's how you can define it block:
234
229
@@ -241,11 +236,10 @@ version:
241
236
242
237
In this configuration:
243
238
244
-
* `path`: Specifies the binary to run.
245
-
* `args`: Specifies the arguments passed to the binary to get the version.
239
+
* `path`: Specifies the binary to run.
240
+
* `args`: Specifies the arguments passed to the binary to get the version.
246
241
* `regex`: Optional field that specifies the regular expression to get the version from the output. When not used, the whole output will be used as the version.
247
242
248
-
249
243
### Kubernetes Deployment
250
244
251
245
The Agent Control leverages [Flux](https://fluxcd.io/) to act as an operator running Helm commands (install, upgrade, delete) as needed based on the provided configurations.
@@ -383,65 +377,65 @@ This guideline shows how to build a custom agent type and integrate it with the
383
377
384
378
1. Create a file with the agent type definition
385
379
386
-
```yaml
387
-
# namespace: newrelic, external, other
388
-
namespace: external
389
-
# name: reverse FQDN that uniquely identifies the agent type
390
-
name: com.influxdata.telegraf
391
-
# version: semver scheme
392
-
version: 0.0.1
393
-
394
-
# variables:
395
-
# common | on_host | k8s:
396
-
# my_var_1:
397
-
# description: "Variable description here"
398
-
# type: file | string
399
-
# required: true | false
400
-
# default: "default value"
401
-
# file_path: "persistence path"
402
-
403
-
variables:
404
-
on_host:
405
-
config_file:
406
-
description: "Telegraf config file path"
407
-
type: string
408
-
required: false
409
-
default: "/path/to/telegraf.conf"
410
-
backoff_delay:
411
-
description: "seconds until next retry if agent fails to start"
412
-
type: string
413
-
required: false
414
-
default: 20s
415
-
416
-
deployment:
417
-
on_host:
418
-
executables:
419
-
- id: telegraf
420
-
path: /usr/bin/telegraf
421
-
args: "--config ${nr-var:config_file}"
422
-
env: ""
423
-
restart_policy:
424
-
backoff_strategy:
425
-
type: fixed
426
-
backoff_delay: ${nr-var:backoff_delay}
427
-
```
380
+
```yaml
381
+
# namespace: newrelic, external, other
382
+
namespace: external
383
+
# name: reverse FQDN that uniquely identifies the agent type
384
+
name: com.influxdata.telegraf
385
+
# version: semver scheme
386
+
version: 0.0.1
387
+
388
+
# variables:
389
+
# common | on_host | k8s:
390
+
# my_var_1:
391
+
# description: "Variable description here"
392
+
# type: string
393
+
# required: false
394
+
# default: "default value"
395
+
396
+
variables:
397
+
on_host:
398
+
config_file:
399
+
description: "Telegraf config file path"
400
+
type: string
401
+
required: false
402
+
default: "/path/to/telegraf.conf"
403
+
backoff_delay:
404
+
description: "seconds until next retry if agent fails to start"
405
+
type: string
406
+
required: false
407
+
default: 20s
408
+
409
+
deployment:
410
+
on_host:
411
+
executables:
412
+
- id: telegraf
413
+
path: /usr/bin/telegraf
414
+
args: "--config ${nr-var:config_file}"
415
+
env: ""
416
+
restart_policy:
417
+
backoff_strategy:
418
+
type: fixed
419
+
backoff_delay: ${nr-var:backoff_delay}
420
+
```
428
421
429
422
2. Copy the agent type definition to the folder `/etc/newrelic-agent-control/dynamic-agent-types`
430
-
431
423
3. Use the new type in the `agents` config for the agent control:
4. If any `required` variable has been defined in the type or any default value for variables needs to be customized, then define a `values.yaml` in `/etc/newrelic-agent-control/fleet/agents.d/my-telegraf/values.yaml`:
0 commit comments