From e6a46340529d9c064425787394c88029af91361c Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Thu, 16 Nov 2023 19:31:44 -0800 Subject: [PATCH 01/67] Set env vars for service instead of machine --- .../workflows/scripts/win-test-services.ps1 | 40 +++++++++++------- .../packaging/installer/install.ps1 | 41 ++++++++++++++----- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/.github/workflows/scripts/win-test-services.ps1 b/.github/workflows/scripts/win-test-services.ps1 index b6ff00c9d0..0e4d3dce21 100644 --- a/.github/workflows/scripts/win-test-services.ps1 +++ b/.github/workflows/scripts/win-test-services.ps1 @@ -10,10 +10,20 @@ param ( $ErrorActionPreference = 'Stop' Set-PSDebug -Trace 1 -function check_regkey([string]$name, [string]$value) { - $actual = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "$name" - if ( "$value" -ne "$actual" ) { - throw "Environment variable $name is not properly set. Found: '$actual', Expected '$value'" +function check_collector_svc_environment([hashtable]$expected_env_vars) { + $env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" + $actual_env_vars = @{} + foreach ($entry in $env_array) { + $key, $value = $entry.Split("=", 2) + $actual_env_vars.Add($key, $value) + } + + foreach ($key in $expected_env_vars.Keys) { + $expected_value = $expected_env_vars[$key] + $actual_value = $actual_env_vars[$key] + if ($expected_value -ne $actual_value) { + throw "Environment variable $key is not properly set. Found: '$actual_value', Expected '$expected_value'" + } } } @@ -24,16 +34,18 @@ function service_running([string]$name) { $api_url = "https://api.${realm}.signalfx.com" $ingest_url = "https://ingest.${realm}.signalfx.com" -check_regkey -name "SPLUNK_CONFIG" -value "${env:PROGRAMDATA}\Splunk\OpenTelemetry Collector\${mode}_config.yaml" -check_regkey -name "SPLUNK_ACCESS_TOKEN" -value "$access_token" -check_regkey -name "SPLUNK_REALM" -value "$realm" -check_regkey -name "SPLUNK_API_URL" -value "$api_url" -check_regkey -name "SPLUNK_INGEST_URL" -value "$ingest_url" -check_regkey -name "SPLUNK_TRACE_URL" -value "${ingest_url}/v2/trace" -check_regkey -name "SPLUNK_HEC_URL" -value "${ingest_url}/v1/log" -check_regkey -name "SPLUNK_HEC_TOKEN" -value "$access_token" -check_regkey -name "SPLUNK_BUNDLE_DIR" -value "${env:PROGRAMFILES}\Splunk\OpenTelemetry Collector\agent-bundle" -check_regkey -name "SPLUNK_MEMORY_TOTAL_MIB" -value "$memory" +check_collector_svc_environment @{ + "SPLUNK_CONFIG" = "${env:PROGRAMDATA}\Splunk\OpenTelemetry Collector\${mode}_config.yaml"; + "SPLUNK_ACCESS_TOKEN" = "$access_token"; + "SPLUNK_REALM" = "$realm"; + "SPLUNK_API_URL" = "$api_url"; + "SPLUNK_INGEST_URL" = "$ingest_url"; + "SPLUNK_TRACE_URL" = "${ingest_url}/v2/trace"; + "SPLUNK_HEC_URL" = "${ingest_url}/v1/log"; + "SPLUNK_HEC_TOKEN" = "$access_token"; + "SPLUNK_BUNDLE_DIR" = "${env:PROGRAMFILES}\Splunk\OpenTelemetry Collector\agent-bundle"; + "SPLUNK_MEMORY_TOTAL_MIB" = "$memory"; +} if ((service_running -name "splunk-otel-collector")) { write-host "splunk-otel-collector service is running." diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index 7a0bf2b2c0..cd8410c9cf 100644 --- a/internal/buildscripts/packaging/installer/install.ps1 +++ b/internal/buildscripts/packaging/installer/install.ps1 @@ -420,6 +420,20 @@ function update_registry([string]$path, [string]$name, [string]$value) { Set-ItemProperty -path "$path" -name "$name" -value "$value" } +function set_service_environment([string]$service_name, [hashtable]$env_vars) { + # Transform the $env_vars to an array of strings so the Set-ItemProperty correctly create the + # 'Environment' REG_MULTI_SZ value. + [string []] $multi_sz_value = ($env_vars.Keys | foreach-object { "$_=$($env_vars[$_])" }) + + $target_service_reg_key = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name + if (Test-Path $target_service_reg_key) { + Set-ItemProperty $target_service_reg_key -Name "Environment" -Value $multi_sz_value + } + else { + throw "Invalid service '$service_name'. Registry key '$target_service_reg_key' doesn't exist." + } +} + function install_msi([string]$path) { Write-Host "Installing $path ..." $startTime = Get-Date @@ -580,19 +594,24 @@ if ($config_path -Eq "") { } } -update_registry -path "$regkey" -name "SPLUNK_ACCESS_TOKEN" -value "$access_token" -update_registry -path "$regkey" -name "SPLUNK_API_URL" -value "$api_url" -update_registry -path "$regkey" -name "SPLUNK_BUNDLE_DIR" -value "$bundle_dir" -update_registry -path "$regkey" -name "SPLUNK_CONFIG" -value "$config_path" -update_registry -path "$regkey" -name "SPLUNK_HEC_TOKEN" -value "$hec_token" -update_registry -path "$regkey" -name "SPLUNK_HEC_URL" -value "$hec_url" -update_registry -path "$regkey" -name "SPLUNK_INGEST_URL" -value "$ingest_url" -update_registry -path "$regkey" -name "SPLUNK_MEMORY_TOTAL_MIB" -value "$memory" +@collector_env_vars = @{ + "SPLUNK_ACCESS_TOKEN" = "$access_token"; + "SPLUNK_API_URL" = "$api_url"; + "SPLUNK_BUNDLE_DIR" = "$bundle_dir"; + "SPLUNK_CONFIG" = "$config_path"; + "SPLUNK_HEC_TOKEN" = "$hec_token"; + "SPLUNK_HEC_URL" = "$hec_url"; + "SPLUNK_INGEST_URL" = "$ingest_url"; + "SPLUNK_MEMORY_TOTAL_MIB" = "$memory"; + "SPLUNK_REALM" = "$realm"; + "SPLUNK_TRACE_URL" = "$trace_url"; +} if ($network_interface -Ne "") { - update_registry -path "$regkey" -name "SPLUNK_LISTEN_INTERFACE" -value "$network_interface" + @collector_env_vars.Add("SPLUNK_LISTEN_INTERFACE", "$network_interface") } -update_registry -path "$regkey" -name "SPLUNK_REALM" -value "$realm" -update_registry -path "$regkey" -name "SPLUNK_TRACE_URL" -value "$trace_url" + +# set the environment variables for the collector service +set_service_environment $service_name @collector_env_vars $message = " The Splunk OpenTelemetry Collector for Windows has been successfully installed. From 8dd68c7ca93462aa1520ad18f263d1388db74343 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Thu, 16 Nov 2023 19:43:23 -0800 Subject: [PATCH 02/67] Fix copy and pasted typo --- internal/buildscripts/packaging/installer/install.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index cd8410c9cf..23f1ffd85a 100644 --- a/internal/buildscripts/packaging/installer/install.ps1 +++ b/internal/buildscripts/packaging/installer/install.ps1 @@ -594,7 +594,7 @@ if ($config_path -Eq "") { } } -@collector_env_vars = @{ +$collector_env_vars = @{ "SPLUNK_ACCESS_TOKEN" = "$access_token"; "SPLUNK_API_URL" = "$api_url"; "SPLUNK_BUNDLE_DIR" = "$bundle_dir"; @@ -607,11 +607,11 @@ if ($config_path -Eq "") { "SPLUNK_TRACE_URL" = "$trace_url"; } if ($network_interface -Ne "") { - @collector_env_vars.Add("SPLUNK_LISTEN_INTERFACE", "$network_interface") + $collector_env_vars.Add("SPLUNK_LISTEN_INTERFACE", "$network_interface") } # set the environment variables for the collector service -set_service_environment $service_name @collector_env_vars +set_service_environment $service_name $collector_env_vars $message = " The Splunk OpenTelemetry Collector for Windows has been successfully installed. From 810e4f0bf0da28e58d1d67e13a030cacdab50836 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 10:22:33 -0800 Subject: [PATCH 03/67] Remove unused variable --- internal/buildscripts/packaging/installer/install.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index 23f1ffd85a..427a40d8c3 100644 --- a/internal/buildscripts/packaging/installer/install.ps1 +++ b/internal/buildscripts/packaging/installer/install.ps1 @@ -166,8 +166,6 @@ try { $tempdir = "\tmp\Splunk\OpenTelemetry Collector" } -$regkey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" - $fluentd_msi_name = "td-agent-4.3.2-x64.msi" $fluentd_dl_url = "https://s3.amazonaws.com/packages.treasuredata.com/4/windows/$fluentd_msi_name" try { From e5858d62ae88dd811582f159e1858f573e123196 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 12:17:00 -0800 Subject: [PATCH 04/67] Update chocolatey to use env vars at the service scope --- .../tools/chocolateyinstall.ps1 | 146 +++--------------- .../splunk-otel-collector/tools/common.ps1 | 34 ++++ 2 files changed, 59 insertions(+), 121 deletions(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 3bd529d2cc..7a703c9ee3 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -10,17 +10,6 @@ $pp = Get-PackageParameters $MODE = $pp['MODE'] -$SPLUNK_ACCESS_TOKEN = $pp['SPLUNK_ACCESS_TOKEN'] -$SPLUNK_INGEST_URL = $pp['SPLUNK_INGEST_URL'] -$SPLUNK_API_URL = $pp['SPLUNK_API_URL'] -$SPLUNK_HEC_TOKEN = $pp['SPLUNK_HEC_TOKEN'] -$SPLUNK_HEC_URL = $pp['SPLUNK_HEC_URL'] -$SPLUNK_TRACE_URL = $pp['SPLUNK_TRACE_URL'] -$SPLUNK_BUNDLE_DIR = $pp['SPLUNK_BUNDLE_DIR'] -$SPLUNK_LISTEN_INTERFACE = $pp['SPLUNK_LISTEN_INTERFACE'] -$SPLUNK_REALM = $pp['SPLUNK_REALM'] -$SPLUNK_MEMORY_TOTAL_MIB = $pp['SPLUNK_MEMORY_TOTAL_MIB'] - if ($MODE -and ($MODE -ne "agent") -and ($MODE -ne "gateway")) { throw "Invalid value of MODE option is specified. Collector service can only run in agent or gateway mode." } @@ -44,108 +33,33 @@ if ($WITH_FLUENTD) { check_policy } -$regkey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" - -# default values if parameters not passed -try{ - if (!$SPLUNK_ACCESS_TOKEN) { - $SPLUNK_ACCESS_TOKEN = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_ACCESS_TOKEN" -ErrorAction SilentlyContinue - } - else{ - update_registry -path "$regkey" -name "SPLUNK_ACCESS_TOKEN" -value "$SPLUNK_ACCESS_TOKEN" - } -} -catch{ - write-host "The SPLUNK_ACCESS_TOKEN parameter is not specified." -} - -try { - if (!$SPLUNK_REALM) { - $SPLUNK_REALM = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_REALM" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_REALM = "us0" - write-host "The SPLUNK_REALM parameter is not specified. Using default configuration." -} - -try { - if (!$SPLUNK_INGEST_URL) { - $SPLUNK_INGEST_URL = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_INGEST_URL" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_INGEST_URL = "https://ingest.$SPLUNK_REALM.signalfx.com" - write-host "The SPLUNK_INGEST_URL parameter is not specified. Using default configuration." -} - -try { - if (!$SPLUNK_API_URL) { - $SPLUNK_API_URL = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_API_URL" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_API_URL = "https://api.$SPLUNK_REALM.signalfx.com" - write-host "The SPLUNK_INGEST_URL parameter is not specified. Using default configuration." -} - -try { - if (!$SPLUNK_HEC_TOKEN) { - $SPLUNK_HEC_TOKEN = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_HEC_TOKEN" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_HEC_TOKEN = $SPLUNK_ACCESS_TOKEN - write-host "The SPLUNK_HEC_TOKEN parameter is not specified. Using default configuration." +# Read splunk-otel-collector service Environment variables from the registry, if it exists. +$env_vars = @{} +$service_name = "splunk-otel-collector" +$regkey = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name +foreach ($entry in (Get-ItemPropertyValue -Path "$regkey" -Name "Environment" -ErrorAction SilentlyContinue)) { + $k, $v = $entry.Split("=", 2) + $env_vars[$k] = "$v" } -try { - if (!$SPLUNK_HEC_URL) { - $SPLUNK_HEC_URL = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_HEC_URL" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_HEC_URL = "https://ingest.$SPLUNK_REALM.signalfx.com/v1/log" - write-host "The SPLUNK_HEC_URL parameter is not specified. Using default configuration." -} - -try { - if (!$SPLUNK_TRACE_URL) { - $SPLUNK_TRACE_URL = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_TRACE_URL" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_TRACE_URL = "https://ingest.$SPLUNK_REALM.signalfx.com/v2/trace" - write-host "The SPLUNK_TRACE_URL parameter is not specified. Using default configuration." -} - -try { - if (!$SPLUNK_MEMORY_TOTAL_MIB) { - $SPLUNK_MEMORY_TOTAL_MIB = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_MEMORY_TOTAL_MIB" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_MEMORY_TOTAL_MIB = "512" - write-host "The SPLUNK_MEMORY_TOTAL_MIB parameter is not specified. Using default configuration." +# Use default values if package parameters not set +$access_token = $pp["SPLUNK_ACCESS_TOKEN"] +if ($access_token) { + $env_vars["SPLUNK_ACCESS_TOKEN"] = "$access_token" # Env. var values are always strings +} elseif (!$env_vars["SPLUNK_ACCESS_TOKEN"]) { + write-host "The SPLUNK_ACCESS_TOKEN parameter is not specified." } -try { - if (!$SPLUNK_LISTEN_INTERFACE) { - $SPLUNK_LISTEN_INTERFACE = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_LISTEN_INTERFACE" -ErrorAction SilentlyContinue - } -} -catch { -} +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_REALM" "us0" +$realm = $env_vars["SPLUNK_REALM"] # Cache the realm since it is used to build various default values. -try { - if (!$SPLUNK_BUNDLE_DIR) { - $SPLUNK_BUNDLE_DIR = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_BUNDLE_DIR" -ErrorAction SilentlyContinue - } -} -catch { - $SPLUNK_BUNDLE_DIR = "$installation_path\agent-bundle" - write-host "The SPLUNK_BUNDLE_DIR parameter is not specified. Using default configuration." -} +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_INGEST_URL" "https://ingest.$realm.signalfx.com" +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_API_URL" "https://api.$realm.signalfx.com" +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_HEC_TOKEN" $env_vars["SPLUNK_ACCESS_TOKEN"] +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_HEC_URL" "https://ingest.$realm.signalfx.com/v1/log" +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_TRACE_URL" "https://ingest.$realm.signalfx.com/v2/trace" +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_MEMORY_TOTAL_MIB" "512" +set_env_var_value_from_package_params $env_vars $pp "SPLUNK_BUNDLE_DIR" "$installation_path\agent-bundle" # remove orphaned service or when upgrading from bundle installation if (service_installed -name "$service_name") { @@ -163,18 +77,6 @@ try { write-host "$_" } -update_registry -path "$regkey" -name "SPLUNK_API_URL" -value "$SPLUNK_API_URL" -update_registry -path "$regkey" -name "SPLUNK_BUNDLE_DIR" -value "$SPLUNK_BUNDLE_DIR" -if ($SPLUNK_LISTEN_INTERFACE) { - update_registry -path "$regkey" -name "SPLUNK_LISTEN_INTERFACE" -value "$SPLUNK_LISTEN_INTERFACE" -} -update_registry -path "$regkey" -name "SPLUNK_HEC_TOKEN" -value "$SPLUNK_HEC_TOKEN" -update_registry -path "$regkey" -name "SPLUNK_HEC_URL" -value "$SPLUNK_HEC_URL" -update_registry -path "$regkey" -name "SPLUNK_INGEST_URL" -value "$SPLUNK_INGEST_URL" -update_registry -path "$regkey" -name "SPLUNK_MEMORY_TOTAL_MIB" -value "$SPLUNK_MEMORY_TOTAL_MIB" -update_registry -path "$regkey" -name "SPLUNK_REALM" -value "$SPLUNK_REALM" -update_registry -path "$regkey" -name "SPLUNK_TRACE_URL" -value "$SPLUNK_TRACE_URL" - $packageArgs = @{ packageName = $env:ChocolateyPackageName fileType = 'msi' @@ -203,7 +105,7 @@ elseif ($MODE -eq "gateway"){ } } -update_registry -path "$regkey" -name "SPLUNK_CONFIG" -value "$config_path" +$env_vars["SPLUNK_CONFIG"] = "$config_path" # Install and configure fluentd to forward log events to the collector. if ($WITH_FLUENTD) { @@ -216,6 +118,8 @@ if ($WITH_FLUENTD) { } } +set_service_environment $service_name $env_vars + # Try starting the service(s) only after all components were successfully installed and SPLUNK_ACCESS_TOKEN was found. if (!$SPLUNK_ACCESS_TOKEN) { write-host "" diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 index 488cebf873..cea98ae62b 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 @@ -139,6 +139,40 @@ function remove_otel_registry_entries() { } } +function set_env_var_value_from_package_params([hashtable] $env_vars, [hashtable] $package_params, [string]$name, [string]$default_value) { + $value = $package_params[$name] + if ($value) { + # If the variable was passed as a package parameter, use that value. + $env_vars[$name] = $value + return + } + + # If the variable was not passed as a package parameter, check if it was already set in the environment. + $value = $env_vars[$name] + if ($value) { + # If the variable already exists in the environment, use that value. + return + } + + $value = "$default_value" # Env. var values are always strings. + $env_vars[$name] = $value + Write-Host "The $name package parameter was not set, using the default value: '$value'" +} + +function set_service_environment([string]$service_name, [hashtable]$env_vars) { + # Transform the $env_vars to an array of strings so the Set-ItemProperty correctly create the + # 'Environment' REG_MULTI_SZ value. + [string []] $multi_sz_value = ($env_vars.Keys | foreach-object { "$_=$($env_vars[$_])" }) + + $target_service_reg_key = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name + if (Test-Path $target_service_reg_key) { + Set-ItemProperty $target_service_reg_key -Name "Environment" -Value $multi_sz_value + } + else { + throw "Invalid service '$service_name'. Registry key '$target_service_reg_key' doesn't exist." + } +} + function update_registry([string]$path, [string]$name, [string]$value) { write-host "Updating $path for $name..." Set-ItemProperty -path "$path" -name "$name" -value "$value" From d50a9c5404056262e76830ed183fdaf99257db94 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 12:49:59 -0800 Subject: [PATCH 05/67] Fix check for "SPLUNK_ACCESS_TOKEN" --- .../splunk-otel-collector/tools/chocolateyinstall.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 7a703c9ee3..38b3a1bfa3 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -35,7 +35,6 @@ if ($WITH_FLUENTD) { # Read splunk-otel-collector service Environment variables from the registry, if it exists. $env_vars = @{} -$service_name = "splunk-otel-collector" $regkey = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name foreach ($entry in (Get-ItemPropertyValue -Path "$regkey" -Name "Environment" -ErrorAction SilentlyContinue)) { $k, $v = $entry.Split("=", 2) @@ -121,11 +120,13 @@ if ($WITH_FLUENTD) { set_service_environment $service_name $env_vars # Try starting the service(s) only after all components were successfully installed and SPLUNK_ACCESS_TOKEN was found. -if (!$SPLUNK_ACCESS_TOKEN) { +if (!$env_vars["SPLUNK_ACCESS_TOKEN"]) { write-host "" write-host "*NOTICE*: SPLUNK_ACCESS_TOKEN was not specified as an installation parameter and not found in the Windows Registry." write-host "This is required for the default configuration to reach Splunk Observability Cloud and can be configured with:" - write-host " PS> Set-ItemProperty -path `"HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment`" -name `"SPLUNK_ACCESS_TOKEN`" -value `"ACTUAL_ACCESS_TOKEN`"" + write-host ' PS> $values = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" | Select-Object -ExpandProperty Environment' + write-host ' PS> $values += "SPLUNK_ACCESS_TOKEN="' + write-host ' PS> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name $propertyName -Value $values -Type MultiString' write-host "before starting the $service_name service with:" write-host " PS> Start-Service -Name `"${service_name}`"" if ($WITH_FLUENTD) { From 640e4050c1ff1551b931ae691822237a031f6715 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 14:38:07 -0800 Subject: [PATCH 06/67] Handle upgrade in chocolatey --- .../tools/chocolateyinstall.ps1 | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 38b3a1bfa3..9a99c99d79 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -33,8 +33,39 @@ if ($WITH_FLUENTD) { check_policy } -# Read splunk-otel-collector service Environment variables from the registry, if it exists. +# Read splunk-otel-collector environment variables. $env_vars = @{} +$env_var_names = @( + "SPLUNK_ACCESS_TOKEN", + "SPLUNK_REALM", + "SPLUNK_INGEST_URL", + "SPLUNK_API_URL", + "SPLUNK_HEC_TOKEN", + "SPLUNK_HEC_URL", + "SPLUNK_TRACE_URL", + "SPLUNK_MEMORY_TOTAL_MIB", + "SPLUNK_BUNDLE_DIR", + "SPLUNK_LISTEN_INTERFACE" +) +$upgraded_from_version_with_machine_wide_env_vars = $false + +# First check if any previous version of the collector is installed. +$collector_package = Get-Package -Name "Splunk OpenTelemetry Collector" -ErrorAction SilentlyContinue +if ($collector_package) { + # The package is already present, so this is an upgrade. + $installed_version = [Version]$collector_package.Version # Version for chocolatey doesn't include the prefilx 'v', this conversion is fine. + $last_version_with_machine_wide_env_vars = [Version]"0.88.0" + if ($installed_version -le $last_version_with_machine_wide_env_vars) { + $upgraded_from_version_with_machine_wide_env_vars = $true + foreach ($name in $env_var_names) { + $value = [Environment]::GetEnvironmentVariable($name, "Machine") + if ($value) { + $env_vars[$name] = "$value" + } + } + } +} + $regkey = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name foreach ($entry in (Get-ItemPropertyValue -Path "$regkey" -Name "Environment" -ErrorAction SilentlyContinue)) { $k, $v = $entry.Split("=", 2) @@ -76,6 +107,13 @@ try { write-host "$_" } +if ($upgraded_from_version_with_machine_wide_env_vars) { + # Remove the machine-wide environment variables that were set by previous versions of the collector. + foreach ($name in $env_var_names) { + [Environment]::SetEnvironmentVariable($name, $null, "Machine") + } +} + $packageArgs = @{ packageName = $env:ChocolateyPackageName fileType = 'msi' From 50a8cb574c3c9c0d0b69af0dfb243a783136c56b Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 16:18:41 -0800 Subject: [PATCH 07/67] Get-Package not available on all Windows versions --- .../splunk-otel-collector/tools/chocolateyinstall.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 9a99c99d79..18e837c602 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -50,10 +50,11 @@ $env_var_names = @( $upgraded_from_version_with_machine_wide_env_vars = $false # First check if any previous version of the collector is installed. -$collector_package = Get-Package -Name "Splunk OpenTelemetry Collector" -ErrorAction SilentlyContinue -if ($collector_package) { +$installed_collector = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" -ErrorAction SilentlyContinue | + Where-Object { $_.DisplayName -eq "Splunk OpenTelemetry Collector" } +if ($installed_collector) { # The package is already present, so this is an upgrade. - $installed_version = [Version]$collector_package.Version # Version for chocolatey doesn't include the prefilx 'v', this conversion is fine. + $installed_version = [Version]$installed_collector.DisplayVersion # Version for chocolatey doesn't include the prefilx 'v', this conversion is fine. $last_version_with_machine_wide_env_vars = [Version]"0.88.0" if ($installed_version -le $last_version_with_machine_wide_env_vars) { $upgraded_from_version_with_machine_wide_env_vars = $true @@ -69,7 +70,7 @@ if ($collector_package) { $regkey = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name foreach ($entry in (Get-ItemPropertyValue -Path "$regkey" -Name "Environment" -ErrorAction SilentlyContinue)) { $k, $v = $entry.Split("=", 2) - $env_vars[$k] = "$v" + $env_vars[$k] = $v } # Use default values if package parameters not set From aecc55972915ed27f16e3cd3912411bcae5b3eb8 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 17:34:31 -0800 Subject: [PATCH 08/67] Add messages to track stage on chocolatey install --- .../choco/splunk-otel-collector/tools/chocolateyinstall.ps1 | 6 ++++-- .../packaging/choco/splunk-otel-collector/tools/common.ps1 | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 18e837c602..b472dc01ef 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -49,14 +49,15 @@ $env_var_names = @( ) $upgraded_from_version_with_machine_wide_env_vars = $false +Write-Host "Checking for previous installation..." # First check if any previous version of the collector is installed. $installed_collector = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -eq "Splunk OpenTelemetry Collector" } if ($installed_collector) { # The package is already present, so this is an upgrade. $installed_version = [Version]$installed_collector.DisplayVersion # Version for chocolatey doesn't include the prefilx 'v', this conversion is fine. - $last_version_with_machine_wide_env_vars = [Version]"0.88.0" - if ($installed_version -le $last_version_with_machine_wide_env_vars) { + $first_version_with_service_env_vars = [Version]"0.89.0.0" + if ($installed_version -lt $first_version_with_service_env_vars) { $upgraded_from_version_with_machine_wide_env_vars = $true foreach ($name in $env_var_names) { $value = [Environment]::GetEnvironmentVariable($name, "Machine") @@ -74,6 +75,7 @@ foreach ($entry in (Get-ItemPropertyValue -Path "$regkey" -Name "Environment" -E } # Use default values if package parameters not set +Write-Host "Setting default values for missing parameters..." $access_token = $pp["SPLUNK_ACCESS_TOKEN"] if ($access_token) { $env_vars["SPLUNK_ACCESS_TOKEN"] = "$access_token" # Env. var values are always strings diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 index cea98ae62b..84adc38fdb 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 @@ -160,6 +160,7 @@ function set_env_var_value_from_package_params([hashtable] $env_vars, [hashtable } function set_service_environment([string]$service_name, [hashtable]$env_vars) { + Write-Host "Setting environment variables for the $service_name service..." # Transform the $env_vars to an array of strings so the Set-ItemProperty correctly create the # 'Environment' REG_MULTI_SZ value. [string []] $multi_sz_value = ($env_vars.Keys | foreach-object { "$_=$($env_vars[$_])" }) @@ -173,11 +174,6 @@ function set_service_environment([string]$service_name, [hashtable]$env_vars) { } } -function update_registry([string]$path, [string]$name, [string]$value) { - write-host "Updating $path for $name..." - Set-ItemProperty -path "$path" -name "$name" -value "$value" -} - # check that we're not running with a restricted execution policy function check_policy() { $executionPolicy = (Get-ExecutionPolicy) From bf7f0a481ecf4dd6a86746c0326d9725e84be899 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 19:09:03 -0800 Subject: [PATCH 09/67] Adding more messages to chocolatey script --- .../choco/splunk-otel-collector/tools/chocolateyinstall.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index b472dc01ef..0e7c5ecb2b 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -55,10 +55,12 @@ $installed_collector = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\Curren Where-Object { $_.DisplayName -eq "Splunk OpenTelemetry Collector" } if ($installed_collector) { # The package is already present, so this is an upgrade. + Write-Host "Found a previous installation..." $installed_version = [Version]$installed_collector.DisplayVersion # Version for chocolatey doesn't include the prefilx 'v', this conversion is fine. $first_version_with_service_env_vars = [Version]"0.89.0.0" if ($installed_version -lt $first_version_with_service_env_vars) { $upgraded_from_version_with_machine_wide_env_vars = $true + Write-Host "Getting machine wide environment variables..." foreach ($name in $env_var_names) { $value = [Environment]::GetEnvironmentVariable($name, "Machine") if ($value) { @@ -68,6 +70,7 @@ if ($installed_collector) { } } +Write-Host "Getting service level environment variables..." $regkey = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name foreach ($entry in (Get-ItemPropertyValue -Path "$regkey" -Name "Environment" -ErrorAction SilentlyContinue)) { $k, $v = $entry.Split("=", 2) From da12a5bfc562b83ba8931c13ea0b9f286a4def61 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 19:57:58 -0800 Subject: [PATCH 10/67] Fix service on the registry but no env --- .../tools/chocolateyinstall.ps1 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 0e7c5ecb2b..2a581cda7d 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -70,11 +70,17 @@ if ($installed_collector) { } } -Write-Host "Getting service level environment variables..." -$regkey = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name -foreach ($entry in (Get-ItemPropertyValue -Path "$regkey" -Name "Environment" -ErrorAction SilentlyContinue)) { - $k, $v = $entry.Split("=", 2) - $env_vars[$k] = $v +$reg_path = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name +if (Test-Path $reg_path) { + Write-Host "Service registry entry key found: $reg_path" + $previous_environment = Get-ItemProperty $reg_path -Name "Environment" -ErrorAction SilentlyContinue + if ($previous_environment) { + Write-Host "Found previous environment variables for the $service_name service." + foreach ($entry in $previous_environment) { + $k, $v = $entry.Split("=", 2) + $env_vars[$k] = $v + } + } } # Use default values if package parameters not set From fe6a0ce9ec0de3eee9db09ce93f41257646b53d5 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 17 Nov 2023 20:45:03 -0800 Subject: [PATCH 11/67] Restore $regKey on install.ps1 --- internal/buildscripts/packaging/installer/install.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index 427a40d8c3..a1c8f5132f 100644 --- a/internal/buildscripts/packaging/installer/install.ps1 +++ b/internal/buildscripts/packaging/installer/install.ps1 @@ -687,6 +687,7 @@ if ($with_dotnet_instrumentation) { echo "Installing SignalFx Dotnet Auto Instrumentation..." Install-SignalFxDotnet + $regkey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" if ($deployment_env -ne "") { echo "Setting SIGNALFX_ENV environment variable to $deployment_env ..." update_registry -path "$regkey" -name "SIGNALFX_ENV" -value "$deployment_env" From e091ad72f900b4e28b7acb48f9d69b5e776d675b Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 27 Nov 2023 14:43:03 -0800 Subject: [PATCH 12/67] Add helper allow running the collector manually on Windows --- .../packaging/msi/splunk-support-bundle.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/buildscripts/packaging/msi/splunk-support-bundle.ps1 b/internal/buildscripts/packaging/msi/splunk-support-bundle.ps1 index f4ec25ff86..0e8274dba5 100644 --- a/internal/buildscripts/packaging/msi/splunk-support-bundle.ps1 +++ b/internal/buildscripts/packaging/msi/splunk-support-bundle.ps1 @@ -57,6 +57,23 @@ for ( $i = 0; $i -lt $args.count; $i++ ) { } } +####################################### +# Extracts the environment variables configured for the splunk-otel-collector service +# and sets them in the current PowerShell session. This is useful to directly run the +# collector from the PowerShell console. This is not required for the support bundle. +# - GLOBALS: None +# - ARGUMENTS: None +# - OUTPUTS: None +# - RETURN: None +####################################### +function setCurrentEnvironmentForManualRun() { + $env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" + foreach ($entry in $env_array) { + $key, $value = $entry.Split("=", 2) + [Environment]::SetEnvironmentVariable($key, $value) + } +} + ####################################### # Creates a unique temporary directory to store the contents of the support # bundle. Do not attempt to cleanup to prevent any accidental deletions. From 5282d0732ee0d76974dbc041c37c1ac189e90c6f Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 27 Nov 2023 15:09:16 -0800 Subject: [PATCH 13/67] Add breaking change to CHANGELOG.md --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8e079426a..8adf90adcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Unreleased + +### 🛑 Breaking changes 🛑 + +- (Splunk) On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope. +It is possible that some instrumentations are relying on the machine-wide environment variables set by the installation. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930)) + ## v0.88.0 This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.88.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.88.0) and the [opentelemetry-collector-contrib v0.88.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.88.0) releases where appropriate. From 43f49f180787fadba4a5c755f44de5bdbb025a8c Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 1 Dec 2023 10:36:56 -0800 Subject: [PATCH 14/67] Add -config_path switch to install.ps1 --- .../packaging/installer/install.ps1 | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index a1c8f5132f..3f0ff8e4f0 100644 --- a/internal/buildscripts/packaging/installer/install.ps1 +++ b/internal/buildscripts/packaging/installer/install.ps1 @@ -111,6 +111,11 @@ For information about the public MSI properties see https://learn.microsoft.com/en-us/windows/win32/msi/property-reference#configuration-properties .EXAMPLE .\install.ps1 -access_token "ACCESSTOKEN" -msi_public_properties "ALLUSERS=1" +.PARAMETER config_path + (OPTIONAL) Specify a local path to an alternative configuration file for the Splunk OpenTelemetry Collector. + If specified, the -mode parameter will be ignored. + .EXAMPLE + .\install.ps1 -config_path "C:\SOME_FOLDER\my_config.yaml" #> param ( @@ -132,6 +137,7 @@ param ( [ValidateSet('test','beta','release')][string]$stage = "release", [string]$msi_path = "", [string]$msi_public_properties = "", + [string]$config_path = "", [string]$collector_msi_url = "", [string]$fluentd_msi_url = "", [string]$deployment_env = "", @@ -157,7 +163,6 @@ try { $old_config_path = "$program_data_path\config.yaml" $agent_config_path = "$program_data_path\agent_config.yaml" $gateway_config_path = "$program_data_path\gateway_config.yaml" -$config_path = "" try { Resolve-Path $env:TEMP 2>&1>$null @@ -578,20 +583,20 @@ if (!(Test-Path -Path "$old_config_path") -And (Test-Path -Path "$installation_p Copy-Item "$installation_path\config.yaml" "$old_config_path" } -if (($mode -Eq "agent") -And (Test-Path -Path "$agent_config_path")) { - $config_path = $agent_config_path -} elseif (($mode -Eq "gateway") -And (Test-Path -Path "$gateway_config_path")) { - $config_path = $gateway_config_path -} - if ($config_path -Eq "") { - if (Test-Path -Path "$old_config_path") { + if (($mode -Eq "agent") -And (Test-Path -Path "$agent_config_path")) { + $config_path = $agent_config_path + } elseif (($mode -Eq "gateway") -And (Test-Path -Path "$gateway_config_path")) { + $config_path = $gateway_config_path + } elseif (Test-Path -Path "$old_config_path") { $config_path = $old_config_path - } else { - throw "Valid Collector configuration file not found." } } +if (!(Test-Path -Path "$config_path")) { + throw "Valid Collector configuration file not found at $config_path." +} + $collector_env_vars = @{ "SPLUNK_ACCESS_TOKEN" = "$access_token"; "SPLUNK_API_URL" = "$api_url"; @@ -604,6 +609,7 @@ $collector_env_vars = @{ "SPLUNK_REALM" = "$realm"; "SPLUNK_TRACE_URL" = "$trace_url"; } + if ($network_interface -Ne "") { $collector_env_vars.Add("SPLUNK_LISTEN_INTERFACE", "$network_interface") } From 224ab0b22211196b2230a105761e2bf4d0a7f6d1 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 1 Dec 2023 10:38:02 -0800 Subject: [PATCH 15/67] Fix pipeline collector for Windows ZC IIS test --- .../windows/testdata/Dockerfile.pipeline.collector | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/zeroconfig/windows/testdata/Dockerfile.pipeline.collector b/tests/zeroconfig/windows/testdata/Dockerfile.pipeline.collector index b490fbcba9..404da61ca9 100644 --- a/tests/zeroconfig/windows/testdata/Dockerfile.pipeline.collector +++ b/tests/zeroconfig/windows/testdata/Dockerfile.pipeline.collector @@ -18,10 +18,8 @@ ENV ACCESS_TOKEN_TMP=$access_token RUN ` $token = $Env:ACCESS_TOKEN_TMP; ` $collector_msi_path = (dir "c:\setup\splunk-otel-collector-*.msi").FullName; ` - c:\setup\install.ps1 -access_token $token -msi_path $collector_msi_path -with_fluentd $false -ingest_url "http://192.0.2.1:12345" -trace_url "http://192.0.2.1:12345" -network_interface "0.0.0.0" + c:\setup\install.ps1 -access_token $token -msi_path $collector_msi_path -config_path "C:\setup\pipeline-collector.yaml" -with_fluentd $false -ingest_url "http://192.0.2.1:12345" -trace_url "http://192.0.2.1:12345" -network_interface "0.0.0.0" ENV ACCESS_TOKEN_TMP= -RUN ` - Set-ItemProperty -force -path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -name 'SPLUNK_CONFIG' -value 'C:\setup\pipeline-collector.yaml' # On docker compose the entry point needs to be changed to something that keeps the container alive. -ENTRYPOINT [ "powershell", "-Command", "Start-Sleep 1; While ($? -eq '1') { Start-Sleep 1; Invoke-WebRequest -Uri http://localhost:13133/health_check -TimeoutSec 5 -UseBasicParsing }" ] +ENTRYPOINT [ "powershell", "-Command", "Start-Sleep 5; While ($? -eq '1') { Start-Sleep 5; Invoke-WebRequest -Uri http://localhost:13133/health_check -TimeoutSec 10 -UseBasicParsing }" ] From 51ed501aa3352d4101a983aa933154d762b1155d Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 4 Dec 2023 15:08:11 -0800 Subject: [PATCH 16/67] MSI to set SPLUNK_CONFIG at the service scope --- .../buildscripts/packaging/msi/splunk-otel-collector.wxs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs b/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs index 2c967c2b93..773fa1bb5a 100644 --- a/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs +++ b/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs @@ -39,8 +39,10 @@ - - + + + SPLUNK_CONFIG=[CommonAppDataFolder]Splunk\OpenTelemetry Collector\agent_config.yaml" + From 75638da65d5a518a2dc2419007ae3b4850477ec6 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 6 Dec 2023 13:45:40 -0800 Subject: [PATCH 17/67] Minor doc updates --- docs/getting-started/windows-installer.md | 12 +++------ docs/getting-started/windows-manual.md | 33 ++++++++--------------- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/docs/getting-started/windows-installer.md b/docs/getting-started/windows-installer.md index f2a31e5eda..e32d5394bd 100644 --- a/docs/getting-started/windows-installer.md +++ b/docs/getting-started/windows-installer.md @@ -76,8 +76,8 @@ can be modified as needed. Possible configuration options can be found in the Based on the specified installation parameters, the following environment variables will be saved to the -`HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment` registry -key and passed to the Collector service: +`HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector` registry +key and set on the `Environment` entry: - `SPLUNK_ACCESS_TOKEN`: The Splunk access token to authenticate requests - `SPLUNK_API_URL`: The Splunk API URL, e.g. `https://api.us0.signalfx.com` @@ -90,13 +90,7 @@ key and passed to the Collector service: - `SPLUNK_REALM`: The Splunk realm to send the data to, e.g. `us0` - `SPLUNK_TRACE_URL`: The Splunk trace endpoint URL, e.g. `https://ingest.us0.signalfx.com/v2/trace` -To modify these values, run `regdit` and browse to the path, or run the -following PowerShell command (replace `ENV_VAR` and `VALUE` for the desired -environment variable and value): - -```powershell -Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "ENV_VAR" -value "VALUE" -``` +To modify these values, run `regedit` and browse to the path. To add or remove command line options for the `splunk-otel-collector` service, run `regedit` and modify the `ImagePath` value in the diff --git a/docs/getting-started/windows-manual.md b/docs/getting-started/windows-manual.md index 547636c883..e3fd684fa2 100644 --- a/docs/getting-started/windows-manual.md +++ b/docs/getting-started/windows-manual.md @@ -68,18 +68,7 @@ following command in a PowerShell terminal: Start-Service splunk-otel-collector ``` -To modify the default path to the configuration file for the -`splunk-otel-collector` service, run `regdit` and modify the `SPLUNK_CONFIG` -value in the -`HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment` -registry key, or run the following PowerShell command (replace `PATH` with the -full path to the new configuration file): - -```powershell -Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_CONFIG" -value "PATH" -``` - -To add or remove command line options for the `splunk-otel-collector` service, +To modify, add or remove command line options for the `splunk-otel-collector` service, run `regedit` and modify the `ImagePath` value in the `HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector` registry key, or run the following PowerShell command (replace `OPTIONS` with the desired @@ -195,15 +184,15 @@ choco install splunk-otel-collector --params="'/SPLUNK_ACCESS_TOKEN:MY_SPLUNK_AC The following package parameters are available: - * `/SPLUNK_ACCESS_TOKEN`: The Splunk access token (org token) used to send data to Splunk Observability Cloud. This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_ACCESS_TOKEN` registry value. - * `/SPLUNK_REALM`: The Splunk realm to send the data to. This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_REALM` registry value. Default value is `us0`. - * `/SPLUNK_INGEST_URL:`: URL of the Splunk ingest endpoint (e.g. `https://ingest.us1.signalfx.com`). This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_INGEST_URL` registry value. Default value is `https://ingest.$SPLUNK_REALM.signalfx.com`. - * `/SPLUNK_API_URL`: URL of the Splunk API endpoint (e.g. `https://api.us1.signalfx.com`). This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_API_URL` registry value. Default value is `https://api.$SPLUNK_REALM.signalfx.com`. - * `/SPLUNK_HEC_TOKEN`: The Splunk HEC authentication token. This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_HEC_TOKEN` registry value. Default value is the same as `SPLUNK_ACCESS_TOKEN`. - * `/SPLUNK_HEC_URL`: URL of the Splunk HEC endpoint (e.g. `https://ingest.us1.signalfx.com/v1/log`). This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_HEC_URL` registry value. Default value is `https://ingest.$SPLUNK_REALM.signalfx.com/v1/log` - * `/SPLUNK_TRACE_URL`: URL of the Splunk trace endpoint (e.g. `https://ingest.us1.signalfx.com/v2/trace`). This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_TRACE_URL` registry value. Default value is `https://ingest.$SPLUNK_REALM.signalfx.com/v2/trace` - * `/SPLUNK_BUNDLE_DIR`: The path to the Smart Agent bundle directory for the `smartagent` receiver and extension. The default path is provided by the Collector package. If the specified path is changed from the default value, the path should be an existing directory on the system. This parameter is saved to the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_BUNDLE_DIR` registry value. Default value is `\Program Files\Splunk\OpenTelemetry Collector\agent-bundle`. - * `/MODE`: This parameter is used for setting the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_CONFIG` registry value to `\ProgramData\Splunk\OpenTelemetry Collector\agent_config.yaml` or `\ProgramData\Splunk\OpenTelemetry Collector\gateway_config.yaml`. Possible values are `agent` and `gateway`. Default value is `agent`. + * `/SPLUNK_ACCESS_TOKEN`: The Splunk access token (org token) used to send data to Splunk Observability Cloud. + * `/SPLUNK_REALM`: The Splunk realm to send the data to. Default value is `us0`. + * `/SPLUNK_INGEST_URL:`: URL of the Splunk ingest endpoint (e.g. `https://ingest.us1.signalfx.com`). Default value is `https://ingest.$SPLUNK_REALM.signalfx.com`. + * `/SPLUNK_API_URL`: URL of the Splunk API endpoint (e.g. `https://api.us1.signalfx.com`). Default value is `https://api.$SPLUNK_REALM.signalfx.com`. + * `/SPLUNK_HEC_TOKEN`: The Splunk HEC authentication token. Default value is the same as `SPLUNK_ACCESS_TOKEN`. + * `/SPLUNK_HEC_URL`: URL of the Splunk HEC endpoint (e.g. `https://ingest.us1.signalfx.com/v1/log`). Default value is `https://ingest.$SPLUNK_REALM.signalfx.com/v1/log` + * `/SPLUNK_TRACE_URL`: URL of the Splunk trace endpoint (e.g. `https://ingest.us1.signalfx.com/v2/trace`). Default value is `https://ingest.$SPLUNK_REALM.signalfx.com/v2/trace` + * `/SPLUNK_BUNDLE_DIR`: The path to the Smart Agent bundle directory for the `smartagent` receiver and extension. The default path is provided by the Collector package. If the specified path is changed from the default value, the path should be an existing directory on the system. Default value is `\Program Files\Splunk\OpenTelemetry Collector\agent-bundle`. + * `/MODE`: This parameter is used for setting the `SPLUNK_CONFIG` value to `\ProgramData\Splunk\OpenTelemetry Collector\agent_config.yaml` or `\ProgramData\Splunk\OpenTelemetry Collector\gateway_config.yaml`. Possible values are `agent` and `gateway`. Default value is `agent`. * `/WITH_FLUENTD`: Whether to download, install, and configure Fluentd to collect and forward log events to the Collector. Possible values are `true` and `false`. If set to `true`, the Fluentd MSI package will be downloaded from `https://packages.treasuredata.com`. Default value is `false`. To pass parameters, use `--params "''"` (e.g. `choco install splunk-otel-collector --params="'/SPLUNK_ACCESS_TOKEN:MY_SPLUNK_ACCESS_TOKEN /SPLUNK_REALM:MY_SPLUNK_REALM'"`). @@ -213,7 +202,7 @@ To have choco remember parameters on upgrade, be sure to set `choco feature enab #### Notes * If the `SPLUNK_ACCESS_TOKEN` parameter is not specified on initial installation, the Collector service will not be started. In order to start the Collector service, manually create/set the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_ACCESS_TOKEN` registry value to the Splunk access token and run the `Start-Service splunk-otel-collector` PowerShell command. - * If the Collector configuration file or any of the `HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SPLUNK_*` registry values are modified after installation, restart the Collector service by restarting the system or by running the `Restart-Service splunk-otel-collector` PowerShell command. + * If the Collector configuration file or any of the service configuration settings are modified after installation, restart the Collector service by restarting the system or by running the `Restart-Service splunk-otel-collector` PowerShell command. * If the `WITH_FLUENTD` parameter is set to `true` and the `\opt\td-agent\etc\td-agent\td-agent.conf` Fluentd configuration file does not exist, this file will be created and customized to collect events from the Windows Event Log and forward the collected events to the Collector. If this file is modified after installation, restart the Fluentd service by restarting the system or by running the `Restart-Service fluentdwinsvc` PowerShell command. * See [Collector Configuration](https://github.com/signalfx/splunk-otel-collector/blob/main/docs/getting-started/windows-installer.md#collector-configuration) for additional configuration details. From a82a0bf6ce5d21155aa7974e7267fe59e1bcf7b3 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 6 Dec 2023 17:25:07 -0800 Subject: [PATCH 18/67] Update ansible tests for Windows env vars --- .../molecule/custom_vars/windows-verify.yml | 21 +++++++++++---- .../molecule/default/windows-verify.yml | 19 +++++++------ .../with_instrumentation/windows-verify.yml | 27 ++++++++++--------- deployments/ansible/roles/collector/README.md | 4 +-- .../ansible/roles/collector/tasks/vars.yml | 4 +-- 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/deployments/ansible/molecule/custom_vars/windows-verify.yml b/deployments/ansible/molecule/custom_vars/windows-verify.yml index beb52bdfe0..a812211d64 100644 --- a/deployments/ansible/molecule/custom_vars/windows-verify.yml +++ b/deployments/ansible/molecule/custom_vars/windows-verify.yml @@ -4,7 +4,7 @@ gather_facts: true become: no vars: - reg_values: + collector_reg_values: SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\custom_config.yml' SPLUNK_INGEST_URL: https://fake-splunk-ingest.com SPLUNK_API_URL: https://fake-splunk-api.com @@ -15,17 +15,17 @@ SPLUNK_BALLAST_SIZE_MIB: "100" MY_CUSTOM_VAR1: value1 MY_CUSTOM_VAR2: value2 - SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' dotnet_reg_values: - COR_ENABLE_PROFILING: "true" + COR_ENABLE_PROFILING: 1 COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" - CORECLR_ENABLE_PROFILING: "true" + CORECLR_ENABLE_PROFILING: 1 CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" SIGNALFX_ENV: test-environment SIGNALFX_SERVICE_NAME: test-service-name SIGNALFX_PROFILER_ENABLED: "true" SIGNALFX_PROFILER_MEMORY_ENABLED: "true" SIGNALFX_GLOBAL_TAGS: splunk.zc.method:signalfx-dotnet-tracing-1.0.0,dotnet-tag:dotnet-tag-value + SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' SIGNALFX_DOTNET_VAR1: dotnet-value1 SIGNALFX_DOTNET_VAR2: dotnet-value2 tasks: @@ -126,10 +126,21 @@ that: (item.key + '=' + item.value) in iis_env.value loop: "{{ dotnet_reg_values | dict2items }}" + - name: Get splunk-otel-collector service env vars + ansible.windows.win_reg_stat: + path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector + name: Environment + register: collector_env + + - name: Verify splunk-otel-collector service env vars + assert: + that: (item.key + '=' + item.value) in collector_env.value + loop: "{{ collector_reg_values | dict2items }}" + - name: Verify env vars include_tasks: ../shared/verify_registry_key.yml vars: path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment name: "{{ item.key }}" value: "{{ item.value }}" - loop: "{{ reg_values | combine(dotnet_reg_values) | dict2items }}" + loop: "{{ dotnet_reg_values | dict2items }}" diff --git a/deployments/ansible/molecule/default/windows-verify.yml b/deployments/ansible/molecule/default/windows-verify.yml index d203634b0a..e0a58ac6a6 100644 --- a/deployments/ansible/molecule/default/windows-verify.yml +++ b/deployments/ansible/molecule/default/windows-verify.yml @@ -4,7 +4,7 @@ gather_facts: true become: no vars: - reg_values: + collector_reg_values: SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm @@ -36,10 +36,13 @@ assert: that: not service_status.exists - - name: Verify env vars - include_tasks: ../shared/verify_registry_key.yml - vars: - path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment - name: "{{ item.key }}" - value: "{{ item.value }}" - loop: "{{ reg_values | dict2items }}" + - name: Get splunk-otel-collector service env vars + ansible.windows.win_reg_stat: + path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector + name: Environment + register: collector_env + + - name: Verify splunk-otel-collector service env vars + assert: + that: (item.key + '=' + item.value) in collector_env.value + loop: "{{ collector_reg_values | dict2items }}" diff --git a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml index 70e1c36253..55cb397488 100644 --- a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml +++ b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml @@ -4,7 +4,7 @@ gather_facts: true become: no vars: - reg_values: + collector_reg_values: SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm @@ -13,12 +13,12 @@ SPLUNK_HEC_URL: https://ingest.fake-realm.signalfx.com/v1/log SPLUNK_INGEST_URL: https://ingest.fake-realm.signalfx.com SPLUNK_TRACE_URL: https://ingest.fake-realm.signalfx.com/v2/trace - SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' dotnet_reg_values: - COR_ENABLE_PROFILING: "true" + COR_ENABLE_PROFILING: 1 COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" - CORECLR_ENABLE_PROFILING: "true" + CORECLR_ENABLE_PROFILING: 1 CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" + SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' SIGNALFX_ENV: "" SIGNALFX_SERVICE_NAME: "" SIGNALFX_PROFILER_ENABLED: "false" @@ -50,14 +50,6 @@ {%- set tags = "splunk.zc.method:signalfx-dotnet-tracing-" + (msi_version.stdout | trim) -%} {{ dotnet_reg_values | combine({"SIGNALFX_GLOBAL_TAGS": tags}) }} - - name: Verify collector env vars - include_tasks: ../shared/verify_registry_key.yml - vars: - path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment - name: "{{ item.key }}" - value: "{{ item.value }}" - loop: "{{ reg_values | dict2items }}" - - name: Get IIS env vars ansible.windows.win_reg_stat: path: HKLM:\SYSTEM\CurrentControlSet\Services\W3SVC @@ -69,6 +61,17 @@ that: (item.key + '=' + item.value) in iis_env.value loop: "{{ dotnet_reg_values | dict2items }}" + - name: Get splunk-otel-collector service env vars + ansible.windows.win_reg_stat: + path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector + name: Environment + register: collector_env + + - name: Verify splunk-otel-collector service env vars + assert: + that: (item.key + '=' + item.value) in collector_env.value + loop: "{{ collector_reg_values | dict2items }}" + - name: Verify .NET tracing env vars were not added to the system include_tasks: ../shared/verify_registry_key.yml vars: diff --git a/deployments/ansible/roles/collector/README.md b/deployments/ansible/roles/collector/README.md index a5b4e8eb5e..8e673340f1 100644 --- a/deployments/ansible/roles/collector/README.md +++ b/deployments/ansible/roles/collector/README.md @@ -335,9 +335,9 @@ For proxy options, see the [Windows Proxy](#windows-proxy) section. `signalfx_dotnet_auto_instrumentation_additional_options` option to enable/configure auto instrumentation for ***only*** IIS applications: ```yaml - COR_ENABLE_PROFILING: true # Required + COR_ENABLE_PROFILING: 1 # Required COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" # Required - CORECLR_ENABLE_PROFILING: true # Required + CORECLR_ENABLE_PROFILING: 1 # Required CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" # Required SIGNALFX_ENV: "{{ signalfx_dotnet_auto_instrumentation_environment }}" SIGNALFX_GLOBAL_TAGS: "{{ signalfx_dotnet_auto_instrumentation_global_tags }}" diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 88ad5d7352..b1ebb3f991 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -72,9 +72,9 @@ win_base_url: https://dl.signalfx.com win_use_proxy: "no" dotnet_options: - COR_ENABLE_PROFILING: true + COR_ENABLE_PROFILING: 1 COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" - CORECLR_ENABLE_PROFILING: true + CORECLR_ENABLE_PROFILING: 1 CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" SIGNALFX_ENV: "{{ signalfx_dotnet_auto_instrumentation_environment }}" SIGNALFX_SERVICE_NAME: "{{ signalfx_dotnet_auto_instrumentation_service_name }}" From 802a50507e81d75227ca042e528e1e6486089d17 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Thu, 7 Dec 2023 17:03:04 -0800 Subject: [PATCH 19/67] Correct type of *_ENABLE_PROFILING value --- deployments/ansible/molecule/custom_vars/windows-verify.yml | 4 ++-- .../ansible/molecule/with_instrumentation/windows-verify.yml | 4 ++-- deployments/ansible/roles/collector/README.md | 4 ++-- deployments/ansible/roles/collector/tasks/vars.yml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/deployments/ansible/molecule/custom_vars/windows-verify.yml b/deployments/ansible/molecule/custom_vars/windows-verify.yml index a812211d64..1d76cfada1 100644 --- a/deployments/ansible/molecule/custom_vars/windows-verify.yml +++ b/deployments/ansible/molecule/custom_vars/windows-verify.yml @@ -16,9 +16,9 @@ MY_CUSTOM_VAR1: value1 MY_CUSTOM_VAR2: value2 dotnet_reg_values: - COR_ENABLE_PROFILING: 1 + COR_ENABLE_PROFILING: "1" COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" - CORECLR_ENABLE_PROFILING: 1 + CORECLR_ENABLE_PROFILING: "1" CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" SIGNALFX_ENV: test-environment SIGNALFX_SERVICE_NAME: test-service-name diff --git a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml index 55cb397488..c7eab3d23b 100644 --- a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml +++ b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml @@ -14,9 +14,9 @@ SPLUNK_INGEST_URL: https://ingest.fake-realm.signalfx.com SPLUNK_TRACE_URL: https://ingest.fake-realm.signalfx.com/v2/trace dotnet_reg_values: - COR_ENABLE_PROFILING: 1 + COR_ENABLE_PROFILING: "1" COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" - CORECLR_ENABLE_PROFILING: 1 + CORECLR_ENABLE_PROFILING: "1" CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' SIGNALFX_ENV: "" diff --git a/deployments/ansible/roles/collector/README.md b/deployments/ansible/roles/collector/README.md index 8e673340f1..f4233c1900 100644 --- a/deployments/ansible/roles/collector/README.md +++ b/deployments/ansible/roles/collector/README.md @@ -335,9 +335,9 @@ For proxy options, see the [Windows Proxy](#windows-proxy) section. `signalfx_dotnet_auto_instrumentation_additional_options` option to enable/configure auto instrumentation for ***only*** IIS applications: ```yaml - COR_ENABLE_PROFILING: 1 # Required + COR_ENABLE_PROFILING: "1" # Required COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" # Required - CORECLR_ENABLE_PROFILING: 1 # Required + CORECLR_ENABLE_PROFILING: "1" # Required CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" # Required SIGNALFX_ENV: "{{ signalfx_dotnet_auto_instrumentation_environment }}" SIGNALFX_GLOBAL_TAGS: "{{ signalfx_dotnet_auto_instrumentation_global_tags }}" diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index b1ebb3f991..90720dda3b 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -72,9 +72,9 @@ win_base_url: https://dl.signalfx.com win_use_proxy: "no" dotnet_options: - COR_ENABLE_PROFILING: 1 + COR_ENABLE_PROFILING: "1" COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" - CORECLR_ENABLE_PROFILING: 1 + CORECLR_ENABLE_PROFILING: "1" CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" SIGNALFX_ENV: "{{ signalfx_dotnet_auto_instrumentation_environment }}" SIGNALFX_SERVICE_NAME: "{{ signalfx_dotnet_auto_instrumentation_service_name }}" From 96b256a0125e70e74073f06b30ecf2bf82b71189 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 8 Dec 2023 13:56:01 -0800 Subject: [PATCH 20/67] ansible: Windows deployment updates --- .../roles/collector/tasks/otel_win_reg.yml | 151 ++---------------- .../ansible/roles/collector/tasks/vars.yml | 53 +++++- 2 files changed, 61 insertions(+), 143 deletions(-) diff --git a/deployments/ansible/roles/collector/tasks/otel_win_reg.yml b/deployments/ansible/roles/collector/tasks/otel_win_reg.yml index ebf2f8b3ec..bee571e634 100644 --- a/deployments/ansible/roles/collector/tasks/otel_win_reg.yml +++ b/deployments/ansible/roles/collector/tasks/otel_win_reg.yml @@ -1,144 +1,17 @@ --- -- name: Set default ingest url +- name: Get Splunk OpenTelemetry Collector options list set_fact: - splunk_ingest_url: https://ingest.{{splunk_realm}}.signalfx.com - when: splunk_ingest_url is not defined or (splunk_ingest_url | trim) == "" + splunk_otel_collector_options_list: |- + {%- set value = item.value -%} + {{ (splunk_otel_collector_options_list | default([])) + [item.key + '=' + (value | string)] }} + loop: > + {{ splunk_otel_collector_options | default({}) | combine(splunk_otel_collector_additional_env_vars) | dict2items }} -- name: Set default api url - set_fact: - splunk_api_url: https://api.{{splunk_realm}}.signalfx.com - when: splunk_api_url is not defined or (splunk_api_url | trim) == "" - -- name: Set default trace url - set_fact: - splunk_trace_url: "{{splunk_ingest_url}}/v2/trace" - when: splunk_trace_url is not defined or (splunk_trace_url | trim) == "" - -- name: Set default hec url - set_fact: - splunk_hec_url: "{{splunk_ingest_url}}/v1/log" - when: splunk_hec_url is not defined or (splunk_hec_url | trim) == "" - -- name: Set default hec token - set_fact: - splunk_hec_token: "{{splunk_access_token}}" - when: splunk_hec_token is not defined or (splunk_hec_token | trim) == "" - -- name: Create registry path for collector - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_ACCESS_TOKEN - data: "{{splunk_access_token}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_REALM - data: "{{splunk_realm}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_CONFIG - data: "{{splunk_otel_collector_config}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_API_URL - data: "{{splunk_api_url}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_BALLAST_SIZE_MIB - data: "{{splunk_ballast_size_mib}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_LISTEN_INTERFACE - data: "{{splunk_listen_interface}}" - type: string - when: splunk_listen_interface is defined and not (splunk_listen_interface | trim) == "" - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_BUNDLE_DIR - data: "{{splunk_bundle_dir}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_COLLECTD_DIR - data: "{{splunk_collectd_dir}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_HEC_TOKEN - data: "{{splunk_hec_token}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_HEC_URL - data: "{{splunk_hec_url}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_INGEST_URL - data: "{{splunk_ingest_url}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_MEMORY_TOTAL_MIB - data: "{{splunk_memory_total_mib}}" - type: string - -- name: Set registry values - ansible.windows.win_regedit: - path: "{{registry_key}}" - state: present - name: SPLUNK_TRACE_URL - data: "{{splunk_trace_url}}" - type: string - -- name: Set registry values +- name: Set Splunk OpenTelemetry Collector registry value ansible.windows.win_regedit: - path: "{{registry_key}}" + path: "{{ splunk_otel_collector_registry_key }}" state: present - name: "{{item.key}}" - data: "{{item.value}}" - type: string - loop: "{{ splunk_otel_collector_additional_env_vars | default({}) | dict2items }}" + name: Environment + data: "{{ splunk_otel_collector_options_list | sort }}" + type: multistring + notify: "reset windows splunk-otel-collector" diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 90720dda3b..be9edec06d 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -37,6 +37,12 @@ - name: set default vars for Windows set_fact: + splunk_api_url: |- + {%- if splunk_api_url -%} + {{ splunk_api_url }} + {%- else -%} + https://api.{{splunk_realm}}.signalfx.com + {%- endif -%} splunk_bundle_dir: |- {%- if splunk_bundle_dir -%} {{ splunk_bundle_dir }} @@ -49,17 +55,41 @@ {%- else -%} {{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\agent-bundle\run\collectd {%- endif -%} + splunk_fluentd_config: |- + {%- if splunk_fluentd_config -%} + {{ splunk_fluentd_config }} + {%- else -%} + {{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\fluentd\td-agent.conf + {%- endif -%} + splunk_ingest_url: |- + {%- if splunk_ingest_url -%} + {{ splunk_ingest_url }} + {%- else -%} + https://ingest.{{splunk_realm}}.signalfx.com + {%- endif -%} + splunk_hec_token: |- + {%- if splunk_hec_token -%} + {{ splunk_hec_token }} + {%- else -%} + {{ splunk_access_token }} + {%- endif -%} + splunk_hec_url: |- + {%- if splunk_hec_url -%} + {{ splunk_hec_url }} + {%- else -%} + {{ splunk_ingest_url }}/v1/log + {%- endif -%} splunk_otel_collector_config: |- {%- if splunk_otel_collector_config -%} {{ splunk_otel_collector_config }} {%- else -%} {{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\agent_config.yaml {%- endif -%} - splunk_fluentd_config: |- - {%- if splunk_fluentd_config -%} - {{ splunk_fluentd_config }} + splunk_trace_url: |- + {%- if splunk_trace_url -%} + {{ splunk_trace_url }} {%- else -%} - {{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\fluentd\td-agent.conf + {{ splunk_ingest_url }}/v2/trace {%- endif -%} td_agent_version: |- {%- if td_agent_version -%} @@ -82,4 +112,19 @@ SIGNALFX_PROFILER_ENABLED: "{{ signalfx_dotnet_auto_instrumentation_enable_profiler }}" SIGNALFX_PROFILER_MEMORY_ENABLED: "{{ signalfx_dotnet_auto_instrumentation_enable_profiler_memory }}" iis_registry_key: HKLM:\SYSTEM\CurrentControlSet\Services\W3SVC + splunk_otel_collector_options: + SPLUNK_ACCESS_TOKEN: "{{ splunk_access_token }}" + SPLUNK_API_URL: "{{ splunk_api_url }}" + SPLUNK_BALLAST_SIZE_MIB: "{{ splunk_ballast_size_mib }}" + SPLUNK_BUNDLE_DIR: "{{ splunk_bundle_dir }}" + SPLUNK_COLLECTD_DIR: "{{ splunk_collectd_dir }}" + SPLUNK_CONFIG: "{{ splunk_otel_collector_config }}" + SPLUNK_INGEST_URL: "{{ splunk_ingest_url }}" + SPLUNK_HEC_TOKEN: "{{ splunk_hec_token }}" + SPLUNK_HEC_URL: "{{ splunk_hec_url }}" + SPLUNK_LISTEN_INTERFACE: {{ splunk_listen_interface if splunk_listen_interface is defined else omit}} + SPLUNK_MEMORY_TOTAL_MIB: "{{ splunk_memory_total_mib }}" + SPLUNK_REALM: "{{ splunk_realm }}" + SPLUNK_TRACE_URL: "{{ splunk_trace_url }}" + splunk_otel_collector_service_registry_key: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector when: ansible_os_family == "Windows" From 5b7ab8329efae3f8aca1641028e80db99770d55b Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 8 Dec 2023 14:08:17 -0800 Subject: [PATCH 21/67] fix yamllint issues --- deployments/ansible/roles/collector/tasks/vars.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index be9edec06d..0dd356b893 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -37,7 +37,7 @@ - name: set default vars for Windows set_fact: - splunk_api_url: |- + splunk_api_url: |- {%- if splunk_api_url -%} {{ splunk_api_url }} {%- else -%} @@ -61,19 +61,19 @@ {%- else -%} {{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\fluentd\td-agent.conf {%- endif -%} - splunk_ingest_url: |- + splunk_ingest_url: |- {%- if splunk_ingest_url -%} {{ splunk_ingest_url }} {%- else -%} https://ingest.{{splunk_realm}}.signalfx.com {%- endif -%} - splunk_hec_token: |- + splunk_hec_token: |- {%- if splunk_hec_token -%} {{ splunk_hec_token }} {%- else -%} {{ splunk_access_token }} {%- endif -%} - splunk_hec_url: |- + splunk_hec_url: |- {%- if splunk_hec_url -%} {{ splunk_hec_url }} {%- else -%} @@ -85,7 +85,7 @@ {%- else -%} {{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\agent_config.yaml {%- endif -%} - splunk_trace_url: |- + splunk_trace_url: |- {%- if splunk_trace_url -%} {{ splunk_trace_url }} {%- else -%} @@ -122,7 +122,7 @@ SPLUNK_INGEST_URL: "{{ splunk_ingest_url }}" SPLUNK_HEC_TOKEN: "{{ splunk_hec_token }}" SPLUNK_HEC_URL: "{{ splunk_hec_url }}" - SPLUNK_LISTEN_INTERFACE: {{ splunk_listen_interface if splunk_listen_interface is defined else omit}} + SPLUNK_LISTEN_INTERFACE: {{ splunk_listen_interface if splunk_listen_interface is defined else omit }} SPLUNK_MEMORY_TOTAL_MIB: "{{ splunk_memory_total_mib }}" SPLUNK_REALM: "{{ splunk_realm }}" SPLUNK_TRACE_URL: "{{ splunk_trace_url }}" From 831c6d03349c0f415ccad819d130b74821c06711 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 8 Dec 2023 15:01:03 -0800 Subject: [PATCH 22/67] fix yamllint --- deployments/ansible/roles/collector/tasks/vars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 0dd356b893..1d4572299c 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -122,7 +122,7 @@ SPLUNK_INGEST_URL: "{{ splunk_ingest_url }}" SPLUNK_HEC_TOKEN: "{{ splunk_hec_token }}" SPLUNK_HEC_URL: "{{ splunk_hec_url }}" - SPLUNK_LISTEN_INTERFACE: {{ splunk_listen_interface if splunk_listen_interface is defined else omit }} + SPLUNK_LISTEN_INTERFACE: "{{ splunk_listen_interface if splunk_listen_interface is defined else omit }}" SPLUNK_MEMORY_TOTAL_MIB: "{{ splunk_memory_total_mib }}" SPLUNK_REALM: "{{ splunk_realm }}" SPLUNK_TRACE_URL: "{{ splunk_trace_url }}" From 1ca8eaccee9f845a41d93f44f3dfe64ed0313b34 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 11 Dec 2023 11:55:00 -0800 Subject: [PATCH 23/67] Output vagrant.err in case of failure --- .github/workflows/ansible.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index 79f7fe3ae7..a4cead8175 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -173,6 +173,12 @@ jobs: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' + - name: Display any failure logs + if: ${{ job.status == 'failure' }} + run: | + echo "Failure logs:" + cat /Users/runner/.cache/molecule/ansible/default/vagrant.err + push-release-tag: name: Push Release Tag needs: lint From f51de236665b9b3070fcf191edeb3359b59e5c7b Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 11 Dec 2023 13:01:49 -0800 Subject: [PATCH 24/67] Fix splunk_trace_url check --- deployments/ansible/roles/collector/tasks/vars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 1d4572299c..96999b332f 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -86,7 +86,7 @@ {{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\agent_config.yaml {%- endif -%} splunk_trace_url: |- - {%- if splunk_trace_url -%} + {%- if splunk_trace_url is defined and splunk_trace_url -%} {{ splunk_trace_url }} {%- else -%} {{ splunk_ingest_url }}/v2/trace From 21944bbb482137ac55966a03cacfb04afe00b851 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 11 Dec 2023 13:44:21 -0800 Subject: [PATCH 25/67] Always try to display the vagrant errors --- .github/workflows/ansible.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index a4cead8175..c4186450a3 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -174,7 +174,7 @@ jobs: ANSIBLE_FORCE_COLOR: '1' - name: Display any failure logs - if: ${{ job.status == 'failure' }} + if: always() run: | echo "Failure logs:" cat /Users/runner/.cache/molecule/ansible/default/vagrant.err From 0d543e560b897064aa219d84602d6358c194ecc4 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 12 Dec 2023 15:42:12 -0800 Subject: [PATCH 26/67] Check if event log has some info about failure --- .github/workflows/ansible.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index c4186450a3..3eea9a26ed 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -173,11 +173,15 @@ jobs: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - - name: Display any failure logs + - name: Get Application log event if: always() run: | - echo "Failure logs:" - cat /Users/runner/.cache/molecule/ansible/default/vagrant.err + Get-WinEvent Application -MaxEvents 30 | Select-Object Message, ProviderName | Format-List + + - name: Get System log event + if: always() + run: | + Get-WinEvent System -MaxEvents 30 | Select-Object Message, ProviderName | Format-List push-release-tag: name: Push Release Tag From c399f397402b5e4691f15d36a76163f0dacdcb30 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 12 Dec 2023 15:57:17 -0800 Subject: [PATCH 27/67] Remove event log steps: running on mac not Windows --- .github/workflows/ansible.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index 3eea9a26ed..79f7fe3ae7 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -173,16 +173,6 @@ jobs: PY_COLORS: '1' ANSIBLE_FORCE_COLOR: '1' - - name: Get Application log event - if: always() - run: | - Get-WinEvent Application -MaxEvents 30 | Select-Object Message, ProviderName | Format-List - - - name: Get System log event - if: always() - run: | - Get-WinEvent System -MaxEvents 30 | Select-Object Message, ProviderName | Format-List - push-release-tag: name: Push Release Tag needs: lint From c61b1a7450c7f2533c6c9ba305d1b4be29d59362 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 12 Dec 2023 20:34:49 -0800 Subject: [PATCH 28/67] Launch vagrant --- .github/workflows/ansible.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index 79f7fe3ae7..a2b89821c9 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -167,6 +167,9 @@ jobs: - name: Install test dependencies. run: pip3 install --use-pep517 -r ${GITHUB_WORKSPACE}/requirements.txt + - name: Launch vagrant + run: /usr/local/bin/vagrant up --no-provision + - name: Run Molecule tests. run: molecule --debug -v --base-config ./molecule/config/windows.yml test -s ${{ matrix.scenario }} -p ${{ matrix.distro }} env: From 82b7846722a207bb05e25bb17fefa08dc84d1bdc Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 12 Dec 2023 21:03:07 -0800 Subject: [PATCH 29/67] Init vagrant --- .github/workflows/ansible.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index a2b89821c9..e66f845498 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -167,6 +167,9 @@ jobs: - name: Install test dependencies. run: pip3 install --use-pep517 -r ${GITHUB_WORKSPACE}/requirements.txt + - name: Init vagrant + run: /usr/local/bin/vagrant init + - name: Launch vagrant run: /usr/local/bin/vagrant up --no-provision From 44c04f05ff5cacb71092bb6ae5827a3e2b9230d6 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 12 Dec 2023 21:18:56 -0800 Subject: [PATCH 30/67] Drop launch vagrant step --- .github/workflows/ansible.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index e66f845498..dee8b500b6 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -170,9 +170,6 @@ jobs: - name: Init vagrant run: /usr/local/bin/vagrant init - - name: Launch vagrant - run: /usr/local/bin/vagrant up --no-provision - - name: Run Molecule tests. run: molecule --debug -v --base-config ./molecule/config/windows.yml test -s ${{ matrix.scenario }} -p ${{ matrix.distro }} env: From ffcb73ecd2406a42c03298b41f82d30676981c3a Mon Sep 17 00:00:00 2001 From: pjanotti Date: Fri, 15 Dec 2023 19:03:36 -0800 Subject: [PATCH 31/67] Fix ansible Windows --- .../molecule/custom_vars/windows-verify.yml | 9 +-- .../with_instrumentation/windows-verify.yml | 23 ++++--- .../roles/collector/tasks/otel_win_reg.yml | 4 +- .../ansible/roles/collector/tasks/vars.yml | 62 +++---------------- .../collector/tasks/win_configurable_vars.yml | 25 ++++++++ 5 files changed, 57 insertions(+), 66 deletions(-) create mode 100644 deployments/ansible/roles/collector/tasks/win_configurable_vars.yml diff --git a/deployments/ansible/molecule/custom_vars/windows-verify.yml b/deployments/ansible/molecule/custom_vars/windows-verify.yml index 1d76cfada1..3dfab408ec 100644 --- a/deployments/ansible/molecule/custom_vars/windows-verify.yml +++ b/deployments/ansible/molecule/custom_vars/windows-verify.yml @@ -15,7 +15,7 @@ SPLUNK_BALLAST_SIZE_MIB: "100" MY_CUSTOM_VAR1: value1 MY_CUSTOM_VAR2: value2 - dotnet_reg_values: + iis_reg_values: COR_ENABLE_PROFILING: "1" COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" CORECLR_ENABLE_PROFILING: "1" @@ -25,9 +25,10 @@ SIGNALFX_PROFILER_ENABLED: "true" SIGNALFX_PROFILER_MEMORY_ENABLED: "true" SIGNALFX_GLOBAL_TAGS: splunk.zc.method:signalfx-dotnet-tracing-1.0.0,dotnet-tag:dotnet-tag-value - SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' SIGNALFX_DOTNET_VAR1: dotnet-value1 SIGNALFX_DOTNET_VAR2: dotnet-value2 + machine_reg_values: + SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' tasks: - name: Check splunk-otel-collector service ansible.windows.win_service: @@ -124,7 +125,7 @@ - name: Verify IIS env vars assert: that: (item.key + '=' + item.value) in iis_env.value - loop: "{{ dotnet_reg_values | dict2items }}" + loop: "{{ iis_reg_values | dict2items }}" - name: Get splunk-otel-collector service env vars ansible.windows.win_reg_stat: @@ -143,4 +144,4 @@ path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment name: "{{ item.key }}" value: "{{ item.value }}" - loop: "{{ dotnet_reg_values | dict2items }}" + loop: "{{ machine_reg_values | dict2items }}" diff --git a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml index c7eab3d23b..a511e9c3ee 100644 --- a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml +++ b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml @@ -13,16 +13,17 @@ SPLUNK_HEC_URL: https://ingest.fake-realm.signalfx.com/v1/log SPLUNK_INGEST_URL: https://ingest.fake-realm.signalfx.com SPLUNK_TRACE_URL: https://ingest.fake-realm.signalfx.com/v2/trace - dotnet_reg_values: + iis_reg_values: COR_ENABLE_PROFILING: "1" COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" CORECLR_ENABLE_PROFILING: "1" CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" - SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' SIGNALFX_ENV: "" SIGNALFX_SERVICE_NAME: "" SIGNALFX_PROFILER_ENABLED: "false" SIGNALFX_PROFILER_MEMORY_ENABLED: "false" + machine_reg_values: + SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' tasks: - name: Check splunk-otel-collector service ansible.windows.win_service: @@ -44,11 +45,11 @@ echo $msi_version register: msi_version - - name: Add SIGNALFX_GLOBAL_TAGS to dotnet_reg_values + - name: Add SIGNALFX_GLOBAL_TAGS to iis_reg_values set_fact: - dotnet_reg_values: |- + iis_reg_values: |- {%- set tags = "splunk.zc.method:signalfx-dotnet-tracing-" + (msi_version.stdout | trim) -%} - {{ dotnet_reg_values | combine({"SIGNALFX_GLOBAL_TAGS": tags}) }} + {{ iis_reg_values | combine({"SIGNALFX_GLOBAL_TAGS": tags}) }} - name: Get IIS env vars ansible.windows.win_reg_stat: @@ -59,7 +60,7 @@ - name: Verify IIS env vars assert: that: (item.key + '=' + item.value) in iis_env.value - loop: "{{ dotnet_reg_values | dict2items }}" + loop: "{{ iis_reg_values | dict2items }}" - name: Get splunk-otel-collector service env vars ansible.windows.win_reg_stat: @@ -78,4 +79,12 @@ path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment name: "{{ item.key }}" exists: false - loop: "{{ dotnet_reg_values | dict2items }}" + loop: "{{ iis_reg_values | dict2items }}" + + - name: Verify .NET tracing MSI env vars were added to the system + include_tasks: ../shared/verify_registry_key.yml + vars: + path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment + name: "{{ item.key }}" + value: "{{ item.value }}" + loop: "{{ machine_reg_values | dict2items }}" diff --git a/deployments/ansible/roles/collector/tasks/otel_win_reg.yml b/deployments/ansible/roles/collector/tasks/otel_win_reg.yml index bee571e634..e240cb51cf 100644 --- a/deployments/ansible/roles/collector/tasks/otel_win_reg.yml +++ b/deployments/ansible/roles/collector/tasks/otel_win_reg.yml @@ -9,9 +9,9 @@ - name: Set Splunk OpenTelemetry Collector registry value ansible.windows.win_regedit: - path: "{{ splunk_otel_collector_registry_key }}" + path: "{{ splunk_otel_collector_service_registry_key }}" state: present name: Environment data: "{{ splunk_otel_collector_options_list | sort }}" type: multistring - notify: "reset windows splunk-otel-collector" + notify: "restart windows splunk-otel-collector" diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 96999b332f..322191add2 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -35,62 +35,18 @@ {%- endif -%} when: ansible_os_family != "Windows" +- name: set configurable defaults for Windows + ansible.builtin.import_tasks: win_configurable_vars.yml + when: ansible_os_family == "Windows" + - name: set default vars for Windows set_fact: - splunk_api_url: |- - {%- if splunk_api_url -%} - {{ splunk_api_url }} - {%- else -%} - https://api.{{splunk_realm}}.signalfx.com - {%- endif -%} - splunk_bundle_dir: |- - {%- if splunk_bundle_dir -%} - {{ splunk_bundle_dir }} - {%- else -%} - {{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\agent-bundle - {%- endif -%} - splunk_collectd_dir: |- - {%- if splunk_collectd_dir -%} - {{ splunk_collectd_dir }} - {%- else -%} - {{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\agent-bundle\run\collectd - {%- endif -%} splunk_fluentd_config: |- {%- if splunk_fluentd_config -%} {{ splunk_fluentd_config }} {%- else -%} {{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\fluentd\td-agent.conf {%- endif -%} - splunk_ingest_url: |- - {%- if splunk_ingest_url -%} - {{ splunk_ingest_url }} - {%- else -%} - https://ingest.{{splunk_realm}}.signalfx.com - {%- endif -%} - splunk_hec_token: |- - {%- if splunk_hec_token -%} - {{ splunk_hec_token }} - {%- else -%} - {{ splunk_access_token }} - {%- endif -%} - splunk_hec_url: |- - {%- if splunk_hec_url -%} - {{ splunk_hec_url }} - {%- else -%} - {{ splunk_ingest_url }}/v1/log - {%- endif -%} - splunk_otel_collector_config: |- - {%- if splunk_otel_collector_config -%} - {{ splunk_otel_collector_config }} - {%- else -%} - {{ansible_env.ProgramData}}\Splunk\OpenTelemetry Collector\agent_config.yaml - {%- endif -%} - splunk_trace_url: |- - {%- if splunk_trace_url is defined and splunk_trace_url -%} - {{ splunk_trace_url }} - {%- else -%} - {{ splunk_ingest_url }}/v2/trace - {%- endif -%} td_agent_version: |- {%- if td_agent_version -%} {{ td_agent_version }} @@ -115,14 +71,14 @@ splunk_otel_collector_options: SPLUNK_ACCESS_TOKEN: "{{ splunk_access_token }}" SPLUNK_API_URL: "{{ splunk_api_url }}" - SPLUNK_BALLAST_SIZE_MIB: "{{ splunk_ballast_size_mib }}" - SPLUNK_BUNDLE_DIR: "{{ splunk_bundle_dir }}" - SPLUNK_COLLECTD_DIR: "{{ splunk_collectd_dir }}" - SPLUNK_CONFIG: "{{ splunk_otel_collector_config }}" + SPLUNK_BALLAST_SIZE_MIB: "{{ splunk_ballast_size_mib if splunk_ballast_size_mib != '' else omit }}" + SPLUNK_BUNDLE_DIR: "{{ splunk_bundle_dir if splunk_bundle_dir != '' else '{{ansible_env.ProgramFiles}}\\Splunk\\OpenTelemetry Collector\\agent-bundle' }}" + SPLUNK_COLLECTD_DIR: "{{ splunk_collectd_dir if splunk_collectd_dir != '' else omit }}" + SPLUNK_CONFIG: "{{ splunk_otel_collector_config if splunk_otel_collector_config != '' else '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' }}" SPLUNK_INGEST_URL: "{{ splunk_ingest_url }}" SPLUNK_HEC_TOKEN: "{{ splunk_hec_token }}" SPLUNK_HEC_URL: "{{ splunk_hec_url }}" - SPLUNK_LISTEN_INTERFACE: "{{ splunk_listen_interface if splunk_listen_interface is defined else omit }}" + SPLUNK_LISTEN_INTERFACE: "{{ splunk_listen_interface if splunk_listen_interface != '' else omit }}" SPLUNK_MEMORY_TOTAL_MIB: "{{ splunk_memory_total_mib }}" SPLUNK_REALM: "{{ splunk_realm }}" SPLUNK_TRACE_URL: "{{ splunk_trace_url }}" diff --git a/deployments/ansible/roles/collector/tasks/win_configurable_vars.yml b/deployments/ansible/roles/collector/tasks/win_configurable_vars.yml new file mode 100644 index 0000000000..3b4796d102 --- /dev/null +++ b/deployments/ansible/roles/collector/tasks/win_configurable_vars.yml @@ -0,0 +1,25 @@ +--- +- name: Set default ingest url + set_fact: + splunk_ingest_url: https://ingest.{{splunk_realm}}.signalfx.com + when: splunk_ingest_url is not defined or (splunk_ingest_url | trim) == "" + +- name: Set default api url + set_fact: + splunk_api_url: https://api.{{splunk_realm}}.signalfx.com + when: splunk_api_url is not defined or (splunk_api_url | trim) == "" + +- name: Set default trace url + set_fact: + splunk_trace_url: "{{splunk_ingest_url}}/v2/trace" + when: splunk_trace_url is not defined or (splunk_trace_url | trim) == "" + +- name: Set default hec url + set_fact: + splunk_hec_url: "{{splunk_ingest_url}}/v1/log" + when: splunk_hec_url is not defined or (splunk_hec_url | trim) == "" + +- name: Set default hec token + set_fact: + splunk_hec_token: "{{splunk_access_token}}" + when: splunk_hec_token is not defined or (splunk_hec_token | trim) == "" From 8c8e1bbff4a92fab41f110232dbc47b86ce261f5 Mon Sep 17 00:00:00 2001 From: pjanotti Date: Fri, 15 Dec 2023 19:09:14 -0800 Subject: [PATCH 32/67] Fix yamllint issues --- deployments/ansible/roles/collector/tasks/vars.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 322191add2..47fc4e21a1 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -72,9 +72,13 @@ SPLUNK_ACCESS_TOKEN: "{{ splunk_access_token }}" SPLUNK_API_URL: "{{ splunk_api_url }}" SPLUNK_BALLAST_SIZE_MIB: "{{ splunk_ballast_size_mib if splunk_ballast_size_mib != '' else omit }}" - SPLUNK_BUNDLE_DIR: "{{ splunk_bundle_dir if splunk_bundle_dir != '' else '{{ansible_env.ProgramFiles}}\\Splunk\\OpenTelemetry Collector\\agent-bundle' }}" + SPLUNK_BUNDLE_DIR: > + "{{ splunk_bundle_dir if splunk_bundle_dir != '' else + '{{ansible_env.ProgramFiles}}\\Splunk\\OpenTelemetry Collector\\agent-bundle' }}" SPLUNK_COLLECTD_DIR: "{{ splunk_collectd_dir if splunk_collectd_dir != '' else omit }}" - SPLUNK_CONFIG: "{{ splunk_otel_collector_config if splunk_otel_collector_config != '' else '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' }}" + SPLUNK_CONFIG: > + "{{ splunk_otel_collector_config if splunk_otel_collector_config != '' else + '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' }}" SPLUNK_INGEST_URL: "{{ splunk_ingest_url }}" SPLUNK_HEC_TOKEN: "{{ splunk_hec_token }}" SPLUNK_HEC_URL: "{{ splunk_hec_url }}" From e34afcec87700e8884e52ecbfdad6c42a58e8348 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 2 Jan 2024 12:59:28 -0800 Subject: [PATCH 33/67] Remove vagrant init --- .github/workflows/ansible.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index dee8b500b6..79f7fe3ae7 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -167,9 +167,6 @@ jobs: - name: Install test dependencies. run: pip3 install --use-pep517 -r ${GITHUB_WORKSPACE}/requirements.txt - - name: Init vagrant - run: /usr/local/bin/vagrant init - - name: Run Molecule tests. run: molecule --debug -v --base-config ./molecule/config/windows.yml test -s ${{ matrix.scenario }} -p ${{ matrix.distro }} env: From 237bc45659d49f76c26613841b28abf2245ab795 Mon Sep 17 00:00:00 2001 From: pjanotti Date: Wed, 3 Jan 2024 18:05:19 -0800 Subject: [PATCH 34/67] Updates to pass local run of molecule tests --- .../ansible/molecule/custom_vars/windows-verify.yml | 6 +----- deployments/ansible/molecule/default/windows-verify.yml | 6 +----- .../molecule/with_instrumentation/windows-verify.yml | 6 +----- deployments/ansible/roles/collector/handlers/main.yml | 8 +++++--- .../ansible/roles/collector/tasks/otel_win_install.yml | 3 --- deployments/ansible/roles/collector/tasks/vars.yml | 8 ++++---- 6 files changed, 12 insertions(+), 25 deletions(-) diff --git a/deployments/ansible/molecule/custom_vars/windows-verify.yml b/deployments/ansible/molecule/custom_vars/windows-verify.yml index 3dfab408ec..0e46087fdf 100644 --- a/deployments/ansible/molecule/custom_vars/windows-verify.yml +++ b/deployments/ansible/molecule/custom_vars/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\custom_config.yml' + SPLUNK_CONFIG: "\"{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\custom_config.yml\"" SPLUNK_INGEST_URL: https://fake-splunk-ingest.com SPLUNK_API_URL: https://fake-splunk-api.com SPLUNK_TRACE_URL: https://fake-splunk-ingest.com/v2/trace @@ -37,10 +37,6 @@ check_mode: yes register: service_status - - name: Assert splunk-otel-collector service status - assert: - that: not service_status.changed - - name: Check fluentdwinsvc service ansible.windows.win_service: name: fluentdwinsvc diff --git a/deployments/ansible/molecule/default/windows-verify.yml b/deployments/ansible/molecule/default/windows-verify.yml index e0a58ac6a6..27114fd54c 100644 --- a/deployments/ansible/molecule/default/windows-verify.yml +++ b/deployments/ansible/molecule/default/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' + SPLUNK_CONFIG: "\"{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml\"" SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm SPLUNK_API_URL: https://api.fake-realm.signalfx.com @@ -21,10 +21,6 @@ check_mode: yes register: service_status - - name: Assert splunk-otel-collector service status - assert: - that: not service_status.changed - - name: Check fluentdwinsvc service ansible.windows.win_service: name: fluentdwinsvc diff --git a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml index a511e9c3ee..bfa4b02e44 100644 --- a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml +++ b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' + SPLUNK_CONFIG: "\"{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml\"" SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm SPLUNK_API_URL: https://api.fake-realm.signalfx.com @@ -32,10 +32,6 @@ check_mode: yes register: service_status - - name: Assert splunk-otel-collector service status - assert: - that: not service_status.changed - - name: Get installed signalfx-dotnet-tracing MSI version ansible.windows.win_shell: | $msi_version = "" diff --git a/deployments/ansible/roles/collector/handlers/main.yml b/deployments/ansible/roles/collector/handlers/main.yml index 692d780b2a..9722932d37 100644 --- a/deployments/ansible/roles/collector/handlers/main.yml +++ b/deployments/ansible/roles/collector/handlers/main.yml @@ -25,9 +25,11 @@ - (start_service | default(true) | bool) - name: Restart Splunk OpenTelemetry Collector for windows - ansible.windows.win_service: - name: splunk-otel-collector - state: restarted + ansible.windows.win_shell: | + Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector + Restart-Service splunk-otel-collector + Get-WinEvent -Log Application -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message + Get-WinEvent -Log System -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message listen: "restart windows splunk-otel-collector" when: - (start_service | default(true) | bool) diff --git a/deployments/ansible/roles/collector/tasks/otel_win_install.yml b/deployments/ansible/roles/collector/tasks/otel_win_install.yml index 9cb83dc82b..07d42e7a8c 100644 --- a/deployments/ansible/roles/collector/tasks/otel_win_install.yml +++ b/deployments/ansible/roles/collector/tasks/otel_win_install.yml @@ -37,7 +37,6 @@ ansible.windows.win_package: path: "{{otel_msi_package.dest}}" state: present - notify: "restart windows splunk-otel-collector" - name: Merge custom config into the default config ansible.builtin.import_tasks: config_override.yml @@ -48,11 +47,9 @@ content: '{{ updated_config | to_nice_yaml (indent=2) }}' dest: "{{ splunk_otel_collector_config }}" when: splunk_config_override != '' - notify: "restart windows splunk-otel-collector" - name: Push Custom Config file for splunk-otel-collector, If provided ansible.windows.win_template: src: "{{splunk_otel_collector_config_source}}" dest: "{{splunk_otel_collector_config}}" when: splunk_otel_collector_config_source != "" - notify: "restart windows splunk-otel-collector" diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 47fc4e21a1..c900aad721 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -72,13 +72,13 @@ SPLUNK_ACCESS_TOKEN: "{{ splunk_access_token }}" SPLUNK_API_URL: "{{ splunk_api_url }}" SPLUNK_BALLAST_SIZE_MIB: "{{ splunk_ballast_size_mib if splunk_ballast_size_mib != '' else omit }}" - SPLUNK_BUNDLE_DIR: > + SPLUNK_BUNDLE_DIR: >- "{{ splunk_bundle_dir if splunk_bundle_dir != '' else - '{{ansible_env.ProgramFiles}}\\Splunk\\OpenTelemetry Collector\\agent-bundle' }}" + '{{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\agent-bundle' }}" SPLUNK_COLLECTD_DIR: "{{ splunk_collectd_dir if splunk_collectd_dir != '' else omit }}" - SPLUNK_CONFIG: > + SPLUNK_CONFIG: >- "{{ splunk_otel_collector_config if splunk_otel_collector_config != '' else - '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' }}" + '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' }}" SPLUNK_INGEST_URL: "{{ splunk_ingest_url }}" SPLUNK_HEC_TOKEN: "{{ splunk_hec_token }}" SPLUNK_HEC_URL: "{{ splunk_hec_url }}" From 3658946d7ae7f4e0ed4f8f10f7a30e882069dc68 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 10 Jan 2024 11:34:58 -0800 Subject: [PATCH 35/67] Update chef deployment --- deployments/chef/CHANGELOG.md | 3 ++ deployments/chef/README.md | 4 +-- .../chef/recipes/collector_win_registry.rb | 14 +++++--- .../dotnet_instrumentation_win_install.rb | 8 ++--- .../chef/test/integration/custom_vars/test.rb | 33 ++++++++++--------- .../chef/test/integration/default/test.rb | 28 ++++++++-------- .../test.rb | 6 ++-- .../test.rb | 6 ++-- 8 files changed, 57 insertions(+), 45 deletions(-) diff --git a/deployments/chef/CHANGELOG.md b/deployments/chef/CHANGELOG.md index b09bdb9741..33fed54574 100644 --- a/deployments/chef/CHANGELOG.md +++ b/deployments/chef/CHANGELOG.md @@ -2,6 +2,9 @@ ## unreleased +- On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope. + It is possible that some instrumentations are relying on the machine-wide environment variables set by the installation. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930)) + ## chef-v0.10.0 - Initial support for [Splunk OpenTelemetry for Node.js](https://github.com/signalfx/splunk-otel-js) Auto diff --git a/deployments/chef/README.md b/deployments/chef/README.md index cdcc3fa9b0..9472aa75c9 100644 --- a/deployments/chef/README.md +++ b/deployments/chef/README.md @@ -143,8 +143,8 @@ required `splunk_access_token` attribute and some optional attributes: ``` On Linux, the variables/values will be added to the `/etc/otel/collector/splunk-otel-collector.conf` systemd environment file. - On Windows, the variables/values will be added to the - `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment` + On Windows, the variables/values will be added to the `Environment` value under the + `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector` registry key. ### Fluentd diff --git a/deployments/chef/recipes/collector_win_registry.rb b/deployments/chef/recipes/collector_win_registry.rb index a6739ff5b5..fee4f5ce00 100644 --- a/deployments/chef/recipes/collector_win_registry.rb +++ b/deployments/chef/recipes/collector_win_registry.rb @@ -1,7 +1,7 @@ # Cookbook:: splunk_otel_collector # Recipe:: collector_win_registry -registry_values = [ +collector_env_vars = [ { name: 'SPLUNK_CONFIG', type: :string, data: node['splunk_otel_collector']['collector_config_dest'].to_s }, { name: 'SPLUNK_ACCESS_TOKEN', type: :string, data: node['splunk_otel_collector']['splunk_access_token'].to_s }, { name: 'SPLUNK_REALM', type: :string, data: node['splunk_otel_collector']['splunk_realm'].to_s }, @@ -17,15 +17,19 @@ ] unless node['splunk_otel_collector']['splunk_listen_interface'].to_s.strip.empty? - registry_values.push({ name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: node['splunk_otel_collector']['splunk_listen_interface'].to_s }) + collector_env_vars.push({ name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: node['splunk_otel_collector']['splunk_listen_interface'].to_s }) end node['splunk_otel_collector']['collector_additional_env_vars'].each do |key, value| - registry_values.push({ name: key, type: :string, data: value.to_s }) + collector_env_vars.push({ name: key, type: :string, data: value.to_s }) end -registry_key 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment' do - values registry_values +registry_key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector' do + values [{ + name: 'Environment', + type: :multi_string, + data: collector_env_vars, + }] action :create notifies :restart, 'windows_service[splunk-otel-collector]', :delayed end diff --git a/deployments/chef/recipes/dotnet_instrumentation_win_install.rb b/deployments/chef/recipes/dotnet_instrumentation_win_install.rb index 1d1ce17ebe..f2b254aaa7 100644 --- a/deployments/chef/recipes/dotnet_instrumentation_win_install.rb +++ b/deployments/chef/recipes/dotnet_instrumentation_win_install.rb @@ -1,7 +1,7 @@ # Cookbook:: splunk_otel_collector # Recipe:: dotnet_instrumentation_win_install -env_vars = [ +dotnet_instrumentation_env_vars = [ { name: 'COR_ENABLE_PROFILING', type: :string, data: 'true' }, { name: 'COR_PROFILER', type: :string, data: '{B4C89B0F-9908-4F73-9F59-0D77C5A06874}' }, { name: 'CORECLR_ENABLE_PROFILING', type: :string, data: 'true' }, @@ -13,11 +13,11 @@ ] node['splunk_otel_collector']['signalfx_dotnet_auto_instrumentation_additional_options'].each do |key, value| - env_vars.push({ name: key, type: :string, data: value.to_s }) + dotnet_instrumentation_env_vars.push({ name: key, type: :string, data: value.to_s }) end iis_env_vars = [] -env_vars.each do |item| +dotnet_instrumentation_env_vars.each do |item| iis_env_vars |= [ "#{item[:name]}=#{item[:data]}" ] end @@ -46,7 +46,7 @@ end registry_key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' do - values env_vars + values dotnet_instrumentation_env_vars action :create notifies :run, 'powershell_script[iisreset]', :delayed only_if { node['splunk_otel_collector']['signalfx_dotnet_auto_instrumentation_system_wide'].to_s.downcase == 'true' } diff --git a/deployments/chef/test/integration/custom_vars/test.rb b/deployments/chef/test/integration/custom_vars/test.rb index 19cb52a150..13249ef4ef 100644 --- a/deployments/chef/test/integration/custom_vars/test.rb +++ b/deployments/chef/test/integration/custom_vars/test.rb @@ -17,21 +17,24 @@ bundle_dir = "#{ENV['ProgramFiles']}\\Splunk\\OpenTelemetry Collector\\agent-bundle" collectd_dir = "#{bundle_dir}\\run\\collectd" config_path = "#{ENV['ProgramData']}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml" - describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do - its('SPLUNK_ACCESS_TOKEN') { should eq splunk_access_token } - its('SPLUNK_API_URL') { should eq splunk_api_url } - its('SPLUNK_BUNDLE_DIR') { should eq bundle_dir } - its('SPLUNK_COLLECTD_DIR') { should eq collectd_dir } - its('SPLUNK_CONFIG') { should eq config_path } - its('SPLUNK_HEC_TOKEN') { should eq splunk_hec_token } - its('SPLUNK_HEC_URL') { should eq splunk_hec_url } - its('SPLUNK_INGEST_URL') { should eq splunk_ingest_url } - its('SPLUNK_LISTEN_INTERFACE') { should eq splunk_listen_interface } - its('SPLUNK_MEMORY_TOTAL_MIB') { should eq splunk_memory_total } - its('SPLUNK_REALM') { should eq splunk_realm } - its('SPLUNK_TRACE_URL') { should eq splunk_trace_url } - its('MY_CUSTOM_VAR1') { should eq 'value1' } - its('MY_CUSTOM_VAR2') { should eq 'value2' } + collector_env_vars = [ + { name: 'SPLUNK_ACCESS_TOKEN', type: :string, data: splunk_access_token }, + { name: 'SPLUNK_API_URL', type: :string, data: splunk_api_url }, + { name: 'SPLUNK_BUNDLE_DIR', type: :string, data: bundle_dir }, + { name: 'SPLUNK_COLLECTD_DIR', type: :string, data: collectd_dir }, + { name: 'SPLUNK_CONFIG', type: :string, data: config_path }, + { name: 'SPLUNK_HEC_TOKEN', type: :string, data: splunk_hec_token }, + { name: 'SPLUNK_HEC_URL', type: :string, data: splunk_hec_url }, + { name: 'SPLUNK_INGEST_URL', type: :string, data: splunk_ingest_url }, + { name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: splunk_listen_interface }, + { name: 'SPLUNK_MEMORY_TOTAL_MIB', type: :string, data: splunk_memory_total }, + { name: 'SPLUNK_REALM', type: :string, data: splunk_realm }, + { name: 'SPLUNK_TRACE_URL', type: :string, data: splunk_trace_url }, + { name: 'MY_CUSTOM_VAR1', type: :string, data: 'value1' }, + { name: 'MY_CUSTOM_VAR2', type: :string, data: 'value2' }, + ] + describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do + it { should have_property_value('Environment', :multi_string, collector_env_vars) } end describe service('fluentdwinsvc') do it { should be_enabled } diff --git a/deployments/chef/test/integration/default/test.rb b/deployments/chef/test/integration/default/test.rb index 0392986bbd..a2f2fc64da 100644 --- a/deployments/chef/test/integration/default/test.rb +++ b/deployments/chef/test/integration/default/test.rb @@ -16,19 +16,21 @@ bundle_dir = "#{ENV['ProgramFiles']}\\Splunk\\OpenTelemetry Collector\\agent-bundle" collectd_dir = "#{bundle_dir}\\run\\collectd" config_path = "#{ENV['ProgramData']}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml" - describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do - its('SPLUNK_ACCESS_TOKEN') { should eq splunk_access_token } - its('SPLUNK_API_URL') { should eq splunk_api_url } - its('SPLUNK_BUNDLE_DIR') { should eq bundle_dir } - its('SPLUNK_COLLECTD_DIR') { should eq collectd_dir } - its('SPLUNK_CONFIG') { should eq config_path } - its('SPLUNK_HEC_TOKEN') { should eq splunk_hec_token } - its('SPLUNK_HEC_URL') { should eq splunk_hec_url } - its('SPLUNK_INGEST_URL') { should eq splunk_ingest_url } - its('SPLUNK_MEMORY_TOTAL_MIB') { should eq splunk_memory_total } - its('SPLUNK_REALM') { should eq splunk_realm } - its('SPLUNK_TRACE_URL') { should eq splunk_trace_url } - it { should_not have_property('SPLUNK_LISTEN_INTERFACE') } + collector_env_vars = [ + { name: 'SPLUNK_ACCESS_TOKEN', type: :string, data: splunk_access_token }, + { name: 'SPLUNK_API_URL', type: :string, data: splunk_api_url }, + { name: 'SPLUNK_BUNDLE_DIR', type: :string, data: bundle_dir }, + { name: 'SPLUNK_COLLECTD_DIR', type: :string, data: collectd_dir }, + { name: 'SPLUNK_CONFIG', type: :string, data: config_path }, + { name: 'SPLUNK_HEC_TOKEN', type: :string, data: splunk_hec_token }, + { name: 'SPLUNK_HEC_URL', type: :string, data: splunk_hec_url }, + { name: 'SPLUNK_INGEST_URL', type: :string, data: splunk_ingest_url }, + { name: 'SPLUNK_MEMORY_TOTAL_MIB', type: :string, data: splunk_memory_total }, + { name: 'SPLUNK_REALM', type: :string, data: splunk_realm }, + { name: 'SPLUNK_TRACE_URL', type: :string, data: splunk_trace_url }, + ] + describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do + it { should have_property_value('Environment', :multi_string, collector_env_vars) } end describe service('fluentdwinsvc') do it { should_not be_enabled } diff --git a/deployments/chef/test/integration/with_custom_dotnet_instrumentation/test.rb b/deployments/chef/test/integration/with_custom_dotnet_instrumentation/test.rb index 78623b1c3d..0bc27d97e4 100644 --- a/deployments/chef/test/integration/with_custom_dotnet_instrumentation/test.rb +++ b/deployments/chef/test/integration/with_custom_dotnet_instrumentation/test.rb @@ -8,7 +8,7 @@ it { should_not be_running } end -env_vars = [ +dotnet_instrumentation_env_vars = [ { name: 'COR_ENABLE_PROFILING', type: :string, data: 'true' }, { name: 'COR_PROFILER', type: :string, data: '{B4C89B0F-9908-4F73-9F59-0D77C5A06874}' }, { name: 'CORECLR_ENABLE_PROFILING', type: :string, data: 'true' }, @@ -23,13 +23,13 @@ describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do its('SIGNALFX_DOTNET_TRACER_HOME') { should cmp "#{ENV['ProgramFiles']}\\SignalFx\\.NET Tracing\\" } - env_vars.each do |item| + dotnet_instrumentation_env_vars.each do |item| its(item[:name]) { should eq item[:data] } end end iis_env = [] -env_vars.each do |item| +dotnet_instrumentation_env_vars.each do |item| iis_env |= [ "#{item[:name]}=#{item[:data]}" ] end diff --git a/deployments/chef/test/integration/with_default_dotnet_instrumentation/test.rb b/deployments/chef/test/integration/with_default_dotnet_instrumentation/test.rb index f397907bc0..c56545e5ee 100644 --- a/deployments/chef/test/integration/with_default_dotnet_instrumentation/test.rb +++ b/deployments/chef/test/integration/with_default_dotnet_instrumentation/test.rb @@ -8,7 +8,7 @@ it { should_not be_running } end -env_vars = [ +dotnet_instrumentation_env_vars = [ { name: 'COR_ENABLE_PROFILING', type: :string, data: 'true' }, { name: 'COR_PROFILER', type: :string, data: '{B4C89B0F-9908-4F73-9F59-0D77C5A06874}' }, { name: 'CORECLR_ENABLE_PROFILING', type: :string, data: 'true' }, @@ -21,13 +21,13 @@ describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment') do its('SIGNALFX_DOTNET_TRACER_HOME') { should cmp "#{ENV['ProgramFiles']}\\SignalFx\\.NET Tracing\\" } - env_vars.each do |item| + dotnet_instrumentation_env_vars.each do |item| it { should_not have_property(item[:name]) } end end iis_env = [] -env_vars.each do |item| +dotnet_instrumentation_env_vars.each do |item| iis_env |= [ "#{item[:name]}=#{item[:data]}" ] end From bf9d767f57d21dcab201ebf40b55ac8c92ffb145 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 10 Jan 2024 13:25:45 -0800 Subject: [PATCH 36/67] Proper data type for multi_string registry entry --- deployments/chef/recipes/collector_win_registry.rb | 7 ++++++- deployments/chef/test/integration/custom_vars/test.rb | 6 +++++- deployments/chef/test/integration/default/test.rb | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/deployments/chef/recipes/collector_win_registry.rb b/deployments/chef/recipes/collector_win_registry.rb index fee4f5ce00..e272308ea0 100644 --- a/deployments/chef/recipes/collector_win_registry.rb +++ b/deployments/chef/recipes/collector_win_registry.rb @@ -24,11 +24,16 @@ collector_env_vars.push({ name: key, type: :string, data: value.to_s }) end +collector_env_vars_strings = [] +collector_env_vars.each do |item| + collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] +end + registry_key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector' do values [{ name: 'Environment', type: :multi_string, - data: collector_env_vars, + data: collector_service_environment, }] action :create notifies :restart, 'windows_service[splunk-otel-collector]', :delayed diff --git a/deployments/chef/test/integration/custom_vars/test.rb b/deployments/chef/test/integration/custom_vars/test.rb index 13249ef4ef..06ac07729c 100644 --- a/deployments/chef/test/integration/custom_vars/test.rb +++ b/deployments/chef/test/integration/custom_vars/test.rb @@ -33,8 +33,12 @@ { name: 'MY_CUSTOM_VAR1', type: :string, data: 'value1' }, { name: 'MY_CUSTOM_VAR2', type: :string, data: 'value2' }, ] + collector_env_vars_strings = [] + collector_env_vars.each do |item| + collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] + end describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do - it { should have_property_value('Environment', :multi_string, collector_env_vars) } + it { should have_property_value('Environment', :multi_string, collector_env_vars_strings) } end describe service('fluentdwinsvc') do it { should be_enabled } diff --git a/deployments/chef/test/integration/default/test.rb b/deployments/chef/test/integration/default/test.rb index a2f2fc64da..c627d8a4bb 100644 --- a/deployments/chef/test/integration/default/test.rb +++ b/deployments/chef/test/integration/default/test.rb @@ -29,8 +29,12 @@ { name: 'SPLUNK_REALM', type: :string, data: splunk_realm }, { name: 'SPLUNK_TRACE_URL', type: :string, data: splunk_trace_url }, ] + collector_env_vars_strings = [] + collector_env_vars.each do |item| + collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] + end describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do - it { should have_property_value('Environment', :multi_string, collector_env_vars) } + it { should have_property_value('Environment', :multi_string, collector_env_vars_strings) } end describe service('fluentdwinsvc') do it { should_not be_enabled } From 3c50447c44bbeaf1f221e5ddb3ca333e7a5ac749 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 10 Jan 2024 14:04:27 -0800 Subject: [PATCH 37/67] Fix var name typo --- deployments/chef/recipes/collector_win_registry.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/chef/recipes/collector_win_registry.rb b/deployments/chef/recipes/collector_win_registry.rb index e272308ea0..8520de8ad6 100644 --- a/deployments/chef/recipes/collector_win_registry.rb +++ b/deployments/chef/recipes/collector_win_registry.rb @@ -33,7 +33,7 @@ values [{ name: 'Environment', type: :multi_string, - data: collector_service_environment, + data: collector_env_vars_strings, }] action :create notifies :restart, 'windows_service[splunk-otel-collector]', :delayed From d00b8e6a9929845e5248626ea648be054b0b130a Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 10 Jan 2024 17:11:25 -0800 Subject: [PATCH 38/67] Fix order of collector environment variables --- deployments/chef/recipes/collector_win_registry.rb | 2 +- deployments/chef/test/integration/custom_vars/test.rb | 1 + deployments/chef/test/integration/default/test.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/deployments/chef/recipes/collector_win_registry.rb b/deployments/chef/recipes/collector_win_registry.rb index 8520de8ad6..e00a005015 100644 --- a/deployments/chef/recipes/collector_win_registry.rb +++ b/deployments/chef/recipes/collector_win_registry.rb @@ -28,7 +28,7 @@ collector_env_vars.each do |item| collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] end - +collector_env_vars_strings.sort! registry_key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector' do values [{ name: 'Environment', diff --git a/deployments/chef/test/integration/custom_vars/test.rb b/deployments/chef/test/integration/custom_vars/test.rb index 06ac07729c..8c894053de 100644 --- a/deployments/chef/test/integration/custom_vars/test.rb +++ b/deployments/chef/test/integration/custom_vars/test.rb @@ -37,6 +37,7 @@ collector_env_vars.each do |item| collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] end + collector_env_vars_strings.sort! describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do it { should have_property_value('Environment', :multi_string, collector_env_vars_strings) } end diff --git a/deployments/chef/test/integration/default/test.rb b/deployments/chef/test/integration/default/test.rb index c627d8a4bb..19c091dab6 100644 --- a/deployments/chef/test/integration/default/test.rb +++ b/deployments/chef/test/integration/default/test.rb @@ -33,6 +33,7 @@ collector_env_vars.each do |item| collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] end + collector_env_vars_strings.sort! describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do it { should have_property_value('Environment', :multi_string, collector_env_vars_strings) } end From 6388b907570f13e6b74121740f90cad0be5028cf Mon Sep 17 00:00:00 2001 From: pjanotti Date: Thu, 11 Jan 2024 06:49:43 -0800 Subject: [PATCH 39/67] Experiment custom_vars test --- deployments/chef/test/integration/custom_vars/test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deployments/chef/test/integration/custom_vars/test.rb b/deployments/chef/test/integration/custom_vars/test.rb index 8c894053de..4a10c2c582 100644 --- a/deployments/chef/test/integration/custom_vars/test.rb +++ b/deployments/chef/test/integration/custom_vars/test.rb @@ -38,6 +38,9 @@ collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] end collector_env_vars_strings.sort! + describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do + it { should exist('Environment', :multi_string) } + end describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do it { should have_property_value('Environment', :multi_string, collector_env_vars_strings) } end From 4ff26c600fdc60b3716f06839b4183af5c347f95 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Thu, 11 Jan 2024 15:20:42 -0800 Subject: [PATCH 40/67] Pay attention to conditional variables --- .../chef/recipes/collector_win_registry.rb | 18 ++++++++++-------- .../chef/test/integration/custom_vars/test.rb | 6 ++++++ .../chef/test/integration/default/test.rb | 10 ++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/deployments/chef/recipes/collector_win_registry.rb b/deployments/chef/recipes/collector_win_registry.rb index e00a005015..b8c1d49695 100644 --- a/deployments/chef/recipes/collector_win_registry.rb +++ b/deployments/chef/recipes/collector_win_registry.rb @@ -2,20 +2,22 @@ # Recipe:: collector_win_registry collector_env_vars = [ - { name: 'SPLUNK_CONFIG', type: :string, data: node['splunk_otel_collector']['collector_config_dest'].to_s }, { name: 'SPLUNK_ACCESS_TOKEN', type: :string, data: node['splunk_otel_collector']['splunk_access_token'].to_s }, - { name: 'SPLUNK_REALM', type: :string, data: node['splunk_otel_collector']['splunk_realm'].to_s }, { name: 'SPLUNK_API_URL', type: :string, data: node['splunk_otel_collector']['splunk_api_url'].to_s }, - { name: 'SPLUNK_INGEST_URL', type: :string, data: node['splunk_otel_collector']['splunk_ingest_url'].to_s }, - { name: 'SPLUNK_TRACE_URL', type: :string, data: node['splunk_otel_collector']['splunk_trace_url'].to_s }, - { name: 'SPLUNK_HEC_URL', type: :string, data: node['splunk_otel_collector']['splunk_hec_url'].to_s }, - { name: 'SPLUNK_HEC_TOKEN', type: :string, data: node['splunk_otel_collector']['splunk_hec_token'].to_s }, - { name: 'SPLUNK_MEMORY_TOTAL_MIB', type: :string, data: node['splunk_otel_collector']['splunk_memory_total_mib'].to_s }, - { name: 'SPLUNK_BALLAST_SIZE_MIB', type: :string, data: node['splunk_otel_collector']['splunk_ballast_size_mib'].to_s }, { name: 'SPLUNK_BUNDLE_DIR', type: :string, data: node['splunk_otel_collector']['splunk_bundle_dir'].to_s }, { name: 'SPLUNK_COLLECTD_DIR', type: :string, data: node['splunk_otel_collector']['splunk_collectd_dir'].to_s }, + { name: 'SPLUNK_CONFIG', type: :string, data: node['splunk_otel_collector']['collector_config_dest'].to_s }, + { name: 'SPLUNK_HEC_TOKEN', type: :string, data: node['splunk_otel_collector']['splunk_hec_token'].to_s }, + { name: 'SPLUNK_HEC_URL', type: :string, data: node['splunk_otel_collector']['splunk_hec_url'].to_s }, + { name: 'SPLUNK_INGEST_URL', type: :string, data: node['splunk_otel_collector']['splunk_ingest_url'].to_s }, + { name: 'SPLUNK_REALM', type: :string, data: node['splunk_otel_collector']['splunk_realm'].to_s }, + { name: 'SPLUNK_MEMORY_TOTAL_MIB', type: :string, data: node['splunk_otel_collector']['splunk_memory_total_mib'].to_s }, + { name: 'SPLUNK_TRACE_URL', type: :string, data: node['splunk_otel_collector']['splunk_trace_url'].to_s }, ] +unless node['splunk_otel_collector']['splunk_ballast_size_mib'].to_s.strip.empty? + collector_env_vars.push({ name: 'SPLUNK_BALLAST_SIZE_MIB', type: :string, data: node['splunk_otel_collector']['splunk_ballast_size_mib'].to_s }) +end unless node['splunk_otel_collector']['splunk_listen_interface'].to_s.strip.empty? collector_env_vars.push({ name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: node['splunk_otel_collector']['splunk_listen_interface'].to_s }) end diff --git a/deployments/chef/test/integration/custom_vars/test.rb b/deployments/chef/test/integration/custom_vars/test.rb index 4a10c2c582..c6870d95a4 100644 --- a/deployments/chef/test/integration/custom_vars/test.rb +++ b/deployments/chef/test/integration/custom_vars/test.rb @@ -33,6 +33,12 @@ { name: 'MY_CUSTOM_VAR1', type: :string, data: 'value1' }, { name: 'MY_CUSTOM_VAR2', type: :string, data: 'value2' }, ] + unless splunk_ballast_size_mib.to_s.strip.empty? + collector_env_vars.push({ name: 'SPLUNK_BALLAST_SIZE_MIB', type: :string, data: splunk_ballast_size_mib }) + end + unless splunk_listen_interface.to_s.strip.empty? + collector_env_vars.push({ name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: splunk_listen_interface }) + end collector_env_vars_strings = [] collector_env_vars.each do |item| collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] diff --git a/deployments/chef/test/integration/default/test.rb b/deployments/chef/test/integration/default/test.rb index 19c091dab6..6f3ad578fc 100644 --- a/deployments/chef/test/integration/default/test.rb +++ b/deployments/chef/test/integration/default/test.rb @@ -25,15 +25,25 @@ { name: 'SPLUNK_HEC_TOKEN', type: :string, data: splunk_hec_token }, { name: 'SPLUNK_HEC_URL', type: :string, data: splunk_hec_url }, { name: 'SPLUNK_INGEST_URL', type: :string, data: splunk_ingest_url }, + { name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: splunk_listen_interface }, { name: 'SPLUNK_MEMORY_TOTAL_MIB', type: :string, data: splunk_memory_total }, { name: 'SPLUNK_REALM', type: :string, data: splunk_realm }, { name: 'SPLUNK_TRACE_URL', type: :string, data: splunk_trace_url }, ] + unless splunk_ballast_size_mib.to_s.strip.empty? + collector_env_vars.push({ name: 'SPLUNK_BALLAST_SIZE_MIB', type: :string, data: splunk_ballast_size_mib }) + end + unless splunk_listen_interface.to_s.strip.empty? + collector_env_vars.push({ name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: splunk_listen_interface }) + end collector_env_vars_strings = [] collector_env_vars.each do |item| collector_env_vars_strings |= [ "#{item[:name]}=#{item[:data]}" ] end collector_env_vars_strings.sort! + describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do + it { should exist('Environment', :multi_string) } + end describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\splunk-otel-collector') do it { should have_property_value('Environment', :multi_string, collector_env_vars_strings) } end From 069ee454620293672d58736103f3ea079beb6b0d Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 14:43:18 -0800 Subject: [PATCH 41/67] First try with Puppet --- .../manifests/collector_win_registry.pp | 124 ++++-------------- 1 file changed, 28 insertions(+), 96 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 5a1b61910c..3dfeee5d29 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -1,110 +1,42 @@ # Class for setting the registry values for the splunk-otel-collector service class splunk_otel_collector::collector_win_registry () { - $registry_key = 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' - - registry_key { $registry_key: - ensure => 'present', - } - - registry_value { "${registry_key}\\SPLUNK_ACCESS_TOKEN": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_access_token, - require => Registry_key[$registry_key], - } - - registry_value { "${registry_key}\\SPLUNK_API_URL": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_api_url, - require => Registry_key[$registry_key], - } - - registry_value { "${registry_key}\\SPLUNK_BALLAST_SIZE_MIB": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_ballast_size_mib, - require => Registry_key[$registry_key], - } - - unless $splunk_otel_collector::splunk_listen_interface.strip().empty { - registry_value { "${registry_key}\\SPLUNK_LISTEN_INTERFACE": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_listen_interface, - require => Registry_key[$registry_key], - } - } - - registry_value { "${registry_key}\\SPLUNK_BUNDLE_DIR": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_bundle_dir, - require => Registry_key[$registry_key], - } - - registry_value { "${registry_key}\\SPLUNK_COLLECTD_DIR": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_collectd_dir, - require => Registry_key[$registry_key], + collector_env_vars = [ + "SPLUNK_ACCESS_TOKEN=${splunk_otel_collector::splunk_access_token}", + "SPLUNK_API_URL=${splunk_otel_collector::splunk_api_url}", + "SPLUNK_BUNDLE_DIR=${splunk_otel_collector::splunk_bundle_dir}", + "SPLUNK_COLLECTD_DIR=${splunk_otel_collector::splunk_collectd_dir}", + "SPLUNK_CONFIG=${splunk_otel_collector::collector_config_dest}", + "SPLUNK_HEC_TOKEN=${splunk_otel_collector::splunk_hec_token}", + "SPLUNK_HEC_URL=${splunk_otel_collector::splunk_hec_url}", + "SPLUNK_INGEST_URL=${splunk_otel_collector::splunk_ingest_url}", + "SPLUNK_MEMORY_TOTAL_MIB=${splunk_otel_collector::splunk_memory_total_mib}", + "SPLUNK_REALM=${splunk_otel_collector::splunk_realm}", + "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", + ] + + unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().empty? { + collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") + } + unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().empty? {} + collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") } - registry_value { "${registry_key}\\SPLUNK_CONFIG": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::collector_config_dest, - require => Registry_key[$registry_key], - } - - registry_value { "${registry_key}\\SPLUNK_HEC_TOKEN": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_hec_token, - require => Registry_key[$registry_key], - } - - registry_value { "${registry_key}\\SPLUNK_HEC_URL": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_hec_url, - require => Registry_key[$registry_key], + $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { + collector_env_vars |= "${var}=${value}" } - registry_value { "${registry_key}\\SPLUNK_INGEST_URL": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_ingest_url, - require => Registry_key[$registry_key], - } + collector_env_vars.sort! - registry_value { "${registry_key}\\SPLUNK_MEMORY_TOTAL_MIB": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_memory_total_mib, - require => Registry_key[$registry_key], - } + $registry_key = 'HKLM\SYSTEM\CurrentControlSet\Services\splunk-otel-collector' - registry_value { "${registry_key}\\SPLUNK_REALM": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_realm, - require => Registry_key[$registry_key], + registry_key { $registry_key: + ensure => 'present', } - registry_value { "${registry_key}\\SPLUNK_TRACE_URL": + registry_value { "${registry_key}\\Environment": ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_trace_url, + type => multi_string, + data => $collector_env_vars, require => Registry_key[$registry_key], } - - $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { - registry_value { "${registry_key}\\${var}": - ensure => 'present', - type => 'string', - data => $value, - require => Registry_key[$registry_key], - } - } } From cbaf5d45f7908a7994f3824c45470dcd0f51ea1e Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 16:11:48 -0800 Subject: [PATCH 42/67] Fix syntax for Puppet --- .../puppet/manifests/collector_win_registry.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 3dfeee5d29..3b9aa25e1e 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -14,16 +14,16 @@ "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] - unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().empty? { + unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().empty? collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") - } - unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().empty? {} + end + unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().empty? collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") - } + end - $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { + $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| collector_env_vars |= "${var}=${value}" - } + end collector_env_vars.sort! From 1578caa7896a1802d0b9bfe7d154b27c7be1638a Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 17:45:17 -0800 Subject: [PATCH 43/67] Back to curly brackets --- .../puppet/manifests/collector_win_registry.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 3b9aa25e1e..5ce51b4628 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -14,16 +14,16 @@ "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] - unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().empty? + unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().empty? { collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") - end - unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().empty? + } + unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().empty? { collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") - end + } - $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| + $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { collector_env_vars |= "${var}=${value}" - end + } collector_env_vars.sort! From 4f18580e0f6635a68ac7424c1164888c867946a1 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 18:19:04 -0800 Subject: [PATCH 44/67] Try extension fixes --- .../puppet/manifests/collector_win_registry.pp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 5ce51b4628..e362019d42 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -1,6 +1,6 @@ # Class for setting the registry values for the splunk-otel-collector service class splunk_otel_collector::collector_win_registry () { - collector_env_vars = [ + $collector_env_vars = [ "SPLUNK_ACCESS_TOKEN=${splunk_otel_collector::splunk_access_token}", "SPLUNK_API_URL=${splunk_otel_collector::splunk_api_url}", "SPLUNK_BUNDLE_DIR=${splunk_otel_collector::splunk_bundle_dir}", @@ -14,18 +14,19 @@ "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] - unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().empty? { - collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") + unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip() { + $collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") } - unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().empty? { - collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") + + unless $splunk_otel_collector::splunk_listen_interface.to_s.strip() { + $collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") } $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { - collector_env_vars |= "${var}=${value}" + $collector_env_vars.push("${var}=${value}") } - collector_env_vars.sort! + $collector_env_vars.sort() $registry_key = 'HKLM\SYSTEM\CurrentControlSet\Services\splunk-otel-collector' From 50f9c0f9f9f5ab0e9f48b2f2aece3d05eba39dae Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 18:20:46 -0800 Subject: [PATCH 45/67] Fix conditional --- deployments/puppet/manifests/collector_win_registry.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index e362019d42..9441283589 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -14,11 +14,11 @@ "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] - unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip() { + unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().is_empty() { $collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") } - unless $splunk_otel_collector::splunk_listen_interface.to_s.strip() { + unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().is_empty() { $collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") } From 782aae0f5c4b261c30ebd1321a3c248ece340968 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 19:00:40 -0800 Subject: [PATCH 46/67] Remove to_s --- deployments/puppet/manifests/collector_win_registry.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 9441283589..28c016e4a1 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -14,11 +14,11 @@ "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] - unless $splunk_otel_collector::splunk_ballast_size_mib.to_s.strip().is_empty() { + unless $splunk_otel_collector::splunk_ballast_size_mib.strip().is_empty() { $collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") } - unless $splunk_otel_collector::splunk_listen_interface.to_s.strip().is_empty() { + unless $splunk_otel_collector::splunk_listen_interface.strip().is_empty() { $collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") } From 4d8465e0d9f75e725a34e0c60e2a1da506bb1a6d Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 19:34:54 -0800 Subject: [PATCH 47/67] Use empty instead of is_empty --- deployments/puppet/manifests/collector_win_registry.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 28c016e4a1..9f87766ec1 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -14,11 +14,11 @@ "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] - unless $splunk_otel_collector::splunk_ballast_size_mib.strip().is_empty() { + unless $splunk_otel_collector::splunk_ballast_size_mib.strip().empty() { $collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") } - unless $splunk_otel_collector::splunk_listen_interface.strip().is_empty() { + unless $splunk_otel_collector::splunk_listen_interface.strip().empty() { $collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") } From 6bbc17820ce3cedbfff6c0ccff1a6c3c89f86dc5 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 19:45:18 -0800 Subject: [PATCH 48/67] Fix re-declaration of registry_key --- deployments/puppet/manifests/collector_win_registry.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 9f87766ec1..fb69bb5134 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -28,13 +28,7 @@ $collector_env_vars.sort() - $registry_key = 'HKLM\SYSTEM\CurrentControlSet\Services\splunk-otel-collector' - - registry_key { $registry_key: - ensure => 'present', - } - - registry_value { "${registry_key}\\Environment": + registry_value { "${splunk_otel_collector::registry_key}\\Environment": ensure => 'present', type => multi_string, data => $collector_env_vars, From b7dcb09fff938256d24bcaa03f86971b81a5ae04 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 19:57:36 -0800 Subject: [PATCH 49/67] Fix puppet lint issue --- deployments/puppet/manifests/collector_win_registry.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index fb69bb5134..a385ea866a 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -32,6 +32,6 @@ ensure => 'present', type => multi_string, data => $collector_env_vars, - require => Registry_key[$registry_key], + require => Registry_key[$splunk_otel_collector::registry_key], } } From 2c3af0900e392e7ec58b3e4ffdb2957619c71798 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 20:15:41 -0800 Subject: [PATCH 50/67] Do not re-use registry_key --- deployments/puppet/manifests/collector_win_registry.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index a385ea866a..88d48e4470 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -28,10 +28,10 @@ $collector_env_vars.sort() - registry_value { "${splunk_otel_collector::registry_key}\\Environment": + registry_value { "HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector\\Environment": ensure => 'present', type => multi_string, data => $collector_env_vars, - require => Registry_key[$splunk_otel_collector::registry_key], + require => Registry_key["HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector"], } } From e87063b7ee64c1ed08cba4b804e8ff58e289ee89 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 20:22:58 -0800 Subject: [PATCH 51/67] Use array instead of multi_string --- deployments/puppet/manifests/collector_win_registry.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 88d48e4470..04001d4baa 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -30,7 +30,7 @@ registry_value { "HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector\\Environment": ensure => 'present', - type => multi_string, + type => array, data => $collector_env_vars, require => Registry_key["HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector"], } From e1cf478d3297b687a5730332e8a73e9fd30350f1 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 21:24:50 -0800 Subject: [PATCH 52/67] Ensure side effects --- deployments/puppet/manifests/collector_win_registry.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 04001d4baa..cf1a238894 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -15,18 +15,18 @@ ] unless $splunk_otel_collector::splunk_ballast_size_mib.strip().empty() { - $collector_env_vars.push("SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") + $collector_env_vars = push($collector_env_vars, "SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") } unless $splunk_otel_collector::splunk_listen_interface.strip().empty() { - $collector_env_vars.push("SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") + $collector_env_vars = push($collector_env_vars, "SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") } $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { - $collector_env_vars.push("${var}=${value}") + $collector_env_vars = push($collector_env_vars, "${var}=${value}") } - $collector_env_vars.sort() + $collector_env_vars = sort($collector_env_vars) registry_value { "HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector\\Environment": ensure => 'present', From 2f6ecf4fe308e828e0e38e451eeaeeca8b78a428 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 21:25:18 -0800 Subject: [PATCH 53/67] Update test to use REG_MULTI_SZ --- .../buildscripts/packaging/tests/helpers/win_utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/buildscripts/packaging/tests/helpers/win_utils.py b/internal/buildscripts/packaging/tests/helpers/win_utils.py index 0b9b4fcef2..10eb27378a 100644 --- a/internal/buildscripts/packaging/tests/helpers/win_utils.py +++ b/internal/buildscripts/packaging/tests/helpers/win_utils.py @@ -16,7 +16,7 @@ import winreg WIN_REGISTRY = winreg.HKEY_LOCAL_MACHINE -WIN_REGISTRY_KEY = r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment" +WIN_REGISTRY_KEY = r"SYSTEM\CurrentControlSet\Services\splunk-otel-collector" def run_win_command(cmd, returncodes=None, shell=True, **kwargs): @@ -38,4 +38,11 @@ def has_choco(): def get_registry_value(name, registry=WIN_REGISTRY, key=WIN_REGISTRY_KEY): access_key = winreg.OpenKeyEx(registry, key) - return winreg.QueryValueEx(access_key, name)[0] + environment, regtype = winreg.QueryValueEx(r"Environment", name) + winreg.CloseKey(access_key) + if regtype != winreg.REG_MULTI_SZ: + raise TypeError("Registry type is not REG_MULTI_SZ") + env_var_line = next((line for line in environment if line.startswith(name)), None) + if env_var_line: + return env_var_line.split("=", 1)[1] + return None From d193f50c864595ca88c6eeed5747ac1772c8e1c8 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 21:58:06 -0800 Subject: [PATCH 54/67] Immutability? --- .../puppet/manifests/collector_win_registry.pp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index cf1a238894..e4711155dc 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -1,6 +1,6 @@ # Class for setting the registry values for the splunk-otel-collector service class splunk_otel_collector::collector_win_registry () { - $collector_env_vars = [ + $initial_collector_env_vars = [ "SPLUNK_ACCESS_TOKEN=${splunk_otel_collector::splunk_access_token}", "SPLUNK_API_URL=${splunk_otel_collector::splunk_api_url}", "SPLUNK_BUNDLE_DIR=${splunk_otel_collector::splunk_bundle_dir}", @@ -14,19 +14,20 @@ "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] + $additional_collector_env_vars = [] unless $splunk_otel_collector::splunk_ballast_size_mib.strip().empty() { - $collector_env_vars = push($collector_env_vars, "SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}") + $additional_collector_env_vars = $additional_collector_env_vars + ["SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}"] } unless $splunk_otel_collector::splunk_listen_interface.strip().empty() { - $collector_env_vars = push($collector_env_vars, "SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}") + $additional_collector_env_vars = $additional_collector_env_vars + ["SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}"] } $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { - $collector_env_vars = push($collector_env_vars, "${var}=${value}") + $additional_collector_env_vars = $additional_collector_env_vars + ["${var}=${value}"] } - $collector_env_vars = sort($collector_env_vars) + $collector_env_vars = sort($initial_collector_env_vars + $additional_collector_env_vars) registry_value { "HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector\\Environment": ensure => 'present', From faca2cec880cacbf5f91c4aedabd6081dd6cc9ab Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 22:08:38 -0800 Subject: [PATCH 55/67] Fix lint error --- deployments/puppet/manifests/collector_win_registry.pp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index e4711155dc..446e2b3d4d 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -16,11 +16,13 @@ $additional_collector_env_vars = [] unless $splunk_otel_collector::splunk_ballast_size_mib.strip().empty() { - $additional_collector_env_vars = $additional_collector_env_vars + ["SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}"] + $additional_collector_env_vars = $additional_collector_env_vars + + ["SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}"] } unless $splunk_otel_collector::splunk_listen_interface.strip().empty() { - $additional_collector_env_vars = $additional_collector_env_vars + ["SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}"] + $additional_collector_env_vars = $additional_collector_env_vars + + ["SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}"] } $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { From e1ca7c3e58fb24f597d78a12fddb2b9ef74a9885 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 12 Jan 2024 22:24:23 -0800 Subject: [PATCH 56/67] Fix test --- internal/buildscripts/packaging/tests/helpers/win_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/buildscripts/packaging/tests/helpers/win_utils.py b/internal/buildscripts/packaging/tests/helpers/win_utils.py index 10eb27378a..d0d6ccb4df 100644 --- a/internal/buildscripts/packaging/tests/helpers/win_utils.py +++ b/internal/buildscripts/packaging/tests/helpers/win_utils.py @@ -38,7 +38,7 @@ def has_choco(): def get_registry_value(name, registry=WIN_REGISTRY, key=WIN_REGISTRY_KEY): access_key = winreg.OpenKeyEx(registry, key) - environment, regtype = winreg.QueryValueEx(r"Environment", name) + environment, regtype = winreg.QueryValueEx(access_key, "Environment") winreg.CloseKey(access_key) if regtype != winreg.REG_MULTI_SZ: raise TypeError("Registry type is not REG_MULTI_SZ") From 52a6ebff09feabbf0a61a6894b1a23be6235a52b Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Sat, 13 Jan 2024 07:13:38 -0800 Subject: [PATCH 57/67] Removing name re-use --- .../manifests/collector_win_registry.pp | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 446e2b3d4d..d29fa0020a 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -1,6 +1,9 @@ # Class for setting the registry values for the splunk-otel-collector service class splunk_otel_collector::collector_win_registry () { - $initial_collector_env_vars = [ + $unordered_collector_env_vars = $splunk_otel_collector::collector_additional_env_vars.map |$var, $value| { + "${var}=${value}" + } + + [ "SPLUNK_ACCESS_TOKEN=${splunk_otel_collector::splunk_access_token}", "SPLUNK_API_URL=${splunk_otel_collector::splunk_api_url}", "SPLUNK_BUNDLE_DIR=${splunk_otel_collector::splunk_bundle_dir}", @@ -13,23 +16,18 @@ "SPLUNK_REALM=${splunk_otel_collector::splunk_realm}", "SPLUNK_TRACE_URL=${splunk_otel_collector::splunk_trace_url}", ] - - $additional_collector_env_vars = [] - unless $splunk_otel_collector::splunk_ballast_size_mib.strip().empty() { - $additional_collector_env_vars = $additional_collector_env_vars - + ["SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}"] + + if !$splunk_otel_collector::splunk_ballast_size_mib.strip().empty() { + ["SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}"] + } else { + [] } - - unless $splunk_otel_collector::splunk_listen_interface.strip().empty() { - $additional_collector_env_vars = $additional_collector_env_vars - + ["SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}"] - } - - $splunk_otel_collector::collector_additional_env_vars.each |$var, $value| { - $additional_collector_env_vars = $additional_collector_env_vars + ["${var}=${value}"] + + if !$splunk_otel_collector::splunk_listen_interface.strip().empty() { + ["SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}"] + } else { + [] } - $collector_env_vars = sort($initial_collector_env_vars + $additional_collector_env_vars) + $collector_env_vars = sort($unordered_collector_env_vars) registry_value { "HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector\\Environment": ensure => 'present', From 1b1007f80631b2dcaef08f5c16ec65c88e2dacd4 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Sat, 13 Jan 2024 10:34:05 -0800 Subject: [PATCH 58/67] Update CHANGELOG and README for Puppet --- deployments/puppet/CHANGELOG.md | 3 +++ deployments/puppet/README.md | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/deployments/puppet/CHANGELOG.md b/deployments/puppet/CHANGELOG.md index 83e1d7e2bd..86e793058e 100644 --- a/deployments/puppet/CHANGELOG.md +++ b/deployments/puppet/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope. + It is possible that some instrumentations are relying on the machine-wide environment variables set by the installation. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930)) + ## puppet-v0.12.0 - **Deprecations**: The `auto_instrumentation_generate_service_name` and `auto_instrumentation_disable_telemetry` diff --git a/deployments/puppet/README.md b/deployments/puppet/README.md index 5c4b653d9f..504172b0c3 100644 --- a/deployments/puppet/README.md +++ b/deployments/puppet/README.md @@ -26,6 +26,10 @@ Currently, the following Windows versions are supported and requires PowerShell - Windows Server 2019 64-bit - Windows Server 2022 64-bit +On Windows, the collector is installed as a Windows service and the environment +variables used in the configuration are set at service scope, i.e.: they are +only available to the collector service and not to the entire machine. + ## Usage This module can be downloaded and installed from [Puppet Forge](https://forge.puppet.com/modules/signalfx/splunk_otel_collector). From 5edf011dc8d9509f65f12b3edcf7c9271f7baede Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Sat, 13 Jan 2024 10:40:38 -0800 Subject: [PATCH 59/67] Updates to mass deployments docs --- deployments/ansible/CHANGELOG.md | 3 +++ deployments/ansible/README.md | 4 ++++ deployments/chef/README.md | 4 ++++ deployments/puppet/README.md | 6 +++--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/deployments/ansible/CHANGELOG.md b/deployments/ansible/CHANGELOG.md index 7d85c56740..d9815b634d 100644 --- a/deployments/ansible/CHANGELOG.md +++ b/deployments/ansible/CHANGELOG.md @@ -2,6 +2,9 @@ ## unreleased +- On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope. + It is possible that some instrumentations are relying on the machine-wide environment variables set by the installation. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930)) + ## ansible-v0.24.0 ### 🚩 Deprecations 🚩 diff --git a/deployments/ansible/README.md b/deployments/ansible/README.md index 638ff9a44a..123ff3f00b 100644 --- a/deployments/ansible/README.md +++ b/deployments/ansible/README.md @@ -25,6 +25,10 @@ Currently, the following Windows versions are supported: - Windows Server 2019 64-bit - Windows Server 2022 64-bit +On Windows, the collector is installed as a Windows service and its environment +variables are set at the service scope, i.e.: they are only available to the +collector service and not to the entire machine. + Ansible requires PowerShell 3.0 or newer and at least .NET 4.0 to be installed on Windows host. A WinRM listener should be created and activeted. For setting up Windows Host refer [Ansible Docs](https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html). diff --git a/deployments/chef/README.md b/deployments/chef/README.md index 9472aa75c9..1be5e7cedf 100644 --- a/deployments/chef/README.md +++ b/deployments/chef/README.md @@ -29,6 +29,10 @@ Currently, the following Windows versions are supported: - Windows Server 2019 64-bit - Windows Server 2022 64-bit +On Windows, the collector is installed as a Windows service and its environment +variables are set at the service scope, i.e.: they are only available to the +collector service and not to the entire machine. + ## Usage This cookbook can be downloaded and installed from [Chef Supermarket](https://supermarket.chef.io/cookbooks/splunk_otel_collector). diff --git a/deployments/puppet/README.md b/deployments/puppet/README.md index 504172b0c3..1356fa1449 100644 --- a/deployments/puppet/README.md +++ b/deployments/puppet/README.md @@ -26,9 +26,9 @@ Currently, the following Windows versions are supported and requires PowerShell - Windows Server 2019 64-bit - Windows Server 2022 64-bit -On Windows, the collector is installed as a Windows service and the environment -variables used in the configuration are set at service scope, i.e.: they are -only available to the collector service and not to the entire machine. +On Windows, the collector is installed as a Windows service and its environment +variables are set at the service scope, i.e.: they are only available to the +collector service and not to the entire machine. ## Usage From eb38784685581e7d61308fe6cd38c89e9781e15e Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 16 Jan 2024 13:57:36 -0800 Subject: [PATCH 60/67] Update last version deploying with machine wide env vars --- .../choco/splunk-otel-collector/tools/chocolateyinstall.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 2a581cda7d..ff4b59f9f3 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -57,8 +57,8 @@ if ($installed_collector) { # The package is already present, so this is an upgrade. Write-Host "Found a previous installation..." $installed_version = [Version]$installed_collector.DisplayVersion # Version for chocolatey doesn't include the prefilx 'v', this conversion is fine. - $first_version_with_service_env_vars = [Version]"0.89.0.0" - if ($installed_version -lt $first_version_with_service_env_vars) { + $last_version_with_machine_env_vars = [Version]"0.91.3.0" + if ($installed_version -le $last_version_with_machine_env_vars) { $upgraded_from_version_with_machine_wide_env_vars = $true Write-Host "Getting machine wide environment variables..." foreach ($name in $env_var_names) { From b140644ae6ccba3ecc78b6a4bdd7793af4aa46f5 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 16 Jan 2024 14:09:13 -0800 Subject: [PATCH 61/67] Sort service environment variables set via PowerShell --- .../packaging/choco/splunk-otel-collector/tools/common.ps1 | 2 +- internal/buildscripts/packaging/installer/install.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 index 84adc38fdb..7593a7cb03 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 @@ -163,7 +163,7 @@ function set_service_environment([string]$service_name, [hashtable]$env_vars) { Write-Host "Setting environment variables for the $service_name service..." # Transform the $env_vars to an array of strings so the Set-ItemProperty correctly create the # 'Environment' REG_MULTI_SZ value. - [string []] $multi_sz_value = ($env_vars.Keys | foreach-object { "$_=$($env_vars[$_])" }) + [string []] $multi_sz_value = ($env_vars.Keys | ForEach-Object { "$_=$($env_vars[$_])" } | Sort-Object) $target_service_reg_key = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name if (Test-Path $target_service_reg_key) { diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index 3f0ff8e4f0..85b4c12dab 100644 --- a/internal/buildscripts/packaging/installer/install.ps1 +++ b/internal/buildscripts/packaging/installer/install.ps1 @@ -426,7 +426,7 @@ function update_registry([string]$path, [string]$name, [string]$value) { function set_service_environment([string]$service_name, [hashtable]$env_vars) { # Transform the $env_vars to an array of strings so the Set-ItemProperty correctly create the # 'Environment' REG_MULTI_SZ value. - [string []] $multi_sz_value = ($env_vars.Keys | foreach-object { "$_=$($env_vars[$_])" }) + [string []] $multi_sz_value = ($env_vars.Keys | ForEach-Object { "$_=$($env_vars[$_])" } | Sort-Object) $target_service_reg_key = Join-Path "HKLM:\SYSTEM\CurrentControlSet\Services" $service_name if (Test-Path $target_service_reg_key) { From 34925c2e10049c6c8e2e16a5a87848e27c754aca Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 16 Jan 2024 14:40:38 -0800 Subject: [PATCH 62/67] Improve handling of collector restart in Ansible --- .../ansible/roles/collector/handlers/main.yml | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/deployments/ansible/roles/collector/handlers/main.yml b/deployments/ansible/roles/collector/handlers/main.yml index 9722932d37..0e92ff8772 100644 --- a/deployments/ansible/roles/collector/handlers/main.yml +++ b/deployments/ansible/roles/collector/handlers/main.yml @@ -26,10 +26,23 @@ - name: Restart Splunk OpenTelemetry Collector for windows ansible.windows.win_shell: | - Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector - Restart-Service splunk-otel-collector - Get-WinEvent -Log Application -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message - Get-WinEvent -Log System -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message + Try { + Restart-Service splunk-otel-collector + } Catch { + # Try to get some more helpful information given that the error message is not very helpful + Write-Host "Error restarting splunk-otel-collector service: $_" + + Write-Host "Splunk OpenTelemetry Collector service registry entry:" + Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector + + Write-Host "Last 15 Application log events:" + Get-WinEvent -Log Application -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message + + Write-Host "Last 15 System log events:" + Get-WinEvent -Log System -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message + + Throw $_ + } listen: "restart windows splunk-otel-collector" when: - (start_service | default(true) | bool) From b8b7005ecc3ab7e72c4b786299f9f0e730135118 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 16 Jan 2024 14:54:17 -0800 Subject: [PATCH 63/67] Remove extra double-quotes in SPLUNK_CONFIG for Ansible --- .../ansible/molecule/custom_vars/windows-verify.yml | 2 +- deployments/ansible/molecule/default/windows-verify.yml | 2 +- .../molecule/with_instrumentation/windows-verify.yml | 2 +- deployments/ansible/roles/collector/tasks/vars.yml | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deployments/ansible/molecule/custom_vars/windows-verify.yml b/deployments/ansible/molecule/custom_vars/windows-verify.yml index 0e46087fdf..81d87b155d 100644 --- a/deployments/ansible/molecule/custom_vars/windows-verify.yml +++ b/deployments/ansible/molecule/custom_vars/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: "\"{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\custom_config.yml\"" + SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\custom_config.yml' SPLUNK_INGEST_URL: https://fake-splunk-ingest.com SPLUNK_API_URL: https://fake-splunk-api.com SPLUNK_TRACE_URL: https://fake-splunk-ingest.com/v2/trace diff --git a/deployments/ansible/molecule/default/windows-verify.yml b/deployments/ansible/molecule/default/windows-verify.yml index 27114fd54c..d981af5f2c 100644 --- a/deployments/ansible/molecule/default/windows-verify.yml +++ b/deployments/ansible/molecule/default/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: "\"{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml\"" + SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm SPLUNK_API_URL: https://api.fake-realm.signalfx.com diff --git a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml index bfa4b02e44..7eb5ea0f57 100644 --- a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml +++ b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: "\"{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml\"" + SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm SPLUNK_API_URL: https://api.fake-realm.signalfx.com diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index c900aad721..dbd8992f42 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -73,12 +73,12 @@ SPLUNK_API_URL: "{{ splunk_api_url }}" SPLUNK_BALLAST_SIZE_MIB: "{{ splunk_ballast_size_mib if splunk_ballast_size_mib != '' else omit }}" SPLUNK_BUNDLE_DIR: >- - "{{ splunk_bundle_dir if splunk_bundle_dir != '' else - '{{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\agent-bundle' }}" + {{ splunk_bundle_dir if splunk_bundle_dir != '' else + '{{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\agent-bundle' }} SPLUNK_COLLECTD_DIR: "{{ splunk_collectd_dir if splunk_collectd_dir != '' else omit }}" SPLUNK_CONFIG: >- - "{{ splunk_otel_collector_config if splunk_otel_collector_config != '' else - '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' }}" + {{ splunk_otel_collector_config if splunk_otel_collector_config != '' else + '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' }} SPLUNK_INGEST_URL: "{{ splunk_ingest_url }}" SPLUNK_HEC_TOKEN: "{{ splunk_hec_token }}" SPLUNK_HEC_URL: "{{ splunk_hec_url }}" From 8287246a7c53677e17194ef240de466a3a3bc25a Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 16 Jan 2024 17:17:17 -0800 Subject: [PATCH 64/67] Fix Ansible verify SPLUNK_CONFIG strings --- deployments/ansible/molecule/custom_vars/windows-verify.yml | 2 +- deployments/ansible/molecule/default/windows-verify.yml | 2 +- .../ansible/molecule/with_instrumentation/windows-verify.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deployments/ansible/molecule/custom_vars/windows-verify.yml b/deployments/ansible/molecule/custom_vars/windows-verify.yml index 81d87b155d..d83c1ff430 100644 --- a/deployments/ansible/molecule/custom_vars/windows-verify.yml +++ b/deployments/ansible/molecule/custom_vars/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\custom_config.yml' + SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\custom_config.yml' SPLUNK_INGEST_URL: https://fake-splunk-ingest.com SPLUNK_API_URL: https://fake-splunk-api.com SPLUNK_TRACE_URL: https://fake-splunk-ingest.com/v2/trace diff --git a/deployments/ansible/molecule/default/windows-verify.yml b/deployments/ansible/molecule/default/windows-verify.yml index d981af5f2c..49965a5267 100644 --- a/deployments/ansible/molecule/default/windows-verify.yml +++ b/deployments/ansible/molecule/default/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' + SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm SPLUNK_API_URL: https://api.fake-realm.signalfx.com diff --git a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml index 7eb5ea0f57..39ed06b914 100644 --- a/deployments/ansible/molecule/with_instrumentation/windows-verify.yml +++ b/deployments/ansible/molecule/with_instrumentation/windows-verify.yml @@ -5,7 +5,7 @@ become: no vars: collector_reg_values: - SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\\Splunk\\OpenTelemetry Collector\\agent_config.yaml' + SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml' SPLUNK_ACCESS_TOKEN: fake-token SPLUNK_REALM: fake-realm SPLUNK_API_URL: https://api.fake-realm.signalfx.com From 7b076c65a97812000f9a93c021510e37ca650d18 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 17 Jan 2024 09:52:29 -0800 Subject: [PATCH 65/67] Fix Windows testing checking for legacy versions of the collector --- .github/workflows/scripts/win-test-services.ps1 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/win-test-services.ps1 b/.github/workflows/scripts/win-test-services.ps1 index 0e4d3dce21..c7b7ed42b6 100644 --- a/.github/workflows/scripts/win-test-services.ps1 +++ b/.github/workflows/scripts/win-test-services.ps1 @@ -11,11 +11,16 @@ $ErrorActionPreference = 'Stop' Set-PSDebug -Trace 1 function check_collector_svc_environment([hashtable]$expected_env_vars) { - $env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" $actual_env_vars = @{} - foreach ($entry in $env_array) { - $key, $value = $entry.Split("=", 2) - $actual_env_vars.Add($key, $value) + try { + $env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" + foreach ($entry in $env_array) { + $key, $value = $entry.Split("=", 2) + $actual_env_vars.Add($key, $value) + } + } catch { + Write-Host "Assuming an old version of the collector with environment variables at the machine scope" + $actual_env_vars = [Environment]::GetEnvironmentVariables("Machine")<#Do this if a terminating exception happens#> } foreach ($key in $expected_env_vars.Keys) { From bc206a245c5c0aa18afe6158e6bd953f372ab4e0 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 19 Jan 2024 13:33:17 -0800 Subject: [PATCH 66/67] Update CHANGELOG.md Co-authored-by: Ryan Fitzpatrick <10867373+rmfitzpatrick@users.noreply.github.com> --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a8b923033..e1234d358d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ ### 🛑 Breaking changes 🛑 -- (Splunk) On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope. - It is possible that some instrumentations are relying on the machine-wide environment variables set by the installation. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930)) +- (Splunk) On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope. This avoids collisions with other agents and instrumentation. If any of these environment variables are required by your apps, please adopt them directly. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930)) ## v0.91.3 - (Splunk) Properly sign and associate changelog to release. This should be otherwise identical to v0.91.2 From 3ca07b7231706482dac15e212d31b69c6dad51da Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 19 Jan 2024 14:06:18 -0800 Subject: [PATCH 67/67] Update last version still setting machine wide env vars --- .../choco/splunk-otel-collector/tools/chocolateyinstall.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index ff4b59f9f3..3f5859a765 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -57,7 +57,7 @@ if ($installed_collector) { # The package is already present, so this is an upgrade. Write-Host "Found a previous installation..." $installed_version = [Version]$installed_collector.DisplayVersion # Version for chocolatey doesn't include the prefilx 'v', this conversion is fine. - $last_version_with_machine_env_vars = [Version]"0.91.3.0" + $last_version_with_machine_env_vars = [Version]"0.92.0.0" if ($installed_version -le $last_version_with_machine_env_vars) { $upgraded_from_version_with_machine_wide_env_vars = $true Write-Host "Getting machine wide environment variables..."