Logstash Config File not running getting error: contains non-ascii characters but are not UTF-8 encoded

Hello All,

I'm getting below error while running the logstash config,Unable to understand how it can be resolved.Eearlier it worked by now giving error.

input {
  jdbc { 
	jdbc_connection_string => "jdbc:oracle:thin:@abc:1521/tcs"
	jdbc_user => "random"
	jdbc_password => "random"
    jdbc_driver_library => "../lib/ojdbc8-"
    jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
	jdbc_paging_enabled => true
	last_run_metadata_path => "../config/lastrun-tcs-package-details.yml"
	schedule => "*/10 * * * * *"
	connection_retry_attempts => 5
	connection_retry_attempts_wait_time => 10
	statement=> "select PACKAGE_ID,PACKAGE_DATA, from_tz(CAST (CREATION_DATE AS TIMESTAMP), 'UTC') as CREATION_DATE, from_tz(CAST (LAST_MOD_DATE AS TIMESTAMP), 'UTC') as LAST_MOD_DATE   from mytable where LAST_MOD_DATE >= SYS_EXTRACT_UTC(:sql_last_value)"
	type => "tcs-package-details"
 filter {
  if [type] == "tcs-package-details" {
	json {source => "event_data"} 
		split {field => "event_data"}
		mutate {remove_field => [ "event_data"]}

output {
#stdout { codec => json_lines }
  if [type] == "tcs-package-details"{
	elasticsearch {
		hosts => "http://abc:9200"
		ilm_pattern => "{now/d}-000001"
		"doc_as_upsert" => true
		ilm_rollover_alias => "tcs-package-details"
		ilm_policy => "tcs-monitor--policy"
		"document_id" => "%{package_id}"


[2023-03-06T13:51:43,478][ERROR][logstash.agent ] An exception happened when converging configuration {:exception=>RuntimeError, :message=>"Could not fetch the configuration, message: The following config files contains non-ascii characters but are not UTF-8 encoded ["/P/fol/MIS/logstash/logstash-7.9.1/bin/tcs-sql-package.cfg"]", :backtrace=>["/P/fol/MIS/logstash/logstash-7.9.1/logstash-core/lib/logstash/agent.rb:185:in converge_state_and_update'", "/P/fol/MIS/logstash/logstash-7.9.1/logstash-core/lib/logstash/agent.rb:114:in execute'", "/P/fol/MIS/logstash/logstash-7.9.1/logstash-core/lib/logstash/runner.rb:395:in block in execute'", "/P/fol/MIS/logstash/logstash-7.9.1/vendor/bundle/jruby/2.5.0/gems/stud-0.0.23/lib/stud/task.rb:24:in block in initialize'"]}

Any suggestion would be helpful.


The configuration you shared is this one?

What changed? Something changed. What you use to edit this file? Maybe something added a hidden character to the file.

Do you have dos2unix in the system? If you have, try to run dos2unix file and see if it solves.

Hello @leandrojmp ,

Thanx for having a look into this.I was able to resolve this by opening in notepad++.
selecting encoding option->it was showing ANSI switched to UTF,after taht i could see some random values that might be mistakenly added.This resolved.

Many Thanx

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