Hello,
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:
Check
check_inode_metrics:
command: python3 /etc/sensu/plugins/dpe_inode_metrics.py -g xxxxx.xxxx.com
subscribers:
- dpe
interval: 60
occurrences: 10
plugins:
- dpe_inode_metrics.py
filters:
- occurrences
- only_business_hours
handlers: email
environment_settings:
prod:
command: python3 /etc/sensu/plugins/dpe_inode_metrics.py -g xxxx.xxxx.com
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
{
“api_version”:“core/v2”,
“type”:“Check”,
“metadata”:{
“namespace”:“default”,
“name”:“dpe_check_cpu”,
“labels”:{},
“annotations”:{
“sensu.io.json_attributes”:"{“email”:[“dpe_team@xxxxxx.com”],“pagerduty_name”:“low_priority”,“pagerduty_map”:{“low_priority”:“xxxxxxxx”,“high_priority”:“xxxxxxxx”},“environments”:[“test”,“dev”,“prod”],“severities”:[“critical”,“unknown”],“refresh”:1800,“occurrences”:10,“allow_client_override”:false,“disable_email”:false,“disable_webex”:false,“disable_pagerduty”:false,“environment_settings”:{“test”:{“allow_client_override”:true,“email”:[“dpe_team@xxxxxxxx.com”],“handlers”:[“email”]},“prod”:{“pagerduty_name”:“high_priority”,“handlers”:[“pagerduty”,“email”]}},“plugins”:[“dpe_check_cpu.rb”],“team”:“dpe”,“defined_in”:“dpe_default_checks.yaml”}",
“fatigue_check/occurrences”:“10”,
“fatigue_check/interval”:“1800”
}
},
“spec”:{
“command”:“sensu_ruby /etc/sensu/plugins/dpe_check_cpu.rb -c 99 -w 95”,
“subscriptions”:[
“dpe”
],
“publish”:true,
“interval”:60,
“handlers”:[
“dpe_business_hour_email”
]
}
}