# AND-ing subscriptions for checks--is it possible?

**URL:** <https://discourse.sensu.io/t/and-ing-subscriptions-for-checks-is-it-possible/1925>\
**Category:** Sensu Go\
**Created:** [July 1, 2020, 10:30am UTC](https://discourse.sensu.io/t/and-ing-subscriptions-for-checks-is-it-possible/1925 "2020-07-01T10:30:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mightp](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/mightp/32/426_2.png) [@mightp](https://discourse.sensu.io/u/mightp)\
**Post date:** [July 1, 2020, 10:30am UTC](https://discourse.sensu.io/t/and-ing-subscriptions-for-checks-is-it-possible/1925/1 "2020-07-01T10:30:43Z")

</div>

I want to create checks, which should only be ran on agents, where a combination of subscriptions are present.

Let’s say I want to monitor the state of vmtools on any Linux system. This check should only be ran on agents where the subscriptions `linux` **and** `virtual` are present.

This way, the check wouldn’t be ran on agents with the subscriptions `linux` **and** `physical`. Or `windows` **and** `virtual` for that matter.

Is this possible?  
Or is there a way to configure this, besides creating edge-case subscriptions like `linux_virtual` and `linux_physical`?

Thanks!

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [July 1, 2020, 7:26pm UTC](https://discourse.sensu.io/t/and-ing-subscriptions-for-checks-is-it-possible/1925/2 "2020-07-01T19:26:09Z")

</div>

Hey,

Off the top of my head, I don’t think the conditional subscription filtering is possible right now. It’s an interesting concept, but its not clear its necessary.

So yeah right now I would accomplish it the other way.  
I would just extend the list of subscriptions the agents are configured to be a part of and write the check to fire against ‘linux\_virtual’ or ‘linux\_physical’

Let me back up and ask the related question, is there some reason that makes extending the list of subscriptions an agent participates in the wrong solution for you?

---

<div class="post-metadata">

**Author:** ![calebhailey](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/calebhailey/32/46_2.png) [@calebhailey](https://discourse.sensu.io/u/calebhailey)\
**Post date:** [July 1, 2020, 8:30pm UTC](https://discourse.sensu.io/t/and-ing-subscriptions-for-checks-is-it-possible/1925/3 "2020-07-01T20:30:00Z")

</div>

As Jef mentioned, there’s no feature in Sensu for conditional subscription logic, but you can get quite granular with your subscriptions to achieve a similar result. We’ve started promoting a subscription naming convention in the [monitoring checks template project](https://discourse.sensu.io/t/introducing-curated-configurations-a-new-way-to-contribute-and-share-operational-expertise/1732) that might be helpful as an example:

> <https://github.com/sensu-community/monitoring-checks/blob/master/system/linux/cpu/check-cpu.yaml#L28-L30>

In this example, we’ve proposed that all of the linux system checks should publish to the `system/linux` subscription, as well as more specific subscriptions such as `system/linux/cpu` and `system/linux/disk` (etc). The key here is that **checks can be published to multiple subscriptions**.

When you adopt more robust subscription options in the check templates, this enables more flexibility on the agent side. You can choose how much linux system monitoring (or similar) you want to enable on a per-node basis by joining the `system/linux` subscription (to subscribe to all linux system monitoring checks), or to selectively join the individual subscriptions for cpu, memory, disk, etc.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![mightp](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/mightp/32/426_2.png) [@mightp](https://discourse.sensu.io/u/mightp)\
**Post date:** [July 2, 2020, 5:35am UTC](https://discourse.sensu.io/t/and-ing-subscriptions-for-checks-is-it-possible/1925/4 "2020-07-02T05:35:30Z")

</div>

Thanks a lot for your replies.

We are currently in the planning phase of our Sensu Go installation, and one of the things we stumbled upon, was the subscription naming.  
The template from the “checks template project” seems like a go too.

Thanks a lot!
