Skip to content

socket_listener & socket_writer should be able to control tcp keep alive #2635

Closed
@phemmer

Description

@phemmer

Feature Request

Proposal:

Users should be able to control TCP keep alive for the socket_listener and socket_writer plugins.

Current behavior:

Telegraf inherits the kernel TCP keep alive settings.

Desired behavior:

Telegraf should be able to set its own TCP keep alive settings.

Use case: [Why is this important (helps with prioritizing requests)]

TCP keep alive is very important on socket_listener, as TCP keep alives are the only way to detect when a connection which is read-only is ungracefully terminated (remote host crash, network loss, etc). Without TCP keep alive, and the ability to detect such issues, telegraf may accumulate a large number of dead connections, and exhaust its available file descriptors.
By default TCP keep alive is off (in the kernel). Even if turned on, it's possible telegraf may need to be configured with different settings.

I imagine configuration would be done with a simple tcp_keepalive_interval setting. When set > 0, TCP keep alive is set on at the given interval value, when set = 0, TCP keep alive is turned off, and then when not set at all, we use the OS default.
In order to detect all 3 states, in the code the struct member will have to be a pointer. We could simplify it and just say that when 0, or unset, we inherit the OS default. I can't think of any reason why one would have TCP keep alive enabled on the kernel, and then want to turn it off in the application. But I also don't like making assumptions about use cases I can't think of.

I'll work on this, as it'll be a very easy change. Just creating the issue as a placeholder.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions