# Show Container name on Kubernetes container restart alerts/problem cards

**URL:** <https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761>\
**Category:** Alerting\
**Tags:** problem-notification, anomaly-detection, kubernetes, problems-classic\
**Created:** [September 18, 2024, 6:57am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761 "2024-09-18T06:57:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurugogi](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gurugogi](https://community.dynatrace.com/u/gurugogi)\
**Post date:** [September 18, 2024, 6:57am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/1 "2024-09-18T06:57:20Z")

</div>

Hi All,

I have enabled alerting for container restart at anomaly detection-\> Workload, it is creating alerts/Problem card when any container gets restarted,&nbsp; it is printing workload name in alerts but I want the particular container name to be printed in alerts (container name which got restarted.).

I tried with custom alerts(metric events), auto-tags etc looks like its not working, please guide if anyone has implemented this by modifying message body in mail alerts/slack alerts etc.

Thanks,  
Guru Gogi

---

<div class="post-metadata">

**Author:** ![gurugogi](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gurugogi](https://community.dynatrace.com/u/gurugogi)\
**Post date:** [October 3, 2024, 10:45am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/2 "2024-10-03T10:45:05Z")

</div>

anyone tried ?

---

<div class="post-metadata">

**Author:** ![mizso74](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mizso74/32/41729_2.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [October 3, 2024, 11:01am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/3 "2024-10-03T11:01:19Z")

</div>

Hi&nbsp;[@gurugogi](https://community.dynatrace.com/user/61893),

Have you tride this metric experession in the metric event?

![Mizs_1-1727953158201.png](https://global.discourse-cdn.com/dynatrace/optimized/2X/1/1c788a4d0d6e8734d776a160ba41561bba8afe8a_2_690x32.png)

Then you can use the container dimension in the metric event:

 ![Mizs_2-1727953254102.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/eed9a47c72b8b134c0352feb4629a0c067151695.png)

I hope it helps.

Best regards,

Mizső

---

<div class="post-metadata">

**Author:** ![gurugogi](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gurugogi](https://community.dynatrace.com/u/gurugogi)\
**Post date:** [October 3, 2024, 11:34am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/4 "2024-10-03T11:34:04Z")

</div>

[@Mizső](https://community.dynatrace.com/user/47783)&nbsp; thanks for reply.  
I tried below expression and its triggering alerts for container restarts.  
builtin:kubernetes.container.restarts  
:splitBy(“k8s.container.name”,“k8s.pod.name”,“k8s.cluster.name”,“k8s.namespace.name”)  
:count:sort(value(avg,descending))

I have not sleeted any MZ for this metric event so it is creating Problems in default alerting profile but I want the Problems to be grouped under specific alerting profiles tagged to specific

---

<div class="post-metadata">

**Author:** ![gurugogi](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gurugogi](https://community.dynatrace.com/u/gurugogi)\
**Post date:** [October 3, 2024, 11:36am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/5 "2024-10-03T11:36:29Z")

</div>

I want to use this single “Metric event” for all k8s clusters alerting, particularly we use slack notifications, so I want some particular container restart should be grouped under that particular alerting profile.

---

<div class="post-metadata">

**Author:** ![gurugogi](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gurugogi](https://community.dynatrace.com/u/gurugogi)\
**Post date:** [October 3, 2024, 11:45am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/6 "2024-10-03T11:45:02Z")

</div>

Only option is to create “Metric event”/“Custom alert” for each K8S cluster and MZ filter ?

---

<div class="post-metadata">

**Author:** ![Peter\_Youssef](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/peter_youssef/32/14668_2.png) [@Peter\_Youssef](https://community.dynatrace.com/u/Peter_Youssef)\
**Post date:** [October 8, 2024, 12:55pm UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/7 "2024-10-08T12:55:19Z")

</div>

Hello&nbsp;[@gurugogi](https://community.dynatrace.com/user/61893)

1. let’s agree that to get notified \> problem alerting profile should be Created and hence \> Management zone rules should be configured and customized to include all related entities.
2. The point here is to ensure the **K8s configured management zone** contains all K8s related entities and then you can easily create metrics and receive alerts upon the specified conditions.

**For the K8s related anomaly detections, feel free to customize it as per the K8s admin inputs**

 ![2024-10-08_16h48_35.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/1/617587902847d43dc62f124fedac1a7abfa79dcd.png)

 ![2024-10-08_16h50_50.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/f/0fc5e669b488d61cbc50ab3774dc52b5ad0bc628.png)

 ![2024-10-08_16h51_34.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/3/3387fc5d83b392f14a7c8a7e821480f9b347da68.png)

 ![2024-10-08_16h51_47.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/4/e4ce648cfb854bad864b1637dd351324641a99cc.png)

 ![2024-10-08_16h53_45.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0422ebc8343bec88029709991d37fd2e083fec1a.png)

 ![2024-10-08_16h54_02.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/a/0a15eab5d63c74b696c2921e894953782fbaea53.png)

BR,

Peter

---

<div class="post-metadata">

**Author:** ![Gosia\_Murawska](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@Gosia\_Murawska](https://community.dynatrace.com/u/Gosia_Murawska)\
**Post date:** [December 19, 2024, 9:57am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/8 "2024-12-19T09:57:06Z")

</div>

Hi&nbsp;[@gurugogi](https://community.dynatrace.com/user/61893)! Did you manage to solve this one? 🤔

---

<div class="post-metadata">

**Author:** ![gurugogi](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gurugogi](https://community.dynatrace.com/u/gurugogi)\
**Post date:** [December 19, 2024, 10:49am UTC](https://community.dynatrace.com/t/show-container-name-on-kubernetes-container-restart-alerts-problem-cards/47761/9 "2024-12-19T10:49:33Z")

</div>

Hi Gosia,

Yes I solved it through metric expression

Expression:  
builtin:kubernetes.container.restarts  
:filter(and(eq(“k8s.cluster.name”,“cluster-name”),eq(“k8s.namespace.name”,“ns”)))  
:splitBy(“k8s.cluster.name”,“k8s.pod.name”,“k8s.container.name”,“k8s.namespace.name”)  
:sort(value(auto,descending))

Used above expression in Metric events(custom alert)  
Descrption:  
container Name:{dims:k8s.pod.name}-{dims:k8s.container.name}  
Cluster Name:{dims:k8s.cluster.name}  
Namespace:{dims:k8s.namespace.name}
