Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
namespace: newrelic
name: com.newrelic.opentelemetry.collector
version: 0.1.0
variables:
on_host:
config:
description: "Newrelic otel collector configuration"
type: yaml
required: false
default: {}
backoff_delay:
description: "seconds until next retry if agent fails to start"
type: string
required: false
default: 20s
health_check:
# Note the configs added here must align with the health check extension being used on the collector config variable.
# See https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/healthcheckv2extension/README.md#configuration
# For more details
path:
description: "path to health check endpoint"
type: string
required: false
default: "/health/status" # Taken from example at: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/healthcheckv2extension/README.md#configuration
port:
description: "port to health check endpoint"
type: number
required: false
default: 13133
k8s:
chart_values:
nr-k8s-otel-collector:
description: "Newrelic otel collector chart values"
type: yaml
required: false
default: {}
global:
description: "Global values for the chart"
type: yaml
required: false
default: {}
chart_version:
description: "Newrelic otel collector chart version"
type: string
required: true
chart_name:
description: "nr-k8s-otel-collector chart name"
type: string
required: false
default: "nr-k8s-otel-collector"
chart_repository:
url:
description: "chart repository url"
type: string
required: false
default: "https://helm-charts.newrelic.com"
variants:
ac_config_field: "chart_repository_urls"
values: ["https://helm-charts.newrelic.com"]
secret_reference:
description: "HelmRepository secret reference (secretRef)"
type: yaml
required: false
default: null
certificate_secret_reference:
description: "HelmRepository certificate secret reference (certSecretRef)"
type: yaml
required: false
default: null
deployment:
on_host:
health:
interval: 5s
initial_delay: 5s
timeout: 5s
http:
path: "${nr-var:health_check.path}"
port: ${nr-var:health_check.port}
version:
path: /usr/bin/nrdot-collector-host
args: -v
regex: \d+\.\d+\.\d+
filesystem:
otel-config:
config.yaml: |
${nr-var:config}
executables:
- # Important to note the binary name is nrdot-collector-host matching the new nrdot binary
id: nrdot-collector-host
path: /usr/bin/nrdot-collector-host
args: >-
--config=${nr-sub:autogenerated_agent_dir}/otel-config/config.yaml
--feature-gates=-pkg.translator.prometheus.NormalizeName
env:
# sets the otel-collector "env" source resource detector
OTEL_RESOURCE_ATTRIBUTES: "host.id=${nr-ac:host_id}"
restart_policy:
backoff_strategy:
type: fixed
backoff_delay: ${nr-var:backoff_delay}
# See com.newrelic.infrastructure Agent type for description of fields.
Copy link
Contributor

Choose a reason for hiding this comment

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

I've just noticed this comment, copy&pasted for sure but it is a bit misleading, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the com.newrelic.infrastructure has some descriptions for the fields in comments, so perhaps it makes sense to leave this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, now I get it. Let's leave it for now but it is really strange: we define the description field in the com.newrelic.infrastructure Agent Type (those fields could be actually used!) and here we add a comment asking to check the other Agent Type 🙃

k8s:
health:
interval: 30s
initial_delay: 30s
objects:
repository:
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: ${nr-sub:agent_id}
namespace: ${nr-ac:namespace}
spec:
interval: 30m
provider: generic
url: ${nr-var:chart_repository.url}
secretRef: ${nr-var:chart_repository.secret_reference}
certSecretRef: ${nr-var:chart_repository.certificate_secret_reference}
values:
apiVersion: v1
kind: Secret
metadata:
name: values-${nr-sub:agent_id}
namespace: ${nr-ac:namespace}
stringData:
default.yaml: |
global:
licenseKey: ${nr-env:NR_LICENSE_KEY}
cluster: ${nr-env:NR_CLUSTER_NAME}
nrStaging: ${nr-env:NR_STAGING}
lowDataMode: ${nr-env:NR_LOW_DATA_MODE}
verboseLog: ${nr-env:NR_VERBOSE_LOG}
values.yaml: |
${nr-var:chart_values.nr-k8s-otel-collector}
global.yaml: |
global:
${nr-var:chart_values.global | indent 2}
release:
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: ${nr-sub:agent_id}
namespace: ${nr-ac:namespace}
spec:
targetNamespace: ${nr-ac:namespace_agents}
releaseName: ${nr-sub:agent_id}
interval: 30s
chart:
spec:
chart: ${nr-var:chart_name}
version: ${nr-var:chart_version}
reconcileStrategy: ChartVersion
sourceRef:
kind: HelmRepository
name: ${nr-sub:agent_id}
namespace: ${nr-ac:namespace}
interval: 3m
install:
disableWait: true
disableWaitForJobs: true
disableTakeOwnership: true
createNamespace: true
upgrade:
disableWait: true
disableWaitForJobs: true
disableTakeOwnership: true
cleanupOnFail: true
valuesFrom:
- kind: Secret
name: values-${nr-sub:agent_id}
valuesKey: default.yaml
- kind: Secret
name: values-${nr-sub:agent_id}
valuesKey: values.yaml
- kind: Secret
name: values-${nr-sub:agent_id}
valuesKey: global.yaml
20 changes: 12 additions & 8 deletions agent-control/src/agent_control/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,17 @@ k8s:
AgentTypeID::try_from("newrelic/com.newrelic.infrastructure:0.0.1").unwrap(),
},
)));
assert!(diff.contains(&(
&AgentID::try_from("nrdot").unwrap(),
&SubAgentConfig {
agent_type:
AgentTypeID::try_from("newrelic/io.opentelemetry.collector:0.0.1").unwrap(),
},
)));
assert!(
diff.contains(&(
&AgentID::try_from("nrdot").unwrap(),
&SubAgentConfig {
agent_type: AgentTypeID::try_from(
"newrelic/com.newrelic.opentelemetry.collector:0.0.1"
)
.unwrap(),
},
))
);
}

#[test]
Expand Down Expand Up @@ -723,7 +727,7 @@ k8s:
pub fn nrdot_identity() -> AgentIdentity {
let id = AgentID::try_from("nrdot").unwrap();
let agent_type_id =
AgentTypeID::try_from("newrelic/io.opentelemetry.collector:0.0.1").unwrap();
AgentTypeID::try_from("newrelic/com.newrelic.opentelemetry.collector:0.0.1").unwrap();
AgentIdentity { id, agent_type_id }
}

Expand Down
2 changes: 1 addition & 1 deletion agent-control/src/agent_control/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub(crate) fn get_custom_capabilities(agent_type_id: &AgentTypeID) -> Option<Cus
}

pub const AGENT_TYPE_NAME_INFRA_AGENT: &str = "com.newrelic.infrastructure";
pub const AGENT_TYPE_NAME_NRDOT: &str = "io.opentelemetry.collector";
pub const AGENT_TYPE_NAME_NRDOT: &str = "com.newrelic.opentelemetry.collector";

#[cfg(test)]
pub(crate) mod tests {
Expand Down
2 changes: 1 addition & 1 deletion agent-control/src/agent_type/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The metadata section contains information about the agent type, such as its name

```yaml
namespace: newrelic
name: io.opentelemetry.collector
name: com.newrelic.opentelemetry.collector
version: 0.0.1
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,65 @@ static AGENT_TYPE_FLUENTBIT: LazyLock<AgentTypeValuesTestCase> =
});

static AGENT_TYPE_OTEL_COLLECTOR: LazyLock<AgentTypeValuesTestCase> =
LazyLock::new(|| AgentTypeValuesTestCase {
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.1.0",
values_k8s: AgentTypeValues {
cases: HashMap::from([
("mandatory fields only", r#"chart_version: "some-version""#),
(
"check all value types are correct",
r#"
chart_version: "some-version"
chart_values.nr-k8s-otel-collector:
yaml: object
chart_values.global:
yaml: object
"#,
),
]),
additional_env: HashMap::from([
(
Namespace::EnvironmentVariable.namespaced_name("NR_LICENSE_KEY"),
Variable::new_final_string_variable("abcd1234".to_string()),
),
(
Namespace::EnvironmentVariable.namespaced_name("NR_CLUSTER_NAME"),
Variable::new_final_string_variable("my-test-cluster".to_string()),
),
(
Namespace::EnvironmentVariable.namespaced_name("NR_STAGING"),
Variable::new_final_string_variable("true".to_string()),
),
(
Namespace::EnvironmentVariable.namespaced_name("NR_LOW_DATA_MODE"),
Variable::new_final_string_variable("true".to_string()),
),
(
Namespace::EnvironmentVariable.namespaced_name("NR_VERBOSE_LOG"),
Variable::new_final_string_variable("true".to_string()),
),
]),
}
.into(),
values_onhost: AgentTypeValues {
cases: HashMap::from([
("mandatory fields only", ""),
(
"check all value types are correct",
r#"
config: "some file contents"
backoff_delay: "10s"
health_check.path: "/health"
health_check.port: 12345
"#,
),
]),
..Default::default()
}
.into(),
});

static AGENT_TYPE_OTEL_COLLECTOR_OLD: LazyLock<AgentTypeValuesTestCase> =
LazyLock::new(|| AgentTypeValuesTestCase {
agent_type: "newrelic/io.opentelemetry.collector:0.1.0",
values_k8s: AgentTypeValues {
Expand Down Expand Up @@ -507,6 +566,7 @@ fn get_agent_type_test_cases() -> impl Iterator<Item = &'static AgentTypeValuesT
&AGENT_TYPE_PROMETHEUS,
&AGENT_TYPE_FLUENTBIT,
&AGENT_TYPE_OTEL_COLLECTOR,
&AGENT_TYPE_OTEL_COLLECTOR_OLD,
&AGENT_TYPE_PIPELINE_CONTROL_GATEWAY,
&AGENT_TYPE_EBPF,
]
Expand Down
2 changes: 1 addition & 1 deletion agent-control/src/agent_type/embedded_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub mod tests {
}
}

const AGENT_TYPE_AMOUNT: usize = 12;
const AGENT_TYPE_AMOUNT: usize = 13;

#[test]
fn check_agent_type_amount_is_unchanged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ agents:
infra-agent-c:
agent_type: "newrelic/com.newrelic.infrastructure:1.0.3"
not-infra-agent:
agent_type: "newrelic/io.opentelemetry.collector:0.0.1"
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.0.1"
"#,
expected: AgentControlDynamicConfig {
agents: HashMap::from([
Expand Down Expand Up @@ -171,7 +171,7 @@ agents:
infra-agent-c:
agent_type: "newrelic/com.newrelic.infrastructure:1.0.3"
not-infra-agent:
agent_type: "newrelic/io.opentelemetry.collector:0.0.1"
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.0.1"
"#,
expected: AgentControlDynamicConfig {
agents: HashMap::from([
Expand Down Expand Up @@ -249,7 +249,7 @@ agents:
infra-agent-b:
agent_type: "newrelic/com.newrelic.infrastructure:0.0.2"
not-infra-agent:
agent_type: "newrelic/io.opentelemetry.collector:0.0.1"
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.0.1"
"#,
},
TestCase {
Expand All @@ -268,7 +268,7 @@ agents:
infra-agent-c:
agent_type: "newrelic/com.newrelic.infrastructure:1.0.3"
not-infra-agent:
agent_type: "newrelic/io.opentelemetry.collector:0.0.1"
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.0.1"
"#,
},
];
Expand Down
2 changes: 1 addition & 1 deletion agent-control/tests/k8s/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn k8s_self_update_bump_chart_version_with_new_config() {
// This agent will not actually be deployed since misses the chart_version config.
let agents_config = r#"agents:
nrdot:
agent_type: newrelic/io.opentelemetry.collector:0.1.0
agent_type: newrelic/com.newrelic.opentelemetry.collector:0.1.0
"#;

let ac_config = format!(
Expand Down
2 changes: 1 addition & 1 deletion agent-control/tests/k8s/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ agents:
infra-agent-b:
agent_type: "newrelic/com.newrelic.infrastructure:0.0.2"
not-infra-agent:
agent_type: "newrelic/io.opentelemetry.collector:0.1.0"
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.1.0"
"#;
let remote_values_agent = RemoteConfig {
config: from_str::<YAMLConfig>(agents_cfg).unwrap(),
Expand Down
4 changes: 1 addition & 3 deletions build/examples/agent-control-config-all-agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
# provider: PLACEHOLDER
# private_key_path: PLACEHOLDER



server:
enabled: true

agents:
nr-infra:
agent_type: "newrelic/com.newrelic.infrastructure:0.1.0"
nrdot:
agent_type: "newrelic/io.opentelemetry.collector:0.1.0"
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ server:

agents:
nrdot:
agent_type: "newrelic/io.opentelemetry.collector:0.1.0"
agent_type: "newrelic/com.newrelic.opentelemetry.collector:0.1.0"
Loading
Loading