Parsleaf

Google SecOps parser errors

invalid JSON: cannot unmarshal array into Go value of type map

The log is a JSON array, not a JSON object. Wrap it in an object first, then parse it with array_function.

The error

pipeline failed: filter json (0) failed: invalid JSON: json: cannot unmarshal array into Go value of type map[string]interface {}

Why it happens

The json filter expects an object ({ … }) at the top. Your log line starts with [ … ], for example a batch of records exported as an array.

How to fix it

Works:

mutate {
  replace => { "wrapped" => "{\"records\": %{message}}" }
}
json {
  source => "wrapped"
  array_function => "split_columns"
  on_error => "not_json"
}

Still failing?

One error usually hides the next. Parsleaf writes the full parser from your sample logs and keeps fixing it from the errors your SecOps tenant returns, until it passes. Generate your parser: the first one is free.

Other parser errors