使用NSSM将多个配置文件作为logstash服务运行

我正在使用logstash-7.4并使用NSSM将其作为服务运行。我有一个配置文件,将数据提取到ElasticSearch的索引(index_one),另一个配置文件,将数据提取到ElasticSearch的另一个索引(indiex_two)。 (注意:-两个配置文件都是在不同的时间间隔和时间安排的)。我是否可以将两个文件都设置为服务,具有两个不同的名称,例如service_one用于将conf文件提取数据索引到index_one,而service_two则用于将conf文件提取数据数据提取到indiex_two。这样做是好事还是有更好的方法做到这一点。

下面是两个配置文件: 配置文件1: #file:db.conf

input { 
    jdbc { 
        jdbc_driver_library => ""
        jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver" 
        jdbc_connection_string => "jdbc:oracle:thin:@nl0123vca0020.xyz-nl0123.abc.com:1521/pintu1"
        jdbc_user =>"usersys2"
        jdbc_password => "password"
        statement => "select name,id,address,col_1,col_2,col_3 from  demo_table_1"
        schedule => "0 */2 * * *"
        last_run_metadata_path => "E:/logstash-7.4.2/config/intouch_db_index_increment.txt"
        use_column_value => true
        tracking_column => "version"
    } 
}
filter {
    mutate {
        convert => {
            "contentid" => "string"
        }
    }
}
output{
    elasticsearch {
        hosts => ["http://***.***.119.199:9200"]
        index => "index_two"
        document_id =>"%{contentid}"
        user => "elastic" 
        password => "passwordes" 
    }
}

配置文件2:-

input {
    jdbc {
        jdbc_driver_library => ""
        jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
        jdbc_connection_string => "jdbc:oracle:thin:@nl0123vca0020.xyz-nl0123.abc.com:1521/pintu1"
        jdbc_user =>"usersys2"
        jdbc_password => "password"
        statement  => "select autosuggestid,userid,ldapalias,email,decode(trim(firstname || ' ' || lastname),'',(firstname || ' ' || lastname)) FULLNAME,status as USERSTATUS from demo_autosuggest where rownum < 999999999999" 
        jdbc_fetch_size => "100000" 
        schedule => "0 12 * * *"
    }
}
output{
    elasticsearch {
        hosts => ["http://***.***.119.199:9200"]
        index => "index_two"
        document_id =>"%{autosuggestid}"
        user => "elastic"
        password => "passwordes"
    }
}
iCMS 回答:使用NSSM将多个配置文件作为logstash服务运行

This is how I have configured the conf file of logstash to ingest data from two different sql statements into multiple Elasticsearch indices using logstash.


    input { 
        jdbc { 
            type=>"autosuggest"
            jdbc_driver_library => ""
            jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver" 
            jdbc_connection_string => "jdbc:oracle:thin:@nl0123vca0020.xyz-nl0123.abc.com:1521/pintu1"
            jdbc_user =>"usersys2"
            jdbc_password => "password"
            statement => "select name,id,address,col_1,col_2,col_3 from  demo_table_1"
            schedule => "0 */2 * * *"
            last_run_metadata_path => "E:/logstash-7.4.2/config/intouch_db_index_increment.txt"
            use_column_value => true
            tracking_column => "version"
        } 
jdbc {
        type=>"dbindex"
        jdbc_driver_library => ""
        jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
        jdbc_connection_string => "jdbc:oracle:thin:@nl0123vca0020.xyz-nl0123.abc.com:1521/pintu1"
        jdbc_user =>"usersys2"
        jdbc_password => "password"
        statement  => "select autosuggestid,userid,ldapalias,email,decode(trim(firstname || ' ' || lastname),'',(firstname || ' ' || lastname)) FULLNAME,status as USERSTATUS from demo_autosuggest where rownum < 999999999999" 
        jdbc_fetch_size => "100000" 
        schedule => "0 12 * * *"
    }
    }

    filter {
       if [type] == "dbindex" 
        mutate {
            convert => {
                "contentid" => "string"
            }
        }
    }
    output{
        if [type] == "autosuggest"
    {  
        elasticsearch {
            hosts => ["http://***.***.119.199:9200"]
            index => "index_two"
            document_id =>"%{contentid}"
            user => "elastic" 
            password => "passwordes" 
        }
    }
   if [type] == "dbindex" 
    {
   elasticsearch {
        hosts => ["http://***.***.119.199:9200"]
        index => "index_two"
        document_id =>"%{autosuggestid}"
        user => "elastic"
        password => "passwordes"
    }
    } 
    }
本文链接:https://www.f2er.com/1814314.html

大家都在问