how to send alert when a container in a container group enters the terminated state?

Joshua Igoni 20 Reputation points
2023-05-02T09:18:18.67+00:00

I have i group of containers running in a container group in (Azure container Instances), I was able to set up Azure application insights in such a way that it monitors the front-end point of the app, it has been monitoring it successfully, but recently one of the containers in the container group started failing which had nothing to do with the endpoint that is being monitored by application insights and i was not able to know about that event.

is there a way to monitor the status of specific containers in a container group, such that when it changes we get an alert about the change in status of that particular container in the container group. ?

please help thanks.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,938 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
663 questions
{count} votes

Accepted answer
  1. Andrei Barbu 2,581 Reputation points Microsoft Employee
    2023-05-17T06:47:03.7533333+00:00

    Hello Joshua Igoni

    When a container gets in Terminated state, it usually means it was killed.

    To create an alert you should first enable logging and events collected with Azure Monitor Log Analytics Workspace and then, use the following query to create a log based alert:

    ContainerEvent_CL
    | where Message contains "Killing" | where TimeGenerated > ago(5m) | project TimeGenerated,ContainerGroup_s,Message

    This will query when a container gets "Killing" and based on the query results you can set the alert.

    Hopefully this is what you are looking for! If you have additional questions, please let us know in the comments.

    If this has been helpful, please take a moment to accept answers as this helps increase visibility of this question for other members of the Microsoft Q&A community. Thank you for helping to improve Microsoft Q&A!

    User's image

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Joshua Igoni 20 Reputation points
    2023-05-22T11:23:24.5066667+00:00

    Thanks

    0 comments No comments