[Bug] Elastic Agent reports healthy even if two integrations set up which listen on the same tcp port which doesnt work

When setting up two custom tcp integrations on the same elastic agent, it reports being healthy, even if the second integration doesnt work since it cannot listen on the same port as the first tcp integration.

Reproduce:

  1. Install custom tcp integration, listen on some port like 8080 on 0.0.0.0
  2. Add integration to some policy with some agent
  3. Set up a second custom tcp integration, listen again on the same port e.g. 8080 on 0.0.0.0
  4. Add integration to same policy with same agent
  5. Agent reports being healthy

Moreover, even worth is that if you delete the first integration which was listening successfully on the port, the second will not start listening on the port subsequently. This means that you run into a state where you have the second integration setup and it is not working as intened.

Instead, you have to remove the integration again and then add it to the agent again in order to get the port listening working again.

This is a bug as far as I see and if that can be confirmed, I will open an issue on GitHub. Customers had problems with this, and I investigated for them :slight_smile:

One issue here is that by design the Agent reports the health status based mainly if it can talk with fleet or not.

If it can output data or not or if it is having some issues with the input is not taken into consideration in some cases.

I opened an issue about this a couple of months ago: