# How to add custom labels to alerting rules

**URL:** <https://discuss.prometheus.io/t/how-to-add-custom-labels-to-alerting-rules/128>\
**Category:** Prometheus server\
**Created:** [April 13, 2021, 6:09am UTC](https://discuss.prometheus.io/t/how-to-add-custom-labels-to-alerting-rules/128 "2021-04-13T06:09:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gr8adakron](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/gr8adakron/32/82_2.png) [@gr8adakron](https://discuss.prometheus.io/u/gr8adakron)\
**Post date:** [April 13, 2021, 6:09am UTC](https://discuss.prometheus.io/t/how-to-add-custom-labels-to-alerting-rules/128/1 "2021-04-13T06:09:25Z")

</div>

```
groups: 
- name: cadvisor
  rules:
  - alert: ContainerCpuUsage
    expr: (sum(rate(container_cpu_usage_seconds_total[3m])) BY (instance, name) * 100) > 65
    for: 0m
    labels:
      severity: warning
      service : pod cpu near to full
      support_team: support-l1
    annotations:
      summary: Container CPU usage (instance {{ $labels.instance }})
      pod: POD name is (pod {{ $labels.pod }})
      namespace: Namespace is (namespace {{ $labels.namespace }})
      description: Container CPU usage is above 80% VALUE = {{ $value }} LABELS = {{ $labels }} external labels = {{ $externalLabels }}

```

Right now: $labels.pod is empty.

I need to get $labels.pod - which is custom label in the alert ( and $labels.container), is it possible? any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![roidelapluie](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/roidelapluie/32/6_2.png) [@roidelapluie](https://discuss.prometheus.io/u/roidelapluie)\
**Post date:** [April 13, 2021, 8:10am UTC](https://discuss.prometheus.io/t/how-to-add-custom-labels-to-alerting-rules/128/2 "2021-04-13T08:10:00Z")

</div>

Welcome to our forums 🙂

You can adapt your rule like this:

`(rate(container_cpu_usage_seconds_total[3m]) * 100) > 65`

It does not seem like the `by` is needed here.

---

<div class="post-metadata">

**Author:** ![gr8adakron](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/gr8adakron/32/82_2.png) [@gr8adakron](https://discuss.prometheus.io/u/gr8adakron)\
**Post date:** [April 13, 2021, 3:01pm UTC](https://discuss.prometheus.io/t/how-to-add-custom-labels-to-alerting-rules/128/3 "2021-04-13T15:01:58Z")

</div>

Thanks… that helped
