Month names in english with pattern MMM


#1

Hello,

The @timestamp format I have is the following : « 2018-07-10T11:04:14.452Z ». And I would like to have in output this format : « Jul 10 13:09:12 ».

Here is my configuration in order to do that :

input {
	kafka {
		id => "kafka_input"
		client_id => "TEST-client"
		bootstrap_servers => "***********"
		group_id => "TEST-group"
		topics => ["TEST"]
		decorate_events => true
	}
}

output {
	file {
		path => "/var/log/logstash/output/test_P.txt"
		codec => line { format => "<5> %{+MMM dd HH:mm:ss} test.domaine.lan %{message}" }
	}
}

But the output logs have the following format :
:black_small_square: « <5> juil. 11 15:37:12 test.domaine.lan {"version":"…. »

The month is in french(« juil. ») and i would like to have it in english (« jul »).
Do you know how to do that ?

I try to add the filter below. But I get an error message
filter { date { locale => "en" }}

translation missing: en.logstash.agent.configuration.invalid_plugin_register

Thanks in advance for your help.


#2

Any guess ?


#3

In case someone is interested. I found out a way to bypass this issue, I parsed the timestamp in a ruby filter.

input {
	kafka {
		id => "kafka_input"
		client_id => "TEST-client"
		bootstrap_servers => "***********"
		group_id => "TEST-group"
		topics => ["TEST"]
		decorate_events => true
	}
}

filter {
	ruby {
		init => "require 'date'"
		code => "
			event.set('month' , Date.strptime(event.get('@timestamp').to_s, '%Y-%m-%dT%H:%M:%S.%LZ').strftime('%b'))
		"
	}
}

output {
	file {
		path => "/var/log/logstash/output/test_P.txt"
		codec => line { format => "<5> %{month} %{+dd HH:mm:ss} test.domaine.lan %{message}" }
	}
}

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.