Ruby code with operation (modulo)

Hi

I use a CSV (and the logstash csv filter) and with one field I need to create a id based on this php code where $siren value is in my csv (named SIREN, for example 010441582), notice the use of php modulo (%)

return "FR" . (( 12 + 3 * ( $siren % 97 ) ) % 97 ) . $siren;

I try to do this with logstash

filter {

    csv {
        columns => [
			"SIREN","NIC"
        ]
        separator => ","
        }
    ruby {
		code =>  "
			event.set('TVA_id', (( 12 + 3 * ( event.get('SIREN') % 97 ) ) % 97 ))
			"
	     }
	mutate {
			add_field => {
			  "TVA" => "FR%{TVA_id}%{SIREN}"
			}
		}
}

This code failed to work, related to the code in the ruby part... If you have some clue or solution thanks in advance!

Resolve with

mutate {
    		convert => { "SIREN" => "integer" }
    	  }	

Indeed my SIREN field was a String...

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