Share via

Does Microsoft.SqlServer.XEvent.XELite.XELiveEventStreamer work with SSAS ring_buffer or event_stream?

Poul Junge 21 Reputation points
2021-05-03T10:34:49.893+00:00

I'm trying to extract extended events from a stream on a SSAS server with the following code:

Microsoft.SqlServer.XEvent.XELite.XELiveEventStreamer xEvents = new XELiveEventStreamer("Data Source=.;Initial Catalog=master;Integrated Security=SSPI", "pju_RingBuffer");
var cancellationToken = new CancellationTokenSource();

xEvents.ReadEventStream(
            xevent =>
            {
                Console.WriteLine(xevent.Name);
                return Task.CompletedTask;
            },
            cancellationToken.Token
            );

Console.WriteLine("Hit anykey");
Console.ReadKey();
cancellationToken.Cancel();

But nothing comes out.

It works for ring_buffers on a SQL server or if I save the SSAS server events to a .xel file.

A related question... Is the documentation for the Microsoft.SqlServer.XEvent.XELite package available anywhere?

SQL Server Analysis Services
SQL Server Analysis Services

A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

Darren Gosbell 2,376 Reputation points
2021-05-07T14:24:28.787+00:00

AMO is for modelling and administration as far as I know. Not tracking activity.

This is not correct. AMO can do modelling, administration and tracing. This is the library I use in DAX Studio for capturing server side trace events. It cannot capture XEvents, but it can capture profiler events. So any event you can capture with SQL Profiler can be captured with AMO.

One more thing... You mention the ReadMe.... I have been looking and looking for just a small piece of documentation for this package on the Nuget page.
Where did you find it?

Interesting, I did not realise at the time but when I googled for "XELiveEventStreamer examples" it took me to an older release on nuget which had a readme with example code. The following link https://www.nuget.org/packages/Microsoft.SqlServer.XEvent.XELite/2019.7.2.9# had the sample code below:

static void OutputXELStream(string connectionString, string sessionName)
{
    var cancellationTokenSource = new CancellationTokenSource();

    var xeStream = new XELiveEventStreamer(connectionString, sessionName);

    Console.WriteLine("Press any key to stop listening...");
    Task waitTask = Task.Run(() =>
        {
            Console.ReadKey();
            cancellationTokenSource.Cancel();
        });

    Task readTask = xeStream.ReadEventStream(() =>
        {
            Console.WriteLine("Connected to session");
            return Task.CompletedTask;
        },
        xevent =>
        {
            Console.WriteLine(xevent);
            Console.WriteLine("");
            return Task.CompletedTask;
        },
        cancellationTokenSource.Token);


    try
    {
        Task.WaitAny(waitTask, readTask);
    }
    catch (TaskCanceledException)
    {
    }

    if (readTask.IsFaulted)
    {
        Console.Error.WriteLine("Failed with: {0}", readTask.Exception);
    }
}

Was this answer helpful?


4 additional answers

Sort by: Most helpful
  1. Darren Gosbell 2,376 Reputation points
    2021-05-22T00:08:18.713+00:00

    @TomerRotstein-7779 thanks for chiming in here.

    I'm not sure what SSAS Tabular instance exposes as a channel, but if its TDS, XELite should be able to connect to it.

    Unfortunately while SSAS does expose XEvents it uses a protocol called XMLA not TDS

    Was this answer helpful?

    0 comments No comments

  2. tomerr 11 Reputation points Microsoft Employee
    2021-05-21T17:54:20.127+00:00

    Hi,

    I'm the owner of XELite. XELite works with xevents. The channel for getting the xevents into XELite is TDS, as mentioned earlier. I'm not sure what SSAS Tabular instance exposes as a channel, but if its TDS, XELite should be able to connect to it.

    For the documentation, we'll fix the readme with the examples back in the next version.

    Tomer

    Was this answer helpful?


  3. Darren Gosbell 2,376 Reputation points
    2021-05-06T00:43:44.177+00:00

    I have not seen very much documentation at all on consuming SSAS XEvents from code. I'm not sure if that XELiveEventStreamer works with SSAS, but you might be able to use something like the following example https://gist.github.com/albertospelta/358ccc134f6ceb397950719e3b857c48

    Was this answer helpful?


  4. Lukas Yu -MSFT 5,826 Reputation points
    2021-05-04T08:50:03.237+00:00

    I have not try this in code with SSAS , can't judge wether it work or not, I add a SQL Server General tag for this case so some community member with XEvent coding experience could see this question. Hope you don't mind.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.