Trouble with simple ruby code calculation


(Perry Cuenca) #1

Hi,

I am getting a ruby exception error for the calculation, but not sure what could causing it.

input {
    file {
       type => "csv"
    path => "/Users/path/perf.csv"
    start_position => beginning
    # to read from the beginning of file
    sincedb_path => "/dev/null"
  }
}


filter {
    csv {
        columns => ["page_id","unloadEventEnd","responseEnd","responseStart","domInteractive","domainLookupEnd","unloadEventStart","domComplete","domContentLoadedEventStart","domainLookupstart","redirectEnd","redirectStart","connectEnd","toJSON","connectStart","loadEventStart","navigationStart","requestStart","secureConnectionStart","fetchStart","domContentLoadedEventEnd","domLoading","loadEventEnd"]
    }

            
       grok {
   match => { "page_id" => "%{WORD:page}-%{INT:page_ts}" }
   remove_field => [ "page_id", "message", "path" ]
   }
    
mutate {
    convert => { "unloadEventEnd" => "integer" }
    convert => { "responseEnd" => "integer" }
    convert => { "responseStart" => "integer" }
    convert => { "domInteractive" => "integer" }
    convert => { "domainLookupEnd" => "integer" }
    convert => { "unloadEventStart" => "integer" }
    convert => { "domComplete" => "integer" }
    convert => { "domContentLoadedEventStart" => "integer" }
    convert => { "domainLookupstart" => "integer" }
    convert => { "redirectEnd" => "integer" }
    convert => { "redirectStart" => "integer" }
    convert => { "connectEnd" => "integer" }
    convert => { "toJSON" => "string" }
    convert => { "connectStart" => "integer" }
    convert => { "loadEventStart" => "integer" }
    convert => { "navigationStart" => "integer" }
    convert => { "requestStart" => "integer" }
    convert => { "secureConnectionStart" => "integer" }
    convert => { "fetchStart" => "integer" }
    convert => { "domContentLoadedEventEnd" => "integer" }
    convert => { "domLoading" => "integer" }
    convert => { "loadEventEnd" => "integer" }

  }
       
ruby {
             code => "event['TTFB'] = event['responseStart'].to_i - event['navigationStart'].to_i"
       }
       
   date {
       match => [ "page_ts", "UNIX_MS" ]
        target => "timestamp"
        remove_field => [ "page_ts" ]
        }
    }
output {
  elasticsearch { hosts => ["localhost:9200"] }
  stdout { codec => rubydebug }
  }

Any help would be greatly appreciated,


(Magnus B├Ąck) #2

Please quote the exact error message.


(system) #3

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