Sql-server – How to recreate a SQL Server audit without an audit gap

auditsql server

I have some audits and audit specifications on a SQL Server 2012 instance and I want to reapply the audit and audit spec definition every evening in case the DBAs change it. I have measured the time taken to do this on one of my Dev boxes, and it's quite short, but there's still a window there where some audit data could get lost. From a quick test I did to measure the time taken:

AuditRecreate_ms
----------------
23

(1 row(s) affected)

AuditSpecRecreate_ms
--------------------
16

(1 row(s) affected)

It's possible with SQLTrace because you can create a new trace and then delete the old one, and no audit data gets lost. I'm trying to move away from SQL Trace but retain an uninterrupted audit but at the same time make sure the audit definitions do not change. Any ideas here?

Best Answer

I want to reapply the audit and audit spec definition every evening in case the DBAs change it

Engaging in an arms race against the rightful admins is only going to cause delay and confusion.

  • Explain to DBAs the role and purpose of the audit, ask them not to change it
  • Use the audit itself to detect tampering
  • Follow up upon detecting tampering with administrativia to get the responsible party questioned/rewarded/punished depending on situation

If you cannot enforce above, it means by definition that you are not be able to enforce an audit, so why bother?

As for specifically the question, this advice applies always, to any situation: do not blindly re-apply a template 'in case it changed', only apply it if it had changed.

Ask your DBAs to help you, do not ask us to help you against your DBAs.