-
Notifications
You must be signed in to change notification settings - Fork 142
SAM Application Monitoring Templates
In Server and Application Monitor (SAM), an application is a collection of component monitors inherited from a template when you assign the template to a node. SAM includes a number of out-of-the-box templates and has a rich shared repository of THWACK community provided templates. A template can be customized as well as exported and imported to/from a file. To understand more about the application/template relationship, read our Getting Started guide.
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 }
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"
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"
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 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
DeleteTemplate
verb can be used to delete an application template of given id.
Invoke-SwisVerb -swis $swis Orion.Apm.ApplicationTemplate DeleteTemplate @($applicationTemplateId)
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 }
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
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, Uri 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 "Uri: " $_.Uri; Write-Host }
Knowing id of a component template ($componentTemplateId
) and a key of the setting ($key
), you can set a new value ($value
).
$uri = "swis://$hostname/Orion/Orion.APM.ComponentTemplateSetting/ComponentTemplateID=$componentTemplateId,Key=`"$key`""
$properties = @{
Value=$value;
}
Set-SwisObject $swis -Uri $uri -Properties $properties
- About SWIS
- Connecting to SWIS
- SWQL Functions
- REST
- PowerShell
- Alerts
- Creating custom properties
- Poller Types
- Network Performance Monitor
- NetFlow Traffic Analyzer
- Network Configuration Manager
- IP Address Manager
- Server & Application Monitor
- Log Analyzer
- Schema reference