manifests/collectors/Monitor/AppInsightsAvailabilityTests.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Monitor/AppInsightsAvailabilityTests.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 = $null

    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 Application Insights resource (from hiddenlink 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' }
 
            # Test locations
            $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 = 'Kind'
            Expression = 'if ($1.KIND) { $1.KIND } else { if ($data.Kind) { $data.Kind } else { ''N/A'' } }'
        }
        @{
            Name = 'Enabled'
            Expression = 'if ($data.Enabled) { ''Yes'' } else { ''No'' }'
        }
        @{
            Name = 'Frequency (seconds)'
            Expression = 'if ($data.Frequency) { $data.Frequency } else { 300 }'
        }
        @{
            Name = 'Timeout (seconds)'
            Expression = 'if ($data.Timeout) { $data.Timeout } else { 30 }'
        }
        @{
            Name = 'Success Criteria'
            Expression = 'if ($data.RetryEnabled) { ''Retry Enabled'' } else { ''No Retry'' }'
        }
        @{
            Name = 'Test Type'
            Expression = 'if ($data.SyntheticMonitorId) { ''Synthetic Monitor'' } else { ''N/A'' }'
        }
        @{
            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 Availability Tests'
        TableNamePrefix = 'AIAvailabilityTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Test Name'
            'Location'
            'Kind'
            'Enabled'
            'Frequency (seconds)'
            'Timeout (seconds)'
            'App Insights Resource'
            'Test Locations Count'
            'Test Locations'
            'Provisioning State'
            'Resource U'
        )
        TagColumns = @()
        TagColumnsBefore = $null
        NumberFormat = '0'
        ConditionalText = @()
    }

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