Why won't Logstash, running as the logstash user on port 514, start, and how would you diagnose the issue?
Asked at
AI answer
On Linux, port 514 is usually considered a privileged port (ports below 1024), so the regular logstash user cannot bind to it without special permissions. I’ll check the exact error in the journal (journalctl -u logstash and the Logstash logs), then find out whether the port is in use and which transport is being used: sudo ss -lntup | grep ':514' and sudo ss -lnup | grep ':514'. In strace, you can look for the bind() call and its error code: for example, EACCES indicates insufficient permissions, while EADDRINUSE means the address or port is already in use. I’ll also check the input plugin configuration, SELinux/AppArmor, and the value of net.ipv4.ip_unprivileged_port_start.
Possible solutions: receive events on a port above 1024 and redirect traffic from 514; or configure the minimum required capabilities or systemd AmbientCapabilities=CAP_NET_BIND_SERVICE and CapabilityBoundingSet=CAP_NET_BIND_SERVICE. Don’t grant a capability to the entire Logstash Java process without careful consideration—first assess its scope and risks.
Also asked at RWB
- Why did you decide to change jobs / leave your current company?
- What is the key difference between TCP and UDP?
- What is the difference between git merge and git rebase? When should each approach be used?
- What is an inode in Linux?
- Which command is used to determine the route of a packet from your device to the target host?
Similar questions
- How do you customize Logstash filters to parse multiline logs (for example, Java stack traces) in real time?
- Why use Logstash in front of Elasticsearch? Can logs be sent directly from Filebeat to Elasticsearch?
- How can you check which port a service has started on in Linux and filter the output if there are many services?
- And what user does the daemon run as?
- How can you find the directory where an application service writes its logs if there’s nothing in systemd/journalctl, and how can you view its configuration?