使用 ETW 和 EVENT SESSION 监视 SELECT 语句
我目前正在 SQL Server 2008 上使用 ETW 来监视(并最终记录)SQL 语句的执行。我希望监视的事件是存储过程执行、INSERT、UPDATE、DELETE 和... SELECT 语句。
我可以通过使用以下事件创建事件会话来监视 SP、INSERT、UPDATE 和 DELETE:
- sqlserver.sp_statement_completed
- sqlserver.sp_statement_starting
- sqlserver.sql_statement_completed
- sqlserver.sql_statement_starting
我还为每个事件添加了一个操作,以将实际的 SQL 语句添加到事件:sqlserver.sql_text
我的会话基本上看起来像这样:
CREATE EVENT SESSION SomeTestEventSession ON SERVER
ADD EVENT sqlserver.sp_statement_completed (ACTION (sqlserver.sql_text) WHERE sqlserver.database_id > 4),
(...)
什么我应该在上面的事件中添加事件来监视数据库上的简单SELECT 语句吗?我知道这会产生大量活动,但是一旦我可以监视这些语句,我将尝试通过添加一些过滤操作来微调这个野兽,以减少记录事件的实际数量。
提前致谢!
I am currently working with ETW on SQL Server 2008 to monitor (and eventually log) SQL statement execution. The events that I am looking to monitor are stored proc execution, INSERT, UPDATE, DELETE and... SELECT statements.
I am able to monitor the SPs, INSERT, UPDATE and DELETE by creating an EVENT SESSION with the following events:
- sqlserver.sp_statement_completed
- sqlserver.sp_statement_starting
- sqlserver.sql_statement_completed
- sqlserver.sql_statement_starting
I also include an action with each event to add the actual SQL statement to the event: sqlserver.sql_text
My session basically looks something like this:
CREATE EVENT SESSION SomeTestEventSession ON SERVER
ADD EVENT sqlserver.sp_statement_completed (ACTION (sqlserver.sql_text) WHERE sqlserver.database_id > 4),
(...)
What event should I add to the ones above to monitor simple SELECT statements on my database? I am aware this will create a lot of activity, but once I can monitor the statements, I will try to fine tune the beast by adding some filtering actions to reduce the actual number of logged events.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有,我一定忽略了一些东西,因为 sql_statement_completed 似乎确实监视 SELECT 语句。
All, I must have overlooked something, because it seems the sql_statement_completed does monitor the SELECT statements.