I'm writing a SCOM inbound connector and want to create alerts programmatically. I have worked out how to query and resolve alerts using the SDK, but actually creating them has so far eluded me.
Surely there must be a way of doing this?
Thanks in advance for any suggestions.
Edit:
The documentation http://msdn.microsoft.com/en-us/library/hh329020.aspx clearly states that such a thing is possible:
You can use inbound connectors to insert performance, event, and alert data into Operations Manager from an external management system.
I have now got a working solution to this problem. For those who are interested, this is what I did.
Generate events using the SDK as normal. This amounts to calling InsertCustomMonitoringEvent in the way shown in the example.
Write a Rule in the management pack that uses the data source Microsoft.SystemCenter.SdkEventProvider and the writer System.Health.GenerateAlert. The rule should target the objects which you generate the events for.
Add a condition detection module to the rule which filters on the EventLevel property. This means you must have 3 copies of the rule for Informational, Warning and Error type alerts. This allows you to map the EventLevel=1 -> Severity=2 (Error), EventLevel=2 -> Severity=1 (Warning), EventLevel=4 -> Severity=0 (Informational).
You might also need to add a filter on the PublisherName of the event to map onto the correct Target object, using some unique key property of the $Target$.
With all this in place you will of course be generating both events and alerts with the same content, but it does at least give you a working method of generating alerts using the SDK. Quite why they didn't add a Microsoft.SystemCenter.SdkAlertProvider type data source I don't know... That would've made life much easier.