Home

Help with log analytics query to check SQL database availability

%3CLINGO-SUB%20id%3D%22lingo-sub-428044%22%20slang%3D%22en-US%22%3EHelp%20with%20log%20analytics%20query%20to%20check%20SQL%20database%20availability%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-428044%22%20slang%3D%22en-US%22%3E%3CP%3EI%20need%20a%20log%20analytics%20query%20that%20will%20tell%20me%20whether%20a%20particular%20SQL%20database%20is%20available%20or%20not.%20In%20some%20instances%2C%20database%20was%20down.%20We%20would%20like%20to%20create%20an%20alert%20using%20a%20query%20in%20case%20database%20is%20not%20available.%26nbsp%3B%20Can%20anyone%20help%20with%20this%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-428044%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%20Database%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-432717%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20with%20log%20analytics%20query%20to%20check%20SQL%20database%20availability%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-432717%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F318527%22%20target%3D%22_blank%22%3E%40sambitmahanta%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20used%20Azure%20functions%20to%20query%20a%20SQL%20database%20and%20then%20send%20the%20result%20to%20Azure%20Log%20Analytics%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20the%20website%20I%20used%20as%20a%20reference%3C%2FP%3E%3CP%3E%3CA%20title%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-nz%2Fazure%2Fazure-monitor%2Fplatform%2Fdata-collector-api%23sample-requests%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-nz%2Fazure%2Fazure-monitor%2Fplatform%2Fdata-collector-api%23sample-requests%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CFONT%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-nz%2Fazure%2Fazure-monitor%2Fplatform%2Fdata-collector-api%23sample-requests%3C%2FFONT%3E%3C%2FA%3E%3C%2FP%3E%3CDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EThis%20forum%20will%20not%20permit%20me%20to%20paste%20the%20code%20here%20so%20I%20will%20attach%20an%20image%20of%20it.%20Don't%20fear%20the%20code%20is%20all%20detailed%20inside%20the%20webpage%20at%20the%20above%20URL.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
sambitmahanta
Occasional Visitor

I need a log analytics query that will tell me whether a particular SQL database is available or not. In some instances, database was down. We would like to create an alert using a query in case database is not available.  Can anyone help with this?

1 Reply

Hi @sambitmahanta 

 

I used Azure functions to query a SQL database and then send the result to Azure Log Analytics 

 

This is the website I used as a reference

https://docs.microsoft.com/en-nz/azure/azure-monitor/platform/data-collector-api#sample-requests

 
This forum will not permit me to paste the code here so I will attach an image of it. Don't fear the code is all detailed inside the webpage at the above URL.