I'm trying to get a variable that indicates if the threshold has been baselined. I used this post to help, which is awesome (APM Threshold Alert ) but it doesn't appear that nested Select statements are valid in SQL variables, example below:
The below works in SQL management studio really well but when plugged into an alert email as a SQL variable it errors out and just spits back the SQL query in the email...
I used "useBaseline " here to let support teams know its a baselined component. I was also wanting to use "ComputeBaseline" to indicate it had been turned on as well as "BaselineApplyError" if there were any errors calculating the baseline, but looks like I may be out of luck
SELECT useBaseline FROM [dbo].[APM_Threshold] where ID = ${N=SwisEntity;M=ComponentAlert.ComponentID} and istemplate = 0 and thresholdname = (SELECT CASEWHEN ([PercentCPU] > [Threshold-CPU-Warning]) OR ([PercentCPU] > [Threshold-CPU-Critical]) THEN 'CPU'WHEN ([PercentMemory] > [Threshold-PhysicalMemory-Warning]) OR ([PercentMemory] > [Threshold-PhysicalMemory-Critical]) THEN 'PMem'WHEN ([PercentVirtualMemory] > [Threshold-VirtualMemory-Warning]) OR ([PercentVirtualMemory] > [Threshold-VirtualMemory-Critical]) THEN 'VMem'WHEN ([IOReadOperationsPerSec] > [Threshold-IOReadOperationsPerSec-Warning]) OR ([IOReadOperationsPerSec] > [Threshold-IOReadOperationsPerSec-Critical]) THEN 'IOReadOperationsPerSec'WHEN ([IOWriteOperationsPerSec] > [Threshold-IOWriteOperationsPerSec-Warning]) OR ([IOWriteOperationsPerSec] > [Threshold-IOWriteOperationsPerSec-Critical]) THEN 'IOWriteOperationsPerSec'WHEN ([IOTotalOperationsPerSec] > [Threshold-IOTotalOperationsPerSec-Warning]) OR ([IOTotalOperationsPerSec] > [Threshold-IOTotalOperationsPerSec-Critical]) THEN 'IOTotalOperationsPerSec'WHEN ([ResponseTime] > [Threshold-ResponseTime-Warning]) OR ([ResponseTime] > [Threshold-ResponseTime-Critical]) THEN 'Response'WHEN ([StatisticData] > [Threshold-Statistic-Warning]) OR ([StatisticData] > [Threshold-Statistic-Critical]) THEN 'StatisticData'ELSE 'None' END AS ThresholdTypeFROM APM_AlertsAndReportsDataWHERE ComponentID=${N=SwisEntity;M=ComponentAlert.ComponentID})