Skip to content

SAM Application Monitoring Templates

Pawel Kedzior edited this page Jul 17, 2019 · 28 revisions

Application Monitoring Templates

SolarWinds Server and Application Monitor (SAM) includes a number of Application Monitoring Templates. Template, once assigned to a node creates an Application Monitor. A template can be customized as well as exported and imported to/from a file. Application Monitoring Template is composed of one or more Component Templates.

How to list application templates

In order to list currently existing Application Monitoring Templates, use SELECT ... FROM Orion.APM.ApplicationTemplate query. See Orion.APM.ApplicationTemplate Schema Reference for all the available properties. The following snippet prints a list of all the templates to the console:

$applicationTemplates = Get-SwisData -SwisConnection $swis -Query "SELECT ApplicationTemplateID, Name, Uri FROM Orion.APM.ApplicationTemplate"
$applicationTemplates | ForEach-Object { Write-Host "ID:" $_.ApplicationTemplateID; Write-Host "Name: " $_.Name; Write-Host "Uri: " $_.Uri; Write-Host }

How to import an application template

Orion SDK has ImportTemplate verb on Orion.APM.ApplicationTemplate entity which allows for automation of the process of importing Application Monitoring Templates to SAM. For example, in order to import a template from MyTemplate.apm-template file invoke the following PowerShell code:

# Load the template to a variable
$applicationTemplate = (Get-Content -Path ".\MyTemplate.apm-template" | Out-String)
# Import template
$result = Invoke-SwisVerb -Swis $swis Orion.APM.ApplicationTemplate ImportTemplate @($applicationTemplate)
$applicationTemplateId = $result.InnerText
Write-Host "Imported template Id: $applicationTemplateId"

How to export an application template

Similarly, when you know the id of an application template, you can export it to a file. The following code exports template of id 1 to MyTemplate.apm-template.

$applicationTemplateId = 1
# Export the template to a variable
$result = Invoke-SwisVerb -Swis $swis Orion.APM.ApplicationTemplate ExportTemplate @($applicationTemplateId)
$exportedTemplate = $res.InnerText
# Save the template to a file
$exportedTemplate | Out-File ".\MyTemplate.apm-template"

How to change the name of an application template

In order to change the name of an application template, you need Uri of the application template and then call Set-SwisObject. Uri can be constructed as in the example below (replace hostname with your Orion name) or found by selecting Uri column of ApplicationTemplate entity (see the example above).

$uri = "swis://<hostname>/Orion/Orion.APM.ApplicationTemplate/ApplicationTemplateID=$templateId"
$properties = @{
    Name="My new template";
}
Set-SwisObject $swis -Uri $uri -Properties $properties

How to delete an application template

DeleteTemplate verb can be used to delete an application template of given id.

Invoke-SwisVerb -swis $swis Orion.Apm.ApplicationTemplate DeleteTemplate @($applicationTemplateId)

How to list component templates

Components are available by Orion.APM.ComponentTemplate entity. See Orion.APM.ComponentTemplate Schema Reference for all the available properties. The following snippet prints a list of all the component templates of a given application template.

$componentTemplates = Get-SwisData -SwisConnection $swis -Query "SELECT ID, Name, ComponentType, IsDisabled, Uri FROM Orion.APM.ComponentTemplate WHERE ApplicationTemplateID = @applicationTemplateId" @{ applicationTemplateId = $applicationTemplateId }
$componentTemplates | ForEach-Object { Write-Host "ID:" $_.ID; Write-Host "Name: " $_.Name; Write-Host "IsDisabled: " $_.IsDisabled; Write-Host "Uri: " $_.Uri; Write-Host }

How to enable or disable a component template

Similarly to how we changed the name of an application template in the example above, we can change component template properties. In order to enable or disable a component, we need to change IsDisabled property, e.g.:

$uri = "swis://<hostname>/Orion/Orion.APM.ComponentTemplate/ID=$componentTemplateId"
$properties = @{
    IsDisabled="True";
}
Set-SwisObject $swis -Uri $uri -Properties $properties

How to list component template settings

Component Templates are configured by settings, which are key-value pairs. Knowing id of a component template $componentTemplateId, you can list the settings by running:

$componentTemplateSettings = Get-SwisData -SwisConnection $swis -Query "SELECT Key, Value, ValueType, Required FROM Orion.APM.ComponentTemplateSetting WHERE ComponentTemplateID = @componentTemplateId" @{ componentTemplateId = $componentTemplateId }
$componentTemplateSettings | ForEach-Object { Write-Host "Key:" $_.Key; Write-Host "Value: " $_.Value; Write-Host "ValueType: " $_.ValueType; Write-Host "Required: " $_.Required; Write-Host }
Clone this wiki locally