# Create a counter out of 2 counters in a record rule

**URL:** <https://discuss.prometheus.io/t/create-a-counter-out-of-2-counters-in-a-record-rule/930>\
**Category:** PromQL\
**Created:** [April 21, 2022, 10:32am UTC](https://discuss.prometheus.io/t/create-a-counter-out-of-2-counters-in-a-record-rule/930 "2022-04-21T10:32:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergioasantiago](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/sergioasantiago/32/415_2.png) [@sergioasantiago](https://discuss.prometheus.io/u/sergioasantiago)\
**Post date:** [April 21, 2022, 10:32am UTC](https://discuss.prometheus.io/t/create-a-counter-out-of-2-counters-in-a-record-rule/930/1 "2022-04-21T10:32:11Z")

</div>

I have a use case where I need to create a counter out of a combination of 2 other counters. We are using an external tool that expects a prometheus counter as input and therefore I would like to create a counter combining 2 different counters like the example below:

```auto
# Count total number of requests per service
satisfied_requests_total

# Requests per http status code
requests_per_code_total{ code="499" }

```

I need to have a counter that count the `number_of_satisfied_requests_total` - `requests_per_code_total{ code="499" }`

What I want to achieve is:

```auto
- record: requests_good_example
   expr: satisfied_requests_total - requests_per_code_total{ code="499" }

```

But of course if we have counter reset, we can end up with negative results.  
Is there a way to get the expected result?

PS: Both metrics have the same labels
