hey ,
I am using the logstash ruby plugin
I am trying to create new json :
ruby {
init => "require 'json'"
code => "
bandwidth = event.get('bandwidth')
puts bandwidth[0]['count64']
foo = '{\".ssli\": {\\"mappings\\":{\"data\":{\"inspectedbw\" : '+bandwidth[0]['count64'].to_s+' } }}}'
x=foo.to_s.delete('\\')
event.set('new',x)
"
}
but in the new string there are \ string
{"new":"{\".ssli\": {\"mappings\":{\"data\":{\"inspectedbw\" : 572828245 } }}}"
where I would like to get :
{"new":"{".ssli": {"mappings":{"data":{ "inspectedbw" : 572828245 } }}}"
note , when I run this simple program :
foo = '{\".ssli\": {\"mappings\":{\"data\":{\"inspectedbw\" : '+1.to_s+' } }}}'
x=foo.to_s.delete('\\\\')
puts(foo.to_s)
puts(x)
{\".ssli\": {\"mappings\":{\"data\":{\"inspectedbw\" : 1 } }}}
{".ssli": {"mappings":{"data":{"inspectedbw" : 1 } }}}
where the second one is my requested output whom I would like to see in the event ...
is there another recommended way to do this ?