I want to send a single alert on a successful deployment in Azure. Alerting on individual events is a problem because that could get too noisy.
Grouping events by their correlation id and sending that in a single e-mail would be great. Sort of like what you might find in the deployment overview page in the Azure portal:
Your deployment is complete
Deployment name: mesh_rp.linux
Subscription: AcmeDevTest
Resource group: rg-mesh-demo
Start time: 11/29/2018 9:00:00 AM
Duration: 2 minutes 56 seconds
Correlation ID: 11111111-1111-1111-1111-111111111111
Resource TYPE STATUS
HelloWorldApp Microsoft.ServiceFabricMesh/applications OK
HellowWorldNetwork Microsoft.ServiceFabricMesh/networks OK
How would I go about grouping those events by their correlation id and then firing that off in an e-mail?
Is this possible with Azure Monitor or is something like logic apps and event grid the way to go here?
Azure Monitor would be best for you.
From Azure portal, select Monitor > Alerts
Click New Alert Rule at the top of the Alerts window.
Configure Alert target and Target criteria
Configure Action group to send an email.
For a successful deployment, you should choose "create new deployment" as the target criteria.
For more details, please refer to the following:
https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/alert-activity-log
Related
I have an Azure function, which fails while running Startup.cs (while initializing the runtime) because it can't load a key from a Key vault. I would like to automate the deployment of this function in the future and therefore I would like to set up an alert to trigger if the function can't initialize correctly for any reason. (I can fix this speficic error, I just use it as an example).
At the moment I see the error in the Notifications section of the function page in the Azure portal:
I also see the exceptions in Diagnose and solve problems -> Availability and Performance:
But I can't seem to find a way to set up an alert to respond to this situation. I assumed that Resource health alert would cover this, but it doesn't. Maybe because to portal reports the function as Status: Running. I also can't find this error in Application Insights.
Is there any way to set up this alert?
To create the Alerts for Function App Runtime failures, start with the Alert Action Groups.
Open your function app in the Azure Portal and create the action group that points to your function and email configuration:
In the same function app menu > Logs > Get the Function Request Failure results such as below:
Then, click on “New Alert Rule” > Insert the values for Alert logic such as Frequency of Evaluation, Operator, Threshold Value, Measure of data summary, etc.,
Next, Select the Action Group which is created at the starting - that contains the Selected Function Data and the Email Notification configuration details:
After configuring the alert group, you’ll get the mail that the alerts are mailed accordingly:
I have given the wrong input to get the alert for the Function Runtime failure, which is driven to the Alerts:
Result:
For more details regarding Azure Alerts, refer to this MS Doc.
Updated Answer:
- This query gives the function errors messages in the logs and from this panel we can create the alert rule for the errors and warnings.
Log files for my sample application is getting created in the following folder in azure portal
D:/home/LogFiles/sample_application/sample_application.log
sample_application.log can be both edited and deleted.
Is there a way in azure portal to trigger an email alert when someone tries to modify or delete the log file??
• Yes, you can surely configure an alert using the Azure Monitor regarding the deletion of the log file from the App service through the kudu console or by some other means. For this purpose, you will have to create an alert rule from the Azure Monitor alerts pane with the condition ‘ AppServiceFileAuditLogs | where OperationName == “Delete” and Path == “D:/home/LogFiles/sample_application/sample_application.log” ’ with the action of sending an alert to the email id as registered with this alert rule. Please find the link below on how to create an alert rule through Azure Monitor: -
https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-activity-log
Also find the below snapshot below for reference: -
Also, ensure that condition is selected as ‘Custom Log Search’ for as below: -
Please find the link below for detailed instructions on implementing the integration between Azure app service and Azure monitor: -
https://azure.github.io/AppService/2019/11/01/App-Service-Integration-with-Azure-Monitor.html
I want to get alerts whenever a new resource is created, I tried to do it through the monitor using the activity log but could not find any default configuration which can provide the needful. Any help will be appreciated.
Create Event Grid Subcription on Subscription level. Narrow actions to e.g. Successful Writes only, your choice, send such event when its triggered to some external processor (e.g. Azure Function) and do whatever you need with it.
You can create a log alert for any create events.
You will first need to stream the activities to log anayltics:
https://learn.microsoft.com/azure/azure-monitor/essentials/activity-log#send-to-log-analytics-workspace
You can then set a log alert on the subscripition to detect any resource creation.
I would like to set up an Azure alert for when someone on our team sets up an Azure database. Once alerted, I want to have an additional alert created if that resource is running for more than a certain amount of time.
My solution is to create an Alert Rule on the storage account and have it send an email. Where I'm running into trouble is how to monitor the database, since it just got created and I don't know the name yet for the second Alert rule that will monitor its uptime.
Is there some programmatic way to determine the database resource name?
If you don't want to invest time in Programmatic way there is a option to set or configure an alert at Resource Group level based on Resource type, where in the alert rule configure with below configurations
Scope -Select the right subscription, filter by resource type like SqlDatabase and if required filter based on location wise
Condition - In Select condition, Signal type drop down select "Create/Update Azure Sql Database" and in alert logic you can provide additional filtering logic's
Can choose existing Action group or create new one based on your requirement
Add "Alert rule details" like rule name, description etc.
Finally create alert rule
Now once alert rule is created if any new Azure SqlDatabase is created you will be notified based on alert configured.
According to the official doc, you can use Event Grid to notify Azure Automation when a SQL database is created.
https://learn.microsoft.com/en-au/azure/event-grid/overview#ops-automation
Once you subscribe, you can use Logic Apps to send you an email for example.
About the second part, you'll need to query the metrics and figure out if it's running (is performing compute) or not.
I am trying to alert/visualize Resource changes like creation/deletion of Azure resources using Log Analytics/OMS.
I am able to find new deployments using:
AzureActivity
| where ActivityStatus == 'Succeeded' and OperationNameValue contains 'Microsoft.Resources/deployments/write'
and VM start/stop also is traceable.
However, i do not see any logs when a VM is deleted from a resource group. I checked in the resource group Activity logs too, however such an important event doesnt seem to be tracked properly. Only thing I find is the deletion of shutdown schedules as part of VM deletion, however this isnt a reliable indicator.
How can I track resource deletions using Log Analytics?
You can set up an alert when the vm is deleted in log analytics.
Nav to azure portal, your log analytics -> in the left blade, select Alerts -> New alert rule-> in the new page, select your vm as resource -> then in the condition, add an condition: Delete Virtual Machine.