I am having trouble performing a mutate. I thought I had it working with a more simplified version of this config but cannot seem to get it going in this new one (though everything else seems to be working much better).
convert => { "Meter" => "integer" "Group" => "integer" "Org" => "integer" "Reading" => "integer" "Info1" => "integer" "Info2" => "integer" "Info3" => "integer" "Info4" => "integer" "Info5" => "integer" "Info6" => "integer" "Info7" => "integer" }
This produces an error as follows:
[WARN ] 2020-11-16 16:02:03.348 [[main]>worker1] elasticsearch - Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"test-west", :routing=>nil, :_type=>"_doc"}, #LogStash::Event:0x74d535a], :response=>{"index"=>{"_index"=>"test-west-coop2", "_type"=>"_doc", "_id"=>"PCMU03UBcHG8wQHZR9GN", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper [Meter] cannot be changed from type [long] to [text]"
But when I add mutate either encapsulating the converts or when I separate out the mutate into its own filter function, I receive other errors.
mutate { convert => { "Reading" => "integer" } convert => { "Meter" => "integer" "Group" => "integer" "Org" => "integer" "Info1" => "integer" "Info2" => "integer" "Info3" => "integer" "Info4" => "integer" "Info5" => "integer" "Info6" => "integer" "Info7" => "integer" } remove_field => [ "message", "host", "path", "@version" ] } }
or
mutate { convert => { "Meter" => "integer" "Group" => "integer" "Org" => "integer" "Reading" => "integer" "Info1" => "integer" "Info2" => "integer" "Info3" => "integer" "Info4" => "integer" "Info5" => "integer" "Info6" => "integer" "Info7" => "integer" } remove_field => [ "message", "host", "path", "@version" ] } }
I receive the following:
Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [ \t\r\n], "#", "=>" at line 26, column 9 (byte 530) after filter {\n csv {\n columns => [\n "Meter",\n "Group",\n "Org",\n "date",\n "Reading",\n "Info1",\n "Info2",\n "Info3",\n "Info4",\n "Info5",\n "Info6",\n "Info7"\n ]\n\n\tmutate ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:32:in
compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:184:in
initialize'", "org/logstash/execution/JavaBasePipelineExt.java:69:ininitialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:47:in
initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52:inexecute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:365:in
block in converge_state'"]}
I'm pretty new to all this so I'm probably just doing something wrong but any pointers in the right direction would be greatly appreciated.