stevevillardi / Logic.Monitor

LogicMonitor PowerShell Module for automating LM Portal tasks using APIv3
https://www.powershellgallery.com/packages/Logic.Monitor
Mozilla Public License 2.0
23 stars 3 forks source link

Ability to add / update multiple custom properities per device #9

Closed jmossuk closed 1 year ago

jmossuk commented 1 year ago

Hi Steve,

Long time no speak, I hope you are keeping well. Is there a simple way to either add or update multiple custom properties per device in a single request to LM. The reason I ask is that right now for each device we have 15 custom properties so when we are doing a bulk update every night we run into the issue with the rate limit issue of more than 200 requests per minute.

Is there a cmdlet which would allow us to overcome this?

What would be nice is if we can define all the custom properties with there values in a single array and then make one request which would either create the entries if they don't exist or if they already exist to update them. Given the number of devices we had, this would really help.

stevevillardi commented 1 year ago

@jmossuk what cmdlets are you using to perform the update? You should just be able to use the normal Set-LMDevice cmdlet and specify just the -Properties parameter that takes a hashtable of custom properties to add/update.

jmossuk commented 1 year ago

Hi Steve,

I've tried using the Set-LMDevice cmdlet and using a hashtable but it seems to be throwing an error message and I'm wondering if it's because some custom properties don't exist whereas some do, any ideas?

Here are a few screenshots of the contents of the hashtable, part of the code which populates the hashtable and tries to add / update the device and also the error message I'm getting.

[image: screenshot - hashtable contents.png]

[image: Screenshot - Code example.png]

[image: Screenshot - Error Message.png]

Is it because I can't do an add and an update in the same command? any ideas I would be most grateful for.

Not sure if it matters but I'm using the latest version of your module (3.9.2)

Best regards

Jamie

On Mon, Nov 28, 2022 at 4:46 PM Steve Villardi @.***> wrote:

@jmossuk what cmdlets are you using to perform the update? You should just be able to use the normal Set-LMDevice cmdlet and specify just the -Properties parameter that takes a hashtable of custom properties to add/update. — Reply to

@jmossuk https://urldefense.com/v3/__https://github.com/jmossuk__;!!FzMMvhmfRQ!oOg3m4yN3vDBvh4O5ITIOE53LQQkywajeqswks9VftwXxQdIGCfioKPddQZ2vJahk7QQp_Yh2auij5IHf8UnJSFF4vc$ what cmdlets are you using to perform the update? You should just be able to use the normal Set-LMDevice cmdlet and specify just the -Properties parameter that takes a hashtable of custom properties to add/update.

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/stevevillardi/Logic.Monitor/issues/9*issuecomment-1329416746__;Iw!!FzMMvhmfRQ!oOg3m4yN3vDBvh4O5ITIOE53LQQkywajeqswks9VftwXxQdIGCfioKPddQZ2vJahk7QQp_Yh2auij5IHf8UnGFjXNGI$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AZFYJMQASBPLRX25DVUCG6DWKTOVTANCNFSM6AAAAAASNMOOBA__;!!FzMMvhmfRQ!oOg3m4yN3vDBvh4O5ITIOE53LQQkywajeqswks9VftwXxQdIGCfioKPddQZ2vJahk7QQp_Yh2auij5IHf8UnIE2CVcI$ . You are receiving this because you were mentioned.Message ID: @.***>

-- Jamie Moss Principal Voice Engineer / Lead Architect

Booking.com Ltd. 8 Buckingham Avenue Slough United Kingdom SL1 4AX Tel: +44 208 612 8797 Mobile: +44 7740 628896

[image: Booking.com] https://www.booking.com/ Making it easier for everyone to experience the world since 1996 43 languages, 214+ offices worldwide, 141,000+ global destinations, 29 million reported listings Subsidiary of Booking Holdings Inc. (NASDAQ: BKNG)

stevevillardi commented 1 year ago

I cannot see the screenshots you tried to post but I am also unable to reproduce the issue on my end. The property update method is controlled via the parameter -PropertiesMethod which by default is set to "replace". That would update existing properties or create them if they do not exist.

See the example below:

example-update

stevevillardi commented 1 year ago

@jmossuk Are you still having the issue? If so can you repost your images so I can see how you are running the command.