From 1da0e2c5536a1ba25209b8f876c53a3f1c1dc4e3 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 23 Jan 2024 06:22:05 -0800 Subject: [PATCH] Set env vars for service instead of machine (#3930) * Set env vars for service instead of machine * Fix copy and pasted typo * Remove unused variable * Update chocolatey to use env vars at the service scope * Fix check for "SPLUNK_ACCESS_TOKEN" * Handle upgrade in chocolatey * Get-Package not available on all Windows versions * Add messages to track stage on chocolatey install * Adding more messages to chocolatey script * Fix service on the registry but no env * Restore $regKey on install.ps1 * Add helper allow running the collector manually on Windows * Add breaking change to CHANGELOG.md * Add -config_path switch to install.ps1 * Fix pipeline collector for Windows ZC IIS test * MSI to set SPLUNK_CONFIG at the service scope * Minor doc updates * Update ansible tests for Windows env vars * Correct type of *_ENABLE_PROFILING value * ansible: Windows deployment updates * fix yamllint issues * fix yamllint * Output vagrant.err in case of failure * Fix splunk_trace_url check * Always try to display the vagrant errors * Check if event log has some info about failure * Remove event log steps: running on mac not Windows * Launch vagrant * Init vagrant * Drop launch vagrant step * Fix ansible Windows * Fix yamllint issues * Remove vagrant init * Updates to pass local run of molecule tests * Update chef deployment * Proper data type for multi_string registry entry * Fix var name typo * Fix order of collector environment variables * Experiment custom_vars test * Pay attention to conditional variables * First try with Puppet * Fix syntax for Puppet * Back to curly brackets * Try extension fixes * Fix conditional * Remove to_s * Use empty instead of is_empty * Fix re-declaration of registry_key * Fix puppet lint issue * Do not re-use registry_key * Use array instead of multi_string * Ensure side effects * Update test to use REG_MULTI_SZ * Immutability? * Fix lint error * Fix test * Removing name re-use * Update CHANGELOG and README for Puppet * Updates to mass deployments docs * Update last version deploying with machine wide env vars * Sort service environment variables set via PowerShell * Improve handling of collector restart in Ansible * Remove extra double-quotes in SPLUNK_CONFIG for Ansible * Fix Ansible verify SPLUNK_CONFIG strings * Fix Windows testing checking for legacy versions of the collector * Update CHANGELOG.md Co-authored-by: Ryan Fitzpatrick <10867373+rmfitzpatrick@users.noreply.github.com> * Update last version still setting machine wide env vars --------- Co-authored-by: Ryan Fitzpatrick <10867373+rmfitzpatrick@users.noreply.github.com> --- .../workflows/scripts/win-test-services.ps1 | 45 +++-- CHANGELOG.md | 7 +- deployments/ansible/CHANGELOG.md | 3 + deployments/ansible/README.md | 4 + .../molecule/custom_vars/windows-verify.yml | 30 ++- .../molecule/default/windows-verify.yml | 23 +-- .../with_instrumentation/windows-verify.yml | 52 +++-- deployments/ansible/roles/collector/README.md | 4 +- .../ansible/roles/collector/handlers/main.yml | 21 +- .../collector/tasks/otel_win_install.yml | 3 - .../roles/collector/tasks/otel_win_reg.yml | 151 ++------------ .../ansible/roles/collector/tasks/vars.yml | 45 +++-- .../collector/tasks/win_configurable_vars.yml | 25 +++ deployments/chef/CHANGELOG.md | 3 + deployments/chef/README.md | 8 +- .../chef/recipes/collector_win_registry.rb | 37 ++-- .../dotnet_instrumentation_win_install.rb | 8 +- .../chef/test/integration/custom_vars/test.rb | 47 +++-- .../chef/test/integration/default/test.rb | 43 ++-- .../test.rb | 6 +- .../test.rb | 6 +- deployments/puppet/CHANGELOG.md | 3 + deployments/puppet/README.md | 4 + .../manifests/collector_win_registry.pp | 140 ++++--------- docs/getting-started/windows-installer.md | 12 +- docs/getting-started/windows-manual.md | 33 +-- .../tools/chocolateyinstall.ps1 | 189 +++++++----------- .../splunk-otel-collector/tools/common.ps1 | 36 +++- .../packaging/installer/install.ps1 | 70 ++++--- .../packaging/msi/splunk-otel-collector.wxs | 6 +- .../packaging/msi/splunk-support-bundle.ps1 | 17 ++ .../packaging/tests/helpers/win_utils.py | 11 +- .../testdata/Dockerfile.pipeline.collector | 6 +- 33 files changed, 529 insertions(+), 569 deletions(-) create mode 100644 deployments/ansible/roles/collector/tasks/win_configurable_vars.yml diff --git a/.github/workflows/scripts/win-test-services.ps1 b/.github/workflows/scripts/win-test-services.ps1 index b6ff00c9d0..c7b7ed42b6 100644 --- a/.github/workflows/scripts/win-test-services.ps1 +++ b/.github/workflows/scripts/win-test-services.ps1 @@ -10,10 +10,25 @@ 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) { + $actual_env_vars = @{} + 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) { + $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 +39,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/CHANGELOG.md b/CHANGELOG.md index 8fb77dc5a3..9880b43b06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### 🛑 Breaking changes 🛑 + +- (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.92.0 This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.92.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.92.0) and the [opentelemetry-collector-contrib v0.92.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.92.0) releases where appropriate. @@ -86,6 +90,7 @@ This Splunk OpenTelemetry Collector release includes changes from the [opentelem - (Core) `otlpexporter`: remove dependency of otlphttpreceiver on otlpexporter ([#6454](https://github.com/open-telemetry/opentelemetry-collector/issues/6454)) ## v0.91.3 + - (Splunk) Properly sign and associate changelog to release. This should be otherwise identical to v0.91.2 ## v0.91.2 @@ -113,7 +118,6 @@ This Splunk OpenTelemetry Collector release includes changes from the [opentelem - (Splunk) Adopt `awss3` exporter ([#4117](https://github.com/signalfx/splunk-otel-collector/pull/4117)) - (Splunk) Convert loglevel to verbosity on logging exporter ([#4097](https://github.com/signalfx/splunk-otel-collector/pull/4097)) - ## v0.91.1 ### 💡 Enhancements 💡 @@ -301,7 +305,6 @@ This Splunk OpenTelemetry Collector release includes changes from the [opentelem - (Contrib) `zipkinreceiver`: Return BadRequest in case of permanent errors ([#4335](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/4335)) - (Core) `exporterhelper`: fix bug with queue size and capacity metrics ([#8682](https://github.com/open-telemetry/opentelemetry-collector/issues/8682)) - ## 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. 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/ansible/molecule/custom_vars/windows-verify.yml b/deployments/ansible/molecule/custom_vars/windows-verify.yml index beb52bdfe0..d83c1ff430 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,11 +15,10 @@ 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" + iis_reg_values: + 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 @@ -28,6 +27,8 @@ SIGNALFX_GLOBAL_TAGS: splunk.zc.method:signalfx-dotnet-tracing-1.0.0,dotnet-tag:dotnet-tag-value 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: @@ -36,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 @@ -124,7 +121,18 @@ - 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: + 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 @@ -132,4 +140,4 @@ path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment name: "{{ item.key }}" value: "{{ item.value }}" - loop: "{{ reg_values | combine(dotnet_reg_values) | dict2items }}" + loop: "{{ machine_reg_values | dict2items }}" diff --git a/deployments/ansible/molecule/default/windows-verify.yml b/deployments/ansible/molecule/default/windows-verify.yml index d203634b0a..49965a5267 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 @@ -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 @@ -36,10 +32,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..39ed06b914 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,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 - SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\' - dotnet_reg_values: - COR_ENABLE_PROFILING: "true" + iis_reg_values: + 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_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: @@ -31,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 = "" @@ -44,19 +41,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}) }} - - - 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 }}" + {{ iis_reg_values | combine({"SIGNALFX_GLOBAL_TAGS": tags}) }} - name: Get IIS env vars ansible.windows.win_reg_stat: @@ -67,7 +56,18 @@ - 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: + 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 @@ -75,4 +75,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/README.md b/deployments/ansible/roles/collector/README.md index a5b4e8eb5e..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: 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/handlers/main.yml b/deployments/ansible/roles/collector/handlers/main.yml index 692d780b2a..0e92ff8772 100644 --- a/deployments/ansible/roles/collector/handlers/main.yml +++ b/deployments/ansible/roles/collector/handlers/main.yml @@ -25,9 +25,24 @@ - (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: | + 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) 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/otel_win_reg.yml b/deployments/ansible/roles/collector/tasks/otel_win_reg.yml index ebf2f8b3ec..e240cb51cf 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_service_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: "restart windows splunk-otel-collector" diff --git a/deployments/ansible/roles/collector/tasks/vars.yml b/deployments/ansible/roles/collector/tasks/vars.yml index 88ad5d7352..dbd8992f42 100644 --- a/deployments/ansible/roles/collector/tasks/vars.yml +++ b/deployments/ansible/roles/collector/tasks/vars.yml @@ -35,26 +35,12 @@ {%- 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_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_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 }} @@ -72,9 +58,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 }}" @@ -82,4 +68,23 @@ 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 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 != '' 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" 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) == "" 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..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). @@ -143,8 +147,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..b8c1d49695 100644 --- a/deployments/chef/recipes/collector_win_registry.rb +++ b/deployments/chef/recipes/collector_win_registry.rb @@ -1,31 +1,42 @@ # Cookbook:: splunk_otel_collector # Recipe:: collector_win_registry -registry_values = [ - { name: 'SPLUNK_CONFIG', type: :string, data: node['splunk_otel_collector']['collector_config_dest'].to_s }, +collector_env_vars = [ { 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? - 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 +collector_env_vars_strings = [] +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', + type: :multi_string, + data: collector_env_vars_strings, + }] 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..c6870d95a4 100644 --- a/deployments/chef/test/integration/custom_vars/test.rb +++ b/deployments/chef/test/integration/custom_vars/test.rb @@ -17,21 +17,38 @@ 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' }, + ] + 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 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..6f3ad578fc 100644 --- a/deployments/chef/test/integration/default/test.rb +++ b/deployments/chef/test/integration/default/test.rb @@ -16,19 +16,36 @@ 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_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 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 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..1356fa1449 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 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 module can be downloaded and installed from [Puppet Forge](https://forge.puppet.com/modules/signalfx/splunk_otel_collector). diff --git a/deployments/puppet/manifests/collector_win_registry.pp b/deployments/puppet/manifests/collector_win_registry.pp index 5a1b61910c..d29fa0020a 100644 --- a/deployments/puppet/manifests/collector_win_registry.pp +++ b/deployments/puppet/manifests/collector_win_registry.pp @@ -1,110 +1,38 @@ # 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], - } - - 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], - } - - registry_value { "${registry_key}\\SPLUNK_INGEST_URL": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_ingest_url, - require => Registry_key[$registry_key], - } - - 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_value { "${registry_key}\\SPLUNK_REALM": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_realm, - require => Registry_key[$registry_key], - } - - registry_value { "${registry_key}\\SPLUNK_TRACE_URL": - ensure => 'present', - type => 'string', - data => $splunk_otel_collector::splunk_trace_url, - 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], - } + $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}", + "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}", + ] + + if !$splunk_otel_collector::splunk_ballast_size_mib.strip().empty() { + ["SPLUNK_BALLAST_SIZE_MIB=${splunk_otel_collector::splunk_ballast_size_mib}"] + } else { + [] + } + + if !$splunk_otel_collector::splunk_listen_interface.strip().empty() { + ["SPLUNK_LISTEN_INTERFACE=${splunk_otel_collector::splunk_listen_interface}"] + } else { + [] + } + + $collector_env_vars = sort($unordered_collector_env_vars) + + registry_value { "HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector\\Environment": + ensure => 'present', + type => array, + data => $collector_env_vars, + require => Registry_key["HKLM\\SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector"], } } diff --git a/docs/getting-started/windows-installer.md b/docs/getting-started/windows-installer.md index b77ba00071..0961a69196 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 4605d68685..591daddeb6 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. 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..3f5859a765 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,75 @@ 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." -} - -try { - if (!$SPLUNK_HEC_URL) { - $SPLUNK_HEC_URL = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "SPLUNK_HEC_URL" -ErrorAction SilentlyContinue +# 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 + +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. + 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.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..." + foreach ($name in $env_var_names) { + $value = [Environment]::GetEnvironmentVariable($name, "Machine") + if ($value) { + $env_vars[$name] = "$value" + } + } } } -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 +$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 + } } } -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 +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 +} 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,17 +119,12 @@ 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" +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") + } } -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 @@ -203,7 +154,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,12 +167,16 @@ 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) { 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..7593a7cb03 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/common.ps1 @@ -139,9 +139,39 @@ function remove_otel_registry_entries() { } } -function update_registry([string]$path, [string]$name, [string]$value) { - write-host "Updating $path for $name..." - Set-ItemProperty -path "$path" -name "$name" -value "$value" +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) { + 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[$_])" } | Sort-Object) + + $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." + } } # check that we're not running with a restricted execution policy diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index 7a0bf2b2c0..85b4c12dab 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 @@ -166,8 +171,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 { @@ -420,6 +423,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[$_])" } | Sort-Object) + + $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 @@ -566,33 +583,39 @@ 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." } } -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" +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"; + "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. @@ -670,6 +693,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" diff --git a/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs b/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs index 6d9191ae09..72f5db3b45 100644 --- a/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs +++ b/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs @@ -38,8 +38,10 @@ - - + + + SPLUNK_CONFIG=[CommonAppDataFolder]Splunk\OpenTelemetry Collector\agent_config.yaml" + 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. diff --git a/internal/buildscripts/packaging/tests/helpers/win_utils.py b/internal/buildscripts/packaging/tests/helpers/win_utils.py index 0b9b4fcef2..d0d6ccb4df 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(access_key, "Environment") + 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 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 }" ]