This is a cache of https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-for-windows-services.html. It is a snapshot of the page at 2024-10-04T01:01:16.158+0000.
Configuration for <strong>windows</strong> Services | APM .NET Agent Reference [1.x] | Elastic

Configuration for windows Services

edit

Configuration for windows services can be provided by setting environment variables for the specific windows service in the windows registry. With PowerShell

$environment = [string[]]@(
  "ELASTIC_APM_SERVER_URL=http://localhost:8200", 
  "ELASTIC_APM_TRANSACTION_SAMPLE_RATE=1",
  "ELASTIC_APM_ENVIRONMENT=Production",
  "ELASTIC_APM_SERVICE_NAME=MywindowsService")

Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\Services\<service-name> -Name Environment -Value $environment 

define the environment variables to use for the windows service

<service-name> is the name of the windows service.

The service must then be restarted for the change to take effect

Restart-Service <service-name>