# How to group by server when offset is used

**URL:** <https://community.grafana.com/t/how-to-group-by-server-when-offset-is-used/31719>\
**Category:** Prometheus\
**Created:** [June 8, 2020, 3:38pm UTC](https://community.grafana.com/t/how-to-group-by-server-when-offset-is-used/31719 "2020-06-08T15:38:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![such](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@such](https://community.grafana.com/u/such)\
**Post date:** [June 8, 2020, 3:38pm UTC](https://community.grafana.com/t/how-to-group-by-server-when-offset-is-used/31719/1 "2020-06-08T15:38:22Z")

</div>

I want to show thoughput of my message metrics grouping by server:  
I am able to achieve this for one server by using:  
sum(messages\_sent\_total)-sum(messages\_sent\_total offset 1m)

But I want to achieve this for multiple servers using:  
sum by (instance) (sum(messages\_sent\_total)-sum(messages\_sent\_total offset 1m))  
But ‘sum by’ not doing anything here.  
Can anyone suggest proper way to achieve this.

---

<div class="post-metadata">

**Author:** ![codlord](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@codlord](https://community.grafana.com/u/codlord)\
**Post date:** [June 8, 2020, 4:18pm UTC](https://community.grafana.com/t/how-to-group-by-server-when-offset-is-used/31719/2 "2020-06-08T16:18:46Z")

</div>

@such Not 100% sure I understand, but have you tried:  
`sum by (instance) (messages_sent_total-messages_sent_total offset 1m)`

---

<div class="post-metadata">

**Author:** ![such](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@such](https://community.grafana.com/u/such)\
**Post date:** [June 9, 2020, 6:16am UTC](https://community.grafana.com/t/how-to-group-by-server-when-offset-is-used/31719/3 "2020-06-09T06:16:59Z")

</div>

@codlord Thank you so much. It worked!!
