When processing event streams with Logstash, it can be useful to record the time an event was processed and the hostname of the Logstash server handling it.
You can use the Ruby filter plugin in Logstash to add a field capturing the processing time and the hostname.
The Ruby code initializes the necessary libraries, retrieves the current time and server hostname, and adds them as fields to each event.
This allows for better traceability, debugging, and monitoring of event data in Logstash and Elasticsearch.