9 Replies Latest reply on Jun 20, 2018 12:08 PM by equalswql

    Is it possible to update the volume capacity thresholds via the REST API?

    ryanbaham

      I am looking to make updates to volume capacity thresholds in Orion. I have hundreds of volumes to update thresholds on and am looking to utilize the REST Api to make the changes quickly and accurately. Is this possible?

       

      I am pretty familiar with the API but am stumbling trying to even pull the existing thresholds via the SWIS Uri (example below):

       

      Uri for volume from forecast capacity table:

      swis://SYMX-SW-W01.symxsol.local/Orion/Orion.Nodes/NodeID=79/Volumes/VolumeID=5942/ForecastCapacity/EntityType="Orion.Volumes",MetricId=3

       

      Respose from GET to https://<SolarWinds>:17778/SolarWinds/InformationService/v3/Json/swis://<solarwindsFQDN>/Orion/Orion.Nodes/NodeID=79/Volumes/VolumeID=5942/ForecastCapacity/EntityType="Orion.Volumes",MetricId=3

       

      {
        "Message": "Invalid key properties specified for entity Orion.VolumesForecastCapacity.\r\nParameter name: filter",
        "ExceptionType": "System.ArgumentException",
        "FullException": "System.ArgumentException: Invalid key properties specified for entity Orion.VolumesForecastCapacity.\r\nParameter name: filter\r\n   at SolarWinds.InformationService.Core.SwisUriResolver.ValidateAndResolveFilter(IEntityType entity, SwisUriFilter filter, Boolean isHosted)\r\n   at SolarWinds.InformationService.Core.SwisUriResolver.ValidateAndResolveUri(SwisUri uri, IQueryExecutionContext context)\r\n   at SolarWinds.InformationService.Core.CrudProcessor.Read[T](SwisUri uri, IQueryExecutionContext context)\r\n   at SolarWinds.InformationService.Core.InformationService.Read(String uri)"
      }
      

       

      Using the core Volume Uri I was able to pull all sorts of properties back but not the Volume Capacity Thresholds.

       

      Any help would be much appreciated!

        • Re: Is it possible to update the volume capacity thresholds via the REST API?
          tomas.vrabel

          Below I pasted Python script that set forecast settings.

          You need to use SWIS CRUD update operation on Orion.ForecastCapacitySettings entity.

           

          Please check what metricId is used in your environment, in my environment metricId = 3 is used for Forecast.Metric.PercentDiskUsed. Metrics are represented by Orion.ForecastMetrics entity.

           

           

              swis = SwisClient(server, username, password)
          
              volumeId = 14
              metricId = 3
          
              results = swis.query("SELECT Uri FROM Orion.ForecastCapacitySettings WHERE InstanceId=@id and MetricId=@metricId", id = volumeId, metricId = metricId)['results']  # set valid InstanceId
          
          
              if len(results) == 0:
                 print("no entry with given ID found")
                 return
              
              capacitySetting = results[0]
              capacitySettingUri = capacitySetting['Uri']
          
              print ("found capacitySettingUri: " + capacitySettingUri)
              
              swis.update(capacitySettingUri, CriticalThreshold=60, WarningThreshold=50)
          
              newValue = swis.read(capacitySettingUri)
              print ("Critical threshold:", newValue['CriticalThreshold'])
              print ("Warning threshold:", newValue['WarningThreshold'])
          
          
          
          
          
          
          
          1 of 1 people found this helpful
            • Re: Is it possible to update the volume capacity thresholds via the REST API?
              equalswql

              Hello tomas.vrabel,

               

              This is really helpful, thanks for the info. This is working for me if a custom threshold was already defined by setting in the UI.

               

              To create a new volume threshold set, I can use New-SwisObject and define: @{MetricID = 3;InstanceID = $instanceID;Enabled = 'True';UsePeakValues = 'False';CriticalThreshold = $crit;WarningThreshold = $warn} (Using powershell) to create a new setting entry and it behaves the same as if done through the UI.

               

              However I'm not having the same luck with other metrics. They seem to behave differently. I'm assuming this is because the other thresholds require a comparison operator.

              Can you provide any info on how to create these using API only?

              (

              Forecast.Metric.PercentMemoryUsed

              Forecast.Metric.CpuLoad/

              Forecast.Metric.InInterfacePercentUtilization

              Forecast.Metric.OutInterfacePercentUtilization

              )

               

              Thank you,

               

              =swql

                • Re: Is it possible to update the volume capacity thresholds via the REST API?
                  tomas.vrabel

                  Hello equalswql,

                  you are right, CPU and Memory thresholds behave differently than forecast capacity settings.

                  Unfortunately it seems that currently it is not possible to set CPU or memory thresholds through Orion SDK, please see related reply Re: Orion Default Thresholds Bulk Change?

                   

                  The only thing that works for me is to update "Capacity trending" for CPU Load or Memory Trending thresholds using script above and changing property UsePeakValues  = 1 (or = 0). Changing of CriticalThreshold or WarningThreshold does not affect threshold values.

                  1 of 1 people found this helpful
                    • Re: Is it possible to update the volume capacity thresholds via the REST API?
                      equalswql

                      tomas.vrabel,

                       

                      So I did a little bit of testing with regards to the behavior using the UI and it's corresponding behavior in SWIS. What I found:

                       

                      1) When I enable a custom memory/cpu threshold, I do see an entry gets created in Orion.ForecastCapacitySettings, only (as you said) the threshold values are null in that entry.

                      Disabling the custom threshold from the UI does not cause the newly created threshold row to get removed (as is the behavior with custom volume thresholds)

                       

                      2) Thresholds get updated for CPU/Memory in:

                      Orion.NodesForecastCapacity

                      Orion.ForecastCapacity

                       

                       

                      However, I noticed in the following table:

                      Orion.Thresholds - Threshold Type Set to 1 (from 0), ThresholdOperator Set to 0 (from 1)

                      only for objects with custom thresholds.

                       

                      3) By flipping the values for ThresholdType and ThresholdOperator (via SQL, since updating isn't allowed via SWIS - which would be preferable) that custom threshold gets disabled in the UI (success)

                       

                       

                      4) Next, I'll be testing if disabling/enabling the custom threshold functions as normal when using an CPU/Memory alert for "reached critical/warning value". If so, then SQL is the only way I can find to do this at the moment (unless you have another idea.)

                       

                      Update:

                       

                      Valid options for the ThresholdOperators column:

                      0 - greater than

                      1 - greater than or equal to

                      2 - equal to

                      3 - less than or equal to

                      4 - less than

                      5 - not equal to

                       

                      To create a new entry in the thresholds table (SQL) I used the following statement:

                       

                      INSERT INTO [dbo].[Thresholds] (InstanceID, ThresholdType,ThresholdNameID, ThresholdOperator, Warning, Critical)

                      VALUES ($nodeID, 1, 1, 0, 4, 5);

                      I then created an alert based on warning threshold reached for CPUload and the alert triggered.

                      So to recap:


                      To enable a custom threshold for CPU/Memory:

                      1) Create entry in Orion.ForecastCapacitySettings

                      2) Create entry in SQL using above statement

                       

                      and the reverse to disable.


                      Would still prefer to do step 2 using SWQL if you have some other method.


                      Thank you,

                      =swql

                        • Re: Is it possible to update the volume capacity thresholds via the REST API?
                          tomas.vrabel

                          Hello equalswql,

                          I think you are correct, described approach will work. However as you mention it leverages SQL to modify data and it's not good practice to make changes directly on DB level, SQL queries may break in future versions.

                          Unfortunately I'm not aware of any other way how to do step 2) using SDK.

                           

                          Notes related to table values:

                          • options listed above for ThresholdOperators  are correct
                          • options for ThresholdTypes are 0 = Global, 1 = Static, 2 = Dynamic.
                          • options for ThresholdNameID seems to be matched to table [dbo].[ThresholdsNames]. There is foreign-key constraint defined for ThresholdNameID.

                           

                          I will discuss possibility to extend SDK to allow threshold change. I like it as supporting mass change of threshold sounds reasonable to me.

                          1 of 1 people found this helpful