Finding Property References #30
-
I am trying to write some kind of utility that will return all the objects in LogicMonitor where a custom property is defined or referenced. I have written a powershell script to extract custom properties from both devices and groups, where they are defined, from groups where they are referenced by an AppliesTo script, as well as Alert rules where they are defined. # Name of custom property
$propertyName = "test.property.name"
####### FILTERS HERE ####
# Find all devices
$filter = "customProperties.name -eq ""$($propertyName)"""
$devicesCustomProperty = Get-LMDevice -Filter $filter
($devicesCustomProperty | Measure-Object).Count
# Find all group custom properties
$filter = "customProperties.name -eq ""$($propertyName)"""
$groupsCustomProperty = Get-LMDeviceGroup -Filter $filter
($groupsCustomProperty | Measure-Object).Count
# Find all group appliesTo references
$filter = "appliesTo -contains ""$($propertyName)"""
$groupsAppliesTo = Get-LMDeviceGroup -Filter $filter
($groupsAppliesTo | Measure-Object).Count
# find all alert rules using explicit property
$filter = "resourceProperties.name -eq ""$($propertyName)"""
$alertRulesProperties = Get-LMAlertRule -Filter $filter
($alertRulesProperties | Measure-Object).Count What I am struggling with right now is how to find what LogicModules might be referencing the property. I see in the Logic.Monitor module a cmdlet called Get-LMRepositoryLogicModules which seems to be referencing the following API call when I select the -Type datasource /santaba/rest/setting/logicmodules/listcore?type=datasource But nothing returns. Is there a way to get LogicModule information directly from the API or a powershell cmdlet? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You would most likely want to use the appropriate Get-LM*Source cmdlets such as Get-LMDatasource. The cmdlet you mentioned is used to pull modules from core that are not installed in your portal. |
Beta Was this translation helpful? Give feedback.
-
So I tried using the following versions of the cmdlet Get-LMDatasource and get nothing back Get-LMDatasource
Get-LMDatasource -BatchSize 100
Get-LMDatasource -Name "*"
Get-LMDatasource -Name "*" -BatchSize 100
Get-LMDatasource -DisplayName "*" -BatchSize 100
Get-LMDatasource -DisplayName "*"
Get-LMDatasource -Name "Network Interfaces" -BatchSize 100
Get-LMDatasource -DisplayName "Network Interfaces" -BatchSize 100
Get-LMDatasource -Name "SNMP_Network_Interfaces" -BatchSize 100
Get-LMDatasource -DisplayName "SNMP_Network_Interfaces" -BatchSize 100
I am using Version 6.6 of the Logic.Module Powershell module |
Beta Was this translation helpful? Give feedback.
I would check what permissions your api key has and that is has the correct permissions to read datasources. You should get a response back similar to: