Search code examples
azureazure-functionsazure-alerts

Sending alert by analyzing Azure logs


I'm using an azure function which writes a log:

def main(name: str) :

connect_str = os.getenv('AzureWebJobsStorage')
blob = BlobClient.from_connection_string(conn_str=connect_str, container_name="testcsv", 
blob_name=name)
exists = blob.exists()

if (exists == False):
    logging.info(f"The blob exists \n")

else:
    logging.error(f"The blob does not exist \n")
    

return exists

I want to send an alert when I find 'The blob does not exist' in my log. I think I have to use custom log search in alerts. Do you know how ?


Solution

  • An alert is always triggered by a telemetry query. We can set up an alert on bad behaviours if we can formulate a query that reveals them.

    As of now, we could create Custom Alerts i.e., based on Number of results and Metric Measurement.

    Refer to the Microsoft Blog on Alert based on Analytics query using Custom Log Search for more information.