Logstash exit with code 0

heey i'm trynig to use docker-compose for logstash,elasticsearch,postgresql and when i start docker-compose all containers are working except logstash container it gives me logstash exit with code 0 there is my docker-compose.yml and my file.conf



thanks for any help

Welcome to our community! :smiley:

Please don't post pictures of text or code. They are difficult to read, impossible to search and replicate (if it's code), and some people may not be even able to see them :slight_smile:

in order to reduce complexity, first try running everything outside of a container. Does it work? Any error message that you are seeing? Can you share logs? Have you tried just parsing the config file? Does it work?

Thanks!

thanks for replying,when i try to run outside a container everything works,nope no error message,but when i use containers it gives me logstash exit with code 0 there is my configuration files :
docker-compose.yml

logstash: 
        image: logstash:7.13.4
        environment:
            - LOGSTASH_JDBC_URL=jdbc:postgresql://postgres:5432/test1
            - LOGSTASH_JDBC_DRIVER=org.postgresql.Driver
            - LOGSTASH_JDBC_DRIVER_JAR_LOCATION=/usr/share/logstash/logstash-core/lib/jars/postgresql.jar
            - LOGSTASH_JDBC_USERNAME=postgres
            - LOGSTASH_JDBC_PASSWORD=postgres
            - LOGSTASH_ELASTICSEARCH_HOST=http://elasticsearch:9200
        volumes: 
            - ./logstashconfig/logstash.yml:/usr/share/logstash/config/logstash.yml
            - ./logstashconfig/:/usr/share/logstash/pipeline/
            - ./filesconfig/:/usr/share/logstash/pipeline/
            - ./jars/postgresql-42.2.22.jar:/usr/share/logstash/logstash-core/lib/jars/postgresql-42.2.22.jar
                       
                # - type: bind
                #   source: ./logstashconfig/
                #   target: /usr/share/logstash/pipeline/ 
                # - type: bind
                #   #can be either a host path or volume name.
                #   source: ./logstashconfig/piplines.yml
                #   #is the container path where the volume is mounted
                #   target: /usr/share/logstash/pipeline/piplines.yml
                #   read_only: true
        ports:   
        
        - "5000:5000"
        
        depends_on: 
            - postgres 
            - elasticsearch

and :

file2.conf

input { 
   tcp{
        port=> "9600"
    }

jdbc {
jdbc_connection_string =>
"jdbc:postgresql://postgres:5432/test1"
jdbc_user => "postgres"
jdbc_password => "postgres"
jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/postgresql-42.2.22.jar"
jdbc_driver_class =>"org.postgresql.Driver"
schedule => "* * * * *"
statement => "select email,id from public."test" " 
}
stdin { } }
output {
  elasticsearch { hosts => ["elasticsearch:9200"] 
  index => "test"
  document_id => "test_%{id}"
  

}
  stdout { codec => rubydebug }
}

and :
logstash.yml

## Default Logstash configuration from Logstash base image.
## https://github.com/elastic/logstash/blob/master/docker/data/logstash/config/logstash-full.yml
#
http.host: "0.0.0.0"
xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ]
## X-Pack security credentials
#
#xpack.monitoring.enabled: true
#xpack.monitoring.elasticsearch.username: elastic
#xpack.monitoring.elasticsearch.password: changeme
# Settings file in YAML

1 Like

please share your complete configuration in a gist. Maybe you are missing network configuration in your docker compose files, it's hard to tell without seeing the full setup.

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