SQL Server資料庫警示改進

來源:互聯網
上載者:User

標籤:sys.messages   alert   

  考慮對生產環境所有SQL Server伺服器開啟資料庫郵件功能,它是資料庫內建的郵件發送功能,通過配置到郵件伺服器的訪問,及時接收SQL Server事件警示。


  SQL Server警報是基於引擎的事件通知機制發送警示,當事件發生時出發警示通知。

 

  現階段,需要收集如下兩類SQL Server事件警示:

  • Severity - 事件嚴重性層級13到25警示;

  • Error Number - 包括作業系統錯誤、IO錯誤、記憶體錯誤、AlwaysOn狀態相關警示。


策略調整


  我們考慮將這些需要監控的警示整合到應用程式記錄檔,接入ELK日誌分析系統。


  我們瞭解到,在下列情況下,SQL Server 和 SQL Server 應用程式產生的錯誤/訊息將發送到Windows 應用程式記錄檔:

  • 嚴重層級為 19 或更高的 sys.messages 錯誤

  • 任何使用 WITH LOG 文法調用的 RAISERROR 陳述式

  • 所有使用 sp_altermessage 修改或建立的 sys.messages 錯誤

  • 所有使用 xp_logevent 記錄的日誌事件

    引用自 https://docs.microsoft.com/en-us/sql/ssms/agent/create-an-alert-using-severity-level“Severity levels from 19 through 25 send a SQL Server message to the Microsoft Windows application log and trigger an alert. Events with severity levels less than 19 will trigger alerts only if you have used sp_altermessage, RAISERROR WITH LOG, or xp_logevent to force them to be written to the Windows application log. ”


針對上文提到、我們需要監控的Severity和Error Number警示,我們需要做如下變更調整:

  • Severity - 經過討論,不記錄嚴重層級19以下的使用者層級的錯誤,19層級及以上的Fatal Error預設記錄到應用程式記錄檔,我們不用做任何更改。

  • Error Number - 需要監控的錯誤,根據附件的查詢結果,部分錯誤號碼的is_event_logged欄位為0,表示沒有記錄到應用程式記錄檔。可以通過上面的sp_altermessage修改該欄位為1達到記錄到應用程式記錄檔的目的。



SQL Server資料庫警示改進

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.