cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to define tags based on environment variables for clusters?

renatarc
Participant

Hello

We've defined tags based on environment variables for the MS SQL Server instances.

It works fine on standalone instances, but it doesn't work for instances on cluster.

The "Environment" variable is already used by the cluster configuration. The manual setup done for the Dynatrace's tag (DT_CUSTOM_PROP= and DT_TAGS=) disapears after the restart of MSSQL service.

I followed the instructions on the page : https://www.dynatrace.com/support/help/manage/tags-and-metadata/setup/define-tags-based-on-environme...

Do you know how to setup the variables for SQL server clusters ?

Thanks,

Renata

5 REPLIES 5

radek_jasinski
DynaMight Guru
DynaMight Guru

Hi Renata,

I understand that you have correctly added variables to the registry on all servers in the cluster where you have MS SQL?

https://www.dynatrace.com/support/help/shortlink/process-group-properties#variables

Don't you sometimes have a mechanism in the organization that verifies the configuration of servers and, if changes are detected, restores the original one.

Radek

Have a nice day!

Hi Radek

There is any in-house script to restore the original values of the variables.

This configuration of the variables might be at the Cluster Manager level (quorum), but I don't know where/how to setup them.

Regards,

Renata

To set an environment variable using PowerShell and make it persistent (available even after a system reboot), you can use the following command:

[Environment]::SetEnvironmentVariable("VARIABLE_NAME", "VARIABLE_VALUE",[System.EnvironmentVariableTarget]::Machine)

Where:

  • VARIABLE_NAME is the name of the environment variable you want to set.
  • VARIABLE_VALUE is the value you want to assign to this variable.
  • [System.EnvironmentVariableTarget]::Machine means that the variable will be set as a machine variable, which means it will be available to all users on that computer and will be persistent.

https://shellgeek.com/set-environment-variable-using-powershell/

See if this works:)

Radek

Have a nice day!

Thanks for your inputs.

I need to have the "tag" on Dynatrace only in the processes and Process Groups related to the MS SQL Server Service. That's why on Windows, it has to be set in the registry of Service and not as a System Variable.

 

If I set the variable in the system, the server and all the processes will be tagged in Dynatrace with this variable - this is not the goal.

 

The documentation Dynatrace (Define tags based on environment variables ) says : 

Applying tags to hosts (instead of thoughtfully setting up environment variables as explained here) isn't recommended. The same applies to applications and processes. For details on setting up the DT_CUSTOM_PROP environment variable for Tomcat or WebSphere application metadata, Kubernetes annotations for Kubernetes-based deployments, or AWS tagging, see Application metadata & tagging.

 

If you want to set a permanent variable for a specific process or group of processes in windows then you can do it this way:

You can use PowerShell to create or modify environment variables in the Windows Registry. 

# Define permanent environment variables for different process groups
$RegistryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"

# Group A Variables
$GroupA_Variable1 = "ValueA1"
$GroupA_Variable2 = "ValueA2"

# Group B Variables
$GroupB_Variable1 = "ValueB1"
$GroupB_Variable2 = "ValueB2"

# Set Group A Variables
Set-ItemProperty -Path $RegistryPath -Name "GroupA_Variable1" -Value $GroupA_Variable1
Set-ItemProperty -Path $RegistryPath -Name "GroupA_Variable2" -Value $GroupA_Variable2

# Set Group B Variables
Set-ItemProperty -Path $RegistryPath -Name "GroupB_Variable1" -Value $GroupB_Variable1
Set-ItemProperty -Path $RegistryPath -Name "GroupB_Variable2" -Value $GroupB_Variable2

In the above example, you set permanent environment variables for different process groups (GroupA_Variable1, GroupA_Variable2, GroupB_Variable1, and GroupB_Variable2) in the Windows Registry under HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. These variables will persist and be available to all processes system-wide.

After setting permanent environment variables, you may need to restart or refresh processes (such as Explorer or PowerShell sessions) for them to recognize the new variables.

Radek

 

 

Have a nice day!

Featured Posts