Skip to content

Commit 23ae667

Browse files
Merge pull request #81 from logicmonitor/79-get-lmdevicedata-doesnt-handle-paging-correctly
79 get lmdevicedata doesnt handle paging correctly
2 parents e37df20 + 5f6ebfa commit 23ae667

14 files changed

Lines changed: 2175 additions & 236 deletions

Build.ps1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ $buildVersion = $env:BUILD_VERSION
55
$manifestPath = "./Logic.Monitor.psd1"
66
$publicFuncFolderPath = './Public'
77

8+
# Exclude patterns for functions to not export (e.g., work-in-progress features)
9+
$excludePatterns = @('*LMUptime*')
10+
811
$ps1xmlFiles = Get-ChildItem -Path ./ -Filter *.ps1xml
912
Foreach ($ps1xml in $ps1xmlFiles) {
1013
[xml]$xml = Get-Content -Path $ps1xml.FullName
@@ -34,8 +37,23 @@ If (!(Get-Module PwshSpectreConsole -ListAvailable)) {
3437

3538
$manifestContent = (Get-Content -Path $manifestPath -Raw) -replace '<ModuleVersion>', $buildVersion
3639

37-
If ((Test-Path -Path $publicFuncFolderPath) -and ($publicFunctionNames = Get-ChildItem -Path $publicFuncFolderPath -Filter '*.ps1' | Select-Object -ExpandProperty BaseName)) {
38-
$funcStrings = "'$($publicFunctionNames -join "','")'"
40+
If (Test-Path -Path $publicFuncFolderPath) {
41+
$allFunctions = Get-ChildItem -Path $publicFuncFolderPath -Filter '*.ps1'
42+
43+
# Apply exclusion patterns
44+
$filteredFunctions = $allFunctions
45+
foreach ($pattern in $excludePatterns) {
46+
$filteredFunctions = $filteredFunctions | Where-Object { $_.Name -notlike $pattern }
47+
}
48+
49+
$publicFunctionNames = $filteredFunctions | Select-Object -ExpandProperty BaseName
50+
51+
if ($publicFunctionNames) {
52+
$funcStrings = "'$($publicFunctionNames -join "','")'"
53+
}
54+
else {
55+
$funcStrings = $null
56+
}
3957
}
4058
Else {
4159
$funcStrings = $null

Documentation/Get-LMDeviceData.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,56 @@ Retrieves monitoring data for a LogicMonitor device.
1515
### dsName-deviceName-instanceId
1616
```
1717
Get-LMDeviceData -DatasourceName <String> -DeviceName <String> -InstanceId <Int32> [-StartDate <DateTime>]
18-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
18+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
1919
[<CommonParameters>]
2020
```
2121

2222
### dsName-deviceName-instanceName
2323
```
2424
Get-LMDeviceData -DatasourceName <String> -DeviceName <String> [-InstanceName <String>] [-StartDate <DateTime>]
25-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
25+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
2626
[<CommonParameters>]
2727
```
2828

2929
### dsName-deviceId-instanceName
3030
```
3131
Get-LMDeviceData -DatasourceName <String> -DeviceId <Int32> [-InstanceName <String>] [-StartDate <DateTime>]
32-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
32+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
3333
[<CommonParameters>]
3434
```
3535

3636
### dsName-deviceId-instanceId
3737
```
3838
Get-LMDeviceData -DatasourceName <String> -DeviceId <Int32> -InstanceId <Int32> [-StartDate <DateTime>]
39-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
39+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
4040
[<CommonParameters>]
4141
```
4242

4343
### dsId-deviceName-instanceId
4444
```
4545
Get-LMDeviceData -DatasourceId <Int32> -DeviceName <String> -InstanceId <Int32> [-StartDate <DateTime>]
46-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
46+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
4747
[<CommonParameters>]
4848
```
4949

5050
### dsId-deviceName-instanceName
5151
```
5252
Get-LMDeviceData -DatasourceId <Int32> -DeviceName <String> [-InstanceName <String>] [-StartDate <DateTime>]
53-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
53+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
5454
[<CommonParameters>]
5555
```
5656

5757
### dsId-deviceId-instanceName
5858
```
5959
Get-LMDeviceData -DatasourceId <Int32> -DeviceId <Int32> [-InstanceName <String>] [-StartDate <DateTime>]
60-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
60+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
6161
[<CommonParameters>]
6262
```
6363

6464
### dsId-deviceId-instanceId
6565
```
6666
Get-LMDeviceData -DatasourceId <Int32> -DeviceId <Int32> -InstanceId <Int32> [-StartDate <DateTime>]
67-
[-EndDate <DateTime>] [-Filter <Object>] [-BatchSize <Int32>] [-ProgressAction <ActionPreference>]
67+
[-EndDate <DateTime>] [-Filter <Object>] [-Datapoints <String>] [-ProgressAction <ActionPreference>]
6868
[<CommonParameters>]
6969
```
7070

@@ -76,8 +76,8 @@ It supports various combinations of identifying the device, datasource, and inst
7676

7777
### EXAMPLE 1
7878
```
79-
#Retrieve data using IDs
80-
Get-LMDeviceData -DeviceId 123 -DatasourceId 456 -InstanceId 789
79+
#Retrieve data using IDs for datapoints "cpu" and "memory"
80+
Get-LMDeviceData -DeviceId 123 -DatasourceId 456 -InstanceId 789 -Datapoints "cpu,memory"
8181
```
8282

8383
### EXAMPLE 2
@@ -232,19 +232,18 @@ Accept pipeline input: False
232232
Accept wildcard characters: False
233233
```
234234
235-
### -BatchSize
236-
The number of results to return per request.
237-
Must be between 1 and 1000.
238-
Defaults to 1000.
235+
### -Datapoints
236+
Comma separated list of datapoints to retrieve.
237+
If not provided, all datapoints will be retrieved.
239238
240239
```yaml
241-
Type: Int32
240+
Type: String
242241
Parameter Sets: (All)
243242
Aliases:
244243

245244
Required: False
246245
Position: Named
247-
Default value: 1000
246+
Default value: None
248247
Accept pipeline input: False
249248
Accept wildcard characters: False
250249
```
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
---
2+
external help file: Logic.Monitor-help.xml
3+
Module Name: Logic.Monitor
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Set-LMAWSDiscoverySettings
9+
10+
## SYNOPSIS
11+
Updates AWS Cloud discovery settings for specified AWS accounts in LogicMonitor.
12+
13+
## SYNTAX
14+
15+
### Id (Default)
16+
```
17+
Set-LMAWSDiscoverySettings -AccountId <Int32> -ServiceName <String> -Regions <String[]> [-AutoDelete <Boolean>]
18+
[-DeleteDelayDays <Int32>] [-DisableAlerting <Boolean>] [-ProgressAction <ActionPreference>] [-WhatIf]
19+
[-Confirm] [<CommonParameters>]
20+
```
21+
22+
### Name
23+
```
24+
Set-LMAWSDiscoverySettings -Name <String> -ServiceName <String> -Regions <String[]> [-AutoDelete <Boolean>]
25+
[-DeleteDelayDays <Int32>] [-DisableAlerting <Boolean>] [-ProgressAction <ActionPreference>] [-WhatIf]
26+
[-Confirm] [<CommonParameters>]
27+
```
28+
29+
### Csv
30+
```
31+
Set-LMAWSDiscoverySettings -CsvPath <String> -ServiceName <String> -Regions <String[]> [-AutoDelete <Boolean>]
32+
[-DeleteDelayDays <Int32>] [-DisableAlerting <Boolean>] [-ProgressAction <ActionPreference>] [-WhatIf]
33+
[-Confirm] [<CommonParameters>]
34+
```
35+
36+
## DESCRIPTION
37+
The Set-LMAWSDiscoverySettings function modifies AWS Cloud discovery settings such as monitored regions, automatic deletion policies, and alerting preferences for AWS services within LogicMonitor.
38+
The function supports updating a single AWS account by AccountId or multiple accounts by importing AccountIds from a CSV file.
39+
40+
## EXAMPLES
41+
42+
### EXAMPLE 1
43+
```
44+
Set-LMAWSDiscoverySettings -AccountId 317 -ServiceName "EC2" -Regions "us-east-1","us-west-2"
45+
Updates EC2 discovery settings for AWS account group ID 317 to monitor only us-east-1 and us-west-2 regions.
46+
```
47+
48+
### EXAMPLE 2
49+
```
50+
Set-LMAWSDiscoverySettings -Name "Production AWS Account" -ServiceName "RDS" -Regions "us-east-1","us-east-2" -AutoDelete -DeleteDelayDays 10
51+
Updates RDS discovery settings for the AWS account named "Production AWS Account" with automatic deletion enabled after 10 days.
52+
```
53+
54+
### EXAMPLE 3
55+
```
56+
Set-LMAWSDiscoverySettings -CsvPath "C:\aws_accounts.csv" -ServiceName "EC2" -Regions "us-east-1","us-east-2"
57+
Bulk updates EC2 discovery settings for multiple AWS accounts listed in the CSV file.
58+
```
59+
60+
### EXAMPLE 4
61+
```
62+
Set-LMAWSDiscoverySettings -AccountId 317 -ServiceName "Lambda" -Regions "us-east-1" -AutoDelete -DeleteDelayDays 5 -DisableAlerting
63+
Updates Lambda discovery settings with automatic deletion after 5 days and alerting disabled on termination.
64+
```
65+
66+
## PARAMETERS
67+
68+
### -AccountId
69+
Specifies the LogicMonitor device group ID of the AWS account for which to update discovery settings.
70+
This parameter is mandatory when using the 'Id' parameter set.
71+
72+
```yaml
73+
Type: Int32
74+
Parameter Sets: Id
75+
Aliases: Id
76+
77+
Required: True
78+
Position: Named
79+
Default value: 0
80+
Accept pipeline input: True (ByPropertyName)
81+
Accept wildcard characters: False
82+
```
83+
84+
### -Name
85+
Specifies the name of the AWS account device group.
86+
This parameter is mandatory when using the 'Name' parameter set.
87+
88+
```yaml
89+
Type: String
90+
Parameter Sets: Name
91+
Aliases:
92+
93+
Required: True
94+
Position: Named
95+
Default value: None
96+
Accept pipeline input: False
97+
Accept wildcard characters: False
98+
```
99+
100+
### -CsvPath
101+
Specifies the path to a CSV file containing multiple AWS AccountIds to update in bulk.
102+
The CSV must have an "AccountId" column.
103+
This parameter is part of the 'Csv' parameter set.
104+
105+
```yaml
106+
Type: String
107+
Parameter Sets: Csv
108+
Aliases:
109+
110+
Required: True
111+
Position: Named
112+
Default value: None
113+
Accept pipeline input: False
114+
Accept wildcard characters: False
115+
```
116+
117+
### -ServiceName
118+
Specifies the AWS service name (e.g., "EC2", "RDS", "Lambda") whose discovery settings are to be updated.
119+
120+
```yaml
121+
Type: String
122+
Parameter Sets: (All)
123+
Aliases:
124+
125+
Required: True
126+
Position: Named
127+
Default value: None
128+
Accept pipeline input: False
129+
Accept wildcard characters: False
130+
```
131+
132+
### -Regions
133+
Specifies an array of AWS regions (e.g., "us-east-1","us-east-2") to monitor for the specified service.
134+
135+
```yaml
136+
Type: String[]
137+
Parameter Sets: (All)
138+
Aliases:
139+
140+
Required: True
141+
Position: Named
142+
Default value: None
143+
Accept pipeline input: False
144+
Accept wildcard characters: False
145+
```
146+
147+
### -AutoDelete
148+
Specifies whether to enable automatic deletion of terminated AWS resources.
149+
150+
```yaml
151+
Type: Boolean
152+
Parameter Sets: (All)
153+
Aliases:
154+
155+
Required: False
156+
Position: Named
157+
Default value: None
158+
Accept pipeline input: False
159+
Accept wildcard characters: False
160+
```
161+
162+
### -DeleteDelayDays
163+
Specifies the number of days to wait before automatically deleting terminated resources.
164+
Defaults to 7.
165+
166+
```yaml
167+
Type: Int32
168+
Parameter Sets: (All)
169+
Aliases:
170+
171+
Required: False
172+
Position: Named
173+
Default value: None
174+
Accept pipeline input: False
175+
Accept wildcard characters: False
176+
```
177+
178+
### -DisableAlerting
179+
Specifies whether to disable alerting automatically after resource termination.
180+
181+
```yaml
182+
Type: Boolean
183+
Parameter Sets: (All)
184+
Aliases:
185+
186+
Required: False
187+
Position: Named
188+
Default value: None
189+
Accept pipeline input: False
190+
Accept wildcard characters: False
191+
```
192+
193+
### -WhatIf
194+
Shows what would happen if the cmdlet runs.
195+
The cmdlet is not run.
196+
197+
```yaml
198+
Type: SwitchParameter
199+
Parameter Sets: (All)
200+
Aliases: wi
201+
202+
Required: False
203+
Position: Named
204+
Default value: None
205+
Accept pipeline input: False
206+
Accept wildcard characters: False
207+
```
208+
209+
### -Confirm
210+
Prompts you for confirmation before running the cmdlet.
211+
212+
```yaml
213+
Type: SwitchParameter
214+
Parameter Sets: (All)
215+
Aliases: cf
216+
217+
Required: False
218+
Position: Named
219+
Default value: None
220+
Accept pipeline input: False
221+
Accept wildcard characters: False
222+
```
223+
224+
### -ProgressAction
225+
{{ Fill ProgressAction Description }}
226+
227+
```yaml
228+
Type: ActionPreference
229+
Parameter Sets: (All)
230+
Aliases: proga
231+
232+
Required: False
233+
Position: Named
234+
Default value: None
235+
Accept pipeline input: False
236+
Accept wildcard characters: False
237+
```
238+
239+
### CommonParameters
240+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
241+
242+
## INPUTS
243+
244+
### You can pipe objects containing AccountId properties to this function.
245+
## OUTPUTS
246+
247+
### Returns a LogicMonitor.DeviceGroup object containing the updated AWS account group information.
248+
## NOTES
249+
This function requires a valid LogicMonitor API authentication.
250+
Use Connect-LMAccount before running this command.
251+
252+
## RELATED LINKS

0 commit comments

Comments
 (0)