Observability
How to pull node's Custom Properties and update them using API
This article helps in updating the node custom properties using the API.
First published date
Last published date
Overview
This article provides detailed insights into updating node custom properties using the API by pulling from the DB, with possible SWQL/SQL queries.
Product section
Resolution
Write a SWQL/SQL query to get the nodes' custom properties.
Next, update the custom properties.
The following sample query retrieves the custom properties from a node.
-- Scripts are not supported under any SolarWinds support program or service.
-- Scripts are provided AS IS without warranty of any kind. SolarWinds further
-- disclaims all warranties including, without limitation, any implied warranties
-- of merchantability or of fitness for a particular purpose. The risk arising
-- out of the use or performance of the scripts and documentation stays with you.
-- In no event shall SolarWinds or anyone else involved in the creation,
-- production, or delivery of the scripts be liable for any damages whatsoever
-- (including, without limitation, damages for loss of business profits, business
-- interruption, loss of business information, or other pecuniary loss) arising
-- out of the use of or inability to use the scripts or documentation.
SELECT NodeID, Caption, CustomPropertyName1, CustomPropertyName2 FROM Orion.Nodes WHERE NodeID = @nodeID
This will return the node along with its custom properties.
Next, use the SWIS API to update the node entity by setting the custom property fields.
Example REST API PATCH request to update a node's custom property:
-- Scripts are not supported under any SolarWinds support program or service.
-- Scripts are provided AS IS without warranty of any kind. SolarWinds further
-- disclaims all warranties including, without limitation, any implied warranties
-- of merchantability or of fitness for a particular purpose. The risk arising
-- out of the use or performance of the scripts and documentation stays with you.
-- In no event shall SolarWinds or anyone else involved in the creation,
-- production, or delivery of the scripts be liable for any damages whatsoever
-- (including, without limitation, damages for loss of business profits, business
-- interruption, loss of business information, or other pecuniary loss) arising
-- out of the use of or inability to use the scripts or documentation.
PATCH /SolarWinds/InformationService/v3/Json/Orion/Nodes/NodeID
Content-Type: application/json
{
"CustomPropertyName1": "NewValue"
}
Note: Replace NodeID with the actual node ID and CustomPropertyName1 with the actual custom property name.
For more information, refer to the following admin guides.
Use macros and custom properties to populate API requests in SAM
Create a custom property in the SolarWinds Platform
Custom properties in the SolarWinds Platform
Refer to the following for best practices on API-based integrations.
https://documentation.solarwinds.com/en/success_center/sam/content/sam-api-poller-methods.htm
https://documentation.solarwinds.com/en/success_center/sam/content/sam-api-poller-requirements.htm
Note:
- Ensure you have proper permissions and authentication to access the API.
- Custom property names must follow naming conventions and use the Latin1 character set.
- Authentication is typically done via API token or basic auth depending on your setup.
- Custom property names are case-insensitive but must match exactly as defined.