manifests/collectors/Monitor/AppInsightsWebTests.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Monitor/AppInsightsWebTests.ps1 (AB#5660).
# Field expressions are copied verbatim from the original collector and evaluate in an
# equivalent scope -- see docs/design/decisions/declarative-collectors.md.
# Review before trusting; regenerate rather than hand-patch if the source collector changes.
#
@{
    ResourceTypes = @(
        'microsoft.insights/webtests'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = '$_.KIND -eq ''standard'''

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
            $sub1 = $SUB | Where-Object { $_.Id -eq $1.subscriptionId }
            $data = $1.PROPERTIES
            $Tags = if (![string]::IsNullOrEmpty($1.tags.psobject.properties)) { $1.tags.psobject.properties } else { '0' }
 
            # Linked App Insights via hidden-link tag
            $aiResourceId = ''
            if ($1.tags) {
                $hiddenLink = $1.tags.psobject.properties | Where-Object { $_.Name -like 'hidden-link:*' }
                if ($hiddenLink) { $aiResourceId = ($hiddenLink.Name -replace '^hidden-link:', '') }
            }
            $aiResourceName = if ($aiResourceId) { ($aiResourceId -split '/')[-1] } else { 'N/A' }
 
            # Validation rules
            $validateStatus = if ($data.ValidationRules.ExpectedHttpStatusCode) { $data.ValidationRules.ExpectedHttpStatusCode } else { '200' }
            $sslCheck = if ($data.ValidationRules.CheckSsl) { 'Yes' } else { 'No' }
            $sslAlertDays = if ($data.ValidationRules.SSLCertRemainingLifetimeCheck) { $data.ValidationRules.SSLCertRemainingLifetimeCheck } else { 'N/A' }
 
            # Test request
            $testUrl = if ($data.Request.RequestUrl) { $data.Request.RequestUrl } else { 'N/A' }
            $followRedirect = if ($data.Request.FollowRedirects -eq $true) { 'Yes' } else { 'No' }
 
            $locationCount = if ($data.Locations) { @($data.Locations).Count } else { 0 }
            $locations = if ($data.Locations) { (@($data.Locations) | ForEach-Object { $_.Id }) -join '; ' } else { 'N/A' }
'@


    AdditionalRowLoops = @()

    TagLoop = @{
        Variable = 'Tag'
        Source = '$Tags'
        Preamble = ''
    }

    Fields = @(
        @{
            Name = 'ID'
            Expression = '$1.id'
        }
        @{
            Name = 'Subscription'
            Expression = '$sub1.Name'
        }
        @{
            Name = 'Resource Group'
            Expression = '$1.RESOURCEGROUP'
        }
        @{
            Name = 'Test Name'
            Expression = '$1.NAME'
        }
        @{
            Name = 'Location'
            Expression = '$1.LOCATION'
        }
        @{
            Name = 'Enabled'
            Expression = 'if ($data.Enabled) { ''Yes'' } else { ''No'' }'
        }
        @{
            Name = 'Test URL'
            Expression = '$testUrl'
        }
        @{
            Name = 'Frequency (seconds)'
            Expression = 'if ($data.Frequency) { $data.Frequency } else { 300 }'
        }
        @{
            Name = 'Timeout (seconds)'
            Expression = 'if ($data.Timeout) { $data.Timeout } else { 30 }'
        }
        @{
            Name = 'Expected HTTP Status'
            Expression = '$validateStatus'
        }
        @{
            Name = 'SSL Check'
            Expression = '$sslCheck'
        }
        @{
            Name = 'SSL Alert Days'
            Expression = '$sslAlertDays'
        }
        @{
            Name = 'Follow Redirects'
            Expression = '$followRedirect'
        }
        @{
            Name = 'App Insights Resource'
            Expression = '$aiResourceName'
        }
        @{
            Name = 'Test Locations Count'
            Expression = '$locationCount'
        }
        @{
            Name = 'Test Locations'
            Expression = '$locations'
        }
        @{
            Name = 'Provisioning State'
            Expression = 'if ($data.provisioningState) { $data.provisioningState } else { ''N/A'' }'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'App Insights Web Tests'
        TableNamePrefix = 'AIWebTestTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Test Name'
            'Location'
            'Enabled'
            'Test URL'
            'Frequency (seconds)'
            'Timeout (seconds)'
            'Expected HTTP Status'
            'SSL Check'
            'SSL Alert Days'
            'Follow Redirects'
            'App Insights Resource'
            'Test Locations Count'
            'Test Locations'
            'Provisioning State'
            'Resource U'
        )
        TagColumns = @()
        TagColumnsBefore = $null
        NumberFormat = '0'
        ConditionalText = @()
    }

    SourceCollector = 'Modules/Public/InventoryModules/Monitor/AppInsightsWebTests.ps1'
}