Specifications

164 CHAPTER 8 Complex Event Processing with StreamInsight
Windows PowerShell Diagnostics
For quick analysis, you can use Windows PowerShell scripts to view diagnostic information
rather than writing a complete diagnostic application. Before you can use a Windows Pow-
erShell script, the StreamInsight server must be running a query. If the server is running as a
hosted assembly, you must expose the Web service.
You start the diagnostic process by loading the Microsoft.ComplexEventProcessing assem-
bly from the Global Assembly Cache (GAC) into Windows PowerShell by using the following
code:
PS C:\>
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.ComplexEventProcessing")
Then you need to create a connection to the StreamInsight host process by using the code
in this example:
PS C:\> $server =
Microsoft.ComplexEventProcessing.Server]::Connect("http://localhost/StreamInsight")
Then you can use the GetDiagnosticView() method to retrieve statistics for an object, such
as the Event Manager, as shown in the following code:
PS C:\> $dv = $server.GetDiagnosticView("cep:/Server/EventManager")
PS C:\> $dv
To retrieve information about a query, you must provide the full name, following the
StreamInsight hierarchical naming schema. For example, for an application named myApplica-
tion with a query named myQuery, you use the following code:
PS C:\> $dv =
$server.GetDiagnosticView("cep:/Server/Application/myApplication/Query/myQuery")
PS C:\> $dv
NOTE For a complete list of metrics and statistics that you can query by using diagnostic
views, refer to the SQL Server Books Online topic “Monitoring the CEP Server and Queries”
at http://msdn.microsoft.com/en-us/library/ee391166(SQL.105).aspx.