solarwinds / OrionSDK

SDK for the SolarWinds Orion platform, including tools, documentation, and samples in PowerShell, C#, Go, Perl, and Java.
https://thwack.com/OrionSDK
Apache License 2.0
397 stars 139 forks source link

Are the AlertActiveIDs and EventIDs auto-incremented and changeable? #281

Open crestdatasystems opened 3 years ago

crestdatasystems commented 3 years ago

We are trying to pull the Alerts and Events from the SolarWinds platform in the form of the Incidents for our product. It uses a polling mechanism to fetch incidents based on a checkpoint mechanism which usually uses the timestamp. To avoid duplication of incidents we are using AlertActiveID/EventID instead of the TriggeredDateTime/EventTime.

Can anyone from the team please confirm whether the AlertActiveID and the EventID are changeable or not? Also is it a part of SolarWinds Orion's business logic that the IDs are auto-incremented?

Please refer to the below SWQL queries for reference: Query to fetch Alerts: SELECT A.AlertActiveID, A.AlertObjectID, A.Acknowledged, A.AcknowledgedBy, A.AcknowledgedDateTime, A.AcknowledgedNote, A.TriggeredDateTime, A.TriggeredMessage, A.NumberOfNotes, A.LastExecutedEscalationLevel, A.DisplayName, A.Description as AlertDescription, A.InstanceType, A.Uri, A.InstanceSiteId, B.AlertID, B.EntityUri, B.EntityType, B.EntityCaption, B.EntityDetailsUrl, B.EntityNetObjectId, B.RelatedNodeUri, B.RelatedNodeId, B.RelatedNodeDetailsUrl, B.RelatedNodeCaption, B.RealEntityUri, B.RealEntityType, B.TriggeredCount, .LastTriggeredDateTime, B.Context, B.AlertNote, C.AlertMessage, C.AlertRefID, C.Name, C.Description as ConfigurationDescription, C.ObjectType, C.Enabled, C.Frequency, C.Trigger, C.Reset, C.Severity, C.NotifyEnabled, C.NotificationSettings, C.LastEdit, C.CreatedBy, C.Category, C.Canned, D.ResponsibleTeam FROM Orion.AlertActive AS A INNER JOIN Orion.AlertObjects AS B ON A.AlertObjectID = B.AlertObjectID INNER JOIN Orion.AlertConfigurations AS C ON B.AlertID = C.AlertID INNER JOIN Orion.AlertConfigurationsCustomProperties AS D ON C.AlertID = D.AlertID WHERE A.AlertActiveID>{AlertActiveID}

Query to fetch Events: SELECT A.EventID, A.EventTime, A.NetworkNode, A.NetObjectID, A.NetObjectValue, A.EngineID, A.EventType, A.Message, A.Acknowledged, A.NetObjectType, A.TimeStamp, A.DisplayName, A.Description, A.InstanceType, A.Uri,A.InstanceSiteId, B.Name FROM Orion.Events as A INNER JOIN Orion.EventTypes as B ON A.EventType=B.EventType WHERE A.EventID>{EventID}

tdanner commented 3 years ago

Yes, both of those fields are auto-increment IDs at the database level.

crestdatasystems commented 3 years ago

@tdanner thank you for helping, we would also like to know if these fields cannot be changed by the customer. Like customer won't be able to change it to 2000 or 50001 to start the Ids.

danjagnow commented 3 years ago

@tdanner thank you for helping, we would also like to know if these fields cannot be changed by the customer. Like customer won't be able to change it to 2000 or 50001 to start the Ids.

There is no way to set the ID via the API for Orion. However, you can manually set autoincrement IDs in the SQL Server tables themselves. See this StackOverflow answer for a brief example of how to use DBCC CHECKIDENT with the RESEED argument.

This isn't a supported scenario, so you'll want to try this in a test/staging environment before attempting a change like this in your production environment.

crestdatasystems commented 3 years ago

@danjagnow thank you for answering, would this be done by any customer or only admin can do it?

danjagnow commented 3 years ago

It would need to be done by a database admin on the SQL Server that is home to the Orion database. See the Permissions section of that document for the exact requirements.