Autoremoval of Entities when host is deleted

Please fill out this template for all topics in this category. Make sure to read the docs before asking your question. Remember that this those helping you are volunteers. Be kind and follow this template :-). Tag all discussions about Enterprise features, as Enterprise.

  1. What have you already tried? Please include links to gists and/or code blocks (if relatively small)
    Read the documentation found https://docs.sensu.io/sensu-go/5.14/reference/entities/
  2. Tell us about your setup, this should include OS, version of Sensu, version of Sensu components (redis, rabbitmq), plugin versions (if applicable), anything special about your setup such as an airgapped network or strict ACLs
    RHEL 7 running Sensu GO
  3. Is there a Github issue related to your issue?
    No
  4. Is there anything else that can help us effectively help you?
    N/A

Hello, we are installing Sensu entities via Puppet so they automatically join our Sensu Backends and enable checks. However, when a host is deleted from Puppet, it still shows up in Sensu as ‘Unresponsive’. We are able to delete them from the dashboard, but would like to have the Sensu agent removed automatically when an agent is deleted. Is this possible?

Hey!

You should be able to configure the agents to make use of deregistration agent config option. And optionally also configure the agent deregistration_handler if you want Sensu backend to take additional action when the agent

Ref:
https://docs.sensu.io/sensu-go/latest/reference/agent/#ephemeral-agent-configuration-flags

Thank you for the quick response! I am looking at the deregistration_handler and I am unsure how exactly to go about implementing that. If you could provide me a bit of hand holding while I wrap my head around this that would be much appreciated as we are getting close to fully deploying Sensu as a replacement for Nagios.

Ideally, I’d like this to be configured from the backend and from the documentation, I see this:

/etc/sensu/backend.yml example

deregistration-handler: “/path/to/handler.sh”

What exactly would be in /path/to/handler.sh ? Some sort of sensuctl command?

@aknight1 the deregistration_handler would be used in the case of a CMDB like ServiceNow, or similar. Think of it as a handler that would remove the entity from another service. Generally, you’re going to worry more about setting deregister: true and keepalive_timeout: 120(or whatever value you choose). For most folks who aren’t using a CMDB or some other sort of service that needs to know about the deregistration event, you shouldn’t have to populate that value.

Nevermind, I see it in the documentation, sorry for the quick question.