Help understanding Labels/Annotations in Migrations from Sensu-Core to Sensu-Go


I am in the process of migrating our sensu core servers to sensu-go. This has been a task in itself, and not very easy. I am on the creation of checks, and I am having issues with “Environments”.

I understand in the agent.yml I can use annotations or labels to say things like environment is dev. Which is great. The feature that I am trying to understand is environment variables. In our current checks we use environment variables such as:


command: python3 /etc/sensu/plugins/ -g
- dpe
interval: 60
occurrences: 10
- occurrences
- only_business_hours
handlers: email
command: python3 /etc/sensu/plugins/ -g
handlers: pagerduty

I cannot find a way to do this. I have tried many different ways and the only one I can come up with, is if each entity has every “Environment” variable/annotations assigned to it. Is there an easier way to do this? I feel like having 100 different annotations or labels on each entity will be a nightmare to maintain. We also have pagerduty maps, teams, etc. assigned to each check currently.

Here is a basic cpu check translated by the translator to see how we use the variables:

Translated Check

“command”:“sensu_ruby /etc/sensu/plugins/dpe_check_cpu.rb -c 99 -w 95”,

hey @mvinzi . I am not sure I understand the problem. How are environment variables different than a label on an entity?

From what I can see it seems like you are trying to have a different handler per environment, is that correct?

If so, I think you could do one check with all the handlers you needed, and then use filters to stop the handler from activating in certain environments (i.e. filter that does not page if it is a dev environment)

Does that answer your question?


Have you thought about mapping your environment types to Sensu namespace to isolate environments? That way you can maintain agents in Sensu namespaces like “dev” and “production” using a different collection of monitoring resources tailored for each environment. Then its just a matter of setting the correct namespace attribute in the agent.yml.

The trade-off here when using namespaces is you’ll need to maintain resources in each namespace, but an upside is resources in each namespace should be easier to understand, less conditional filter logic in your handler filters.

Also, I use the “default” namespace as sort of a “oops we forgot to set the agent namespace” and have sensu drive registration event alerts differently in “default” namespace so I can catch that situation and address it.