Dev challenge use cases to pull reports from db 05/1805/7
authorparichay gupta <pg0057291@techmahindra.com>
Tue, 8 May 2018 19:15:19 +0000 (15:15 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Wed, 9 May 2018 18:43:05 +0000 (14:43 -0400)
Issue-ID: ACUMOS-806
Change-Id: Ic4e180550fb0ca5ec6d93a323f320a4c3520e8c9
Signed-off-by: parichay gupta <pg0057291@techmahindra.com>
elk-stack/acumos-elk-env.sh
elk-stack/logstash/Dockerfile
elk-stack/logstash/pipeline/logstash.conf

index 7716a96..eee4060 100644 (file)
@@ -35,3 +35,14 @@ export ACUMOS_ELK_ES_JAVA_HEAP_MIN_SIZE=1g
 export ACUMOS_ELK_ES_JAVA_HEAP_MAX_SIZE=1g
 export ACUMOS_ELK_LS_JAVA_HEAP_MIN_SIZE=1g
 export ACUMOS_ELK_LS_JAVA_HEAP_MAX_SIZE=1g
+
+# JDBC Parameters
+host=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
+export ACUMOS_ELK_JDBC_DRIVER_LIBRARY=/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar
+export ACUMOS_ELK_JDBC_DRIVER_CLASS=org.mariadb.jdbc.Driver
+export ACUMOS_ELK_DATABASE_PORT=3306
+export ACUMOS_ELK_DATABASE_NAME=cds1140m_upd
+export ACUMOS_ELK_DATABASE_URL=$host
+export ACUMOS_ELK_JDBC_CONNECTION_STRING=jdbc:mariadb://$ACUMOS_ELK_DATABASE_URL:$ACUMOS_ELK_DATABASE_PORT/$ACUMOS_ELK_DATABASE_NAME
+export ACUMOS_ELK_JDBC_USERNAME=cds_report
+export ACUMOS_ELK_JDBC_PASSWORD=cds_report
index 7bdda31..5b415f3 100644 (file)
 # ===============LICENSE_END=========================================================
 # https://github.com/elastic/logstash-docker
 FROM docker.elastic.co/logstash/logstash:5.5.1
-#FROM docker.elastic.co/logstash/logstash:6.0.1
+RUN /usr/share/logstash/bin/logstash-plugin install logstash-input-jdbc
+ADD https://downloads.mariadb.com/enterprise/1prc-8jnh/connectors/java/connector-java-2.1.0/mariadb-java-client-2.1.0.jar /usr/share/logstash/vendor/bundle/
+USER root
+RUN ls -al /usr/share/logstash/vendor/bundle \
+  && chmod a+r /usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar
 
-# Add your logstash plugins setup here
-# Example: RUN logstash-plugin install logstash-filter-json
-# Install plugin for development
-##RUN /opt/logstash/bin/logstash-plugin install --development
-##RUN /opt/logstash/bin/logstash-plugin list
-
-
-# Prepare directory & file for test
-##USER root
-##RUN mkdir -p /test
-
-#ADD spec /test/spec
-#ADD pipeline /test/pipeline
-##ADD spec/*.rb /test/spec
-##ADD pipeline/logstash.conf /test/pipeline/logstash.conf
-##ADD run.sh /usr/local/bin/run.sh
-
-##RUN chown logstash /usr/local/bin/run.sh && chmod +x /usr/local/bin/run.sh
-
-##USER logstash
-##CMD ["/usr/local/bin/run.sh"]
-#USER logstash
index 6cb5c37..3d15181 100644 (file)
@@ -1,4 +1,105 @@
+# ===============LICENSE_START=======================================================
+# Acumos Apache-2.0
+# ===================================================================================
+# Copyright (C) 2017-2018 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+# ===================================================================================
+# This Acumos software file is distributed by AT&T and Tech Mahindra
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# This file is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ===============LICENSE_END=========================================================
 input {
+
+
+jdbc {
+          jdbc_driver_library => "${ACUMOS_ELK_JDBC_DRIVER_LIBRARY:/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar}"
+       jdbc_driver_class => "${ACUMOS_ELK_JDBC_DRIVER_CLASS:org.mariadb.jdbc.Driver}"
+          jdbc_connection_string => "${ACUMOS_ELK_JDBC_CONNECTION_STRING:jdbc:mariadb://cognita-ist2-vm01-db.eastus.cloudapp.azure.com:3306/acumosist_1_14_0}"
+       jdbc_user => "${ACUMOS_ELK_JDBC_USERNAME:acumos_ro}"
+       jdbc_password => "${ACUMOS_ELK_JDBC_PASSWORD:istro2017}"
+       jdbc_validate_connection => true
+       statement => "SELECT * FROM C_SOLUTION_DOWNLOAD"
+       type => "solution_downloaded"
+       tags => ["database"]
+      }
+jdbc {
+           jdbc_driver_library => "${ACUMOS_ELK_JDBC_DRIVER_LIBRARY:/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar}"
+       jdbc_driver_class => "${ACUMOS_ELK_JDBC_DRIVER_CLASS:org.mariadb.jdbc.Driver}"
+          jdbc_connection_string => "${ACUMOS_ELK_JDBC_CONNECTION_STRING:jdbc:mariadb://cognita-ist2-vm01-db.eastus.cloudapp.azure.com:3306/acumosist_1_14_0}"
+       jdbc_user => "${ACUMOS_ELK_JDBC_USERNAME:acumos_ro}"
+       jdbc_password => "${ACUMOS_ELK_JDBC_PASSWORD:istro2017}"
+       jdbc_validate_connection => true
+       statement => "SELECT * FROM C_USER"
+       type => "no_of_user"
+       tags => ["database"]
+      }
+jdbc {
+          jdbc_driver_library => "${ACUMOS_ELK_JDBC_DRIVER_LIBRARY:/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar}"
+       jdbc_driver_class => "${ACUMOS_ELK_JDBC_DRIVER_CLASS:org.mariadb.jdbc.Driver}"
+          jdbc_connection_string => "${ACUMOS_ELK_JDBC_CONNECTION_STRING:jdbc:mariadb://cognita-ist2-vm01-db.eastus.cloudapp.azure.com:3306/acumosist_1_14_0}"
+       jdbc_user => "${ACUMOS_ELK_JDBC_USERNAME:acumos_ro}"
+       jdbc_password => "${ACUMOS_ELK_JDBC_PASSWORD:istro2017}"
+       jdbc_validate_connection => true
+       statement => "SELECT * FROM C_SOLUTION_DEPLOYMENT"
+       type => "solution_deployed"
+       tags => ["database"]
+      }
+jdbc {
+          jdbc_driver_library => "${ACUMOS_ELK_JDBC_DRIVER_LIBRARY:/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar}"
+       jdbc_driver_class => "${ACUMOS_ELK_JDBC_DRIVER_CLASS:org.mariadb.jdbc.Driver}"
+          jdbc_connection_string => "${ACUMOS_ELK_JDBC_CONNECTION_STRING:jdbc:mariadb://cognita-ist2-vm01-db.eastus.cloudapp.azure.com:3306/acumosist_1_14_0}"
+       jdbc_user => "${ACUMOS_ELK_JDBC_USERNAME:acumos_ro}"
+       jdbc_password => "${ACUMOS_ELK_JDBC_PASSWORD:istro2017}"
+       jdbc_validate_connection => true
+       statement => "SELECT * FROM C_SOLUTION"
+       type => "all_solution"
+       tags => ["database"]
+      }
+jdbc {
+          jdbc_driver_library => "${ACUMOS_ELK_JDBC_DRIVER_LIBRARY:/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar}"
+       jdbc_driver_class => "${ACUMOS_ELK_JDBC_DRIVER_CLASS:org.mariadb.jdbc.Driver}"
+          jdbc_connection_string => "${ACUMOS_ELK_JDBC_CONNECTION_STRING:jdbc:mariadb://cognita-ist2-vm01-db.eastus.cloudapp.azure.com:3306/acumosist_1_14_0}"
+       jdbc_user => "${ACUMOS_ELK_JDBC_USERNAME:acumos_ro}"
+       jdbc_password => "${ACUMOS_ELK_JDBC_PASSWORD:istro2017}"
+       jdbc_validate_connection => true
+       statement => "SELECT * FROM C_SOLUTION WHERE ACCESS_TYPE_CD='OR'"
+       type => "company_model"
+       tags => ["database"]
+      }
+jdbc {
+          jdbc_driver_library => "${ACUMOS_ELK_JDBC_DRIVER_LIBRARY:/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar}"
+       jdbc_driver_class => "${ACUMOS_ELK_JDBC_DRIVER_CLASS:org.mariadb.jdbc.Driver}"
+          jdbc_connection_string => "${ACUMOS_ELK_JDBC_CONNECTION_STRING:jdbc:mariadb://cognita-ist2-vm01-db.eastus.cloudapp.azure.com:3306/acumosist_1_14_0}"
+       jdbc_user => "${ACUMOS_ELK_JDBC_USERNAME:acumos_ro}"
+       jdbc_password => "${ACUMOS_ELK_JDBC_PASSWORD:istro2017}"
+       jdbc_validate_connection => true
+       statement => "SELECT * FROM C_SOLUTION WHERE ACCESS_TYPE_CD='PB'"
+       type => "public_model"
+       tags => ["database"]
+      }
+jdbc {
+          jdbc_driver_library => "${ACUMOS_ELK_JDBC_DRIVER_LIBRARY:/usr/share/logstash/vendor/bundle/mariadb-java-client-2.1.0.jar}"
+       jdbc_driver_class => "${ACUMOS_ELK_JDBC_DRIVER_CLASS:org.mariadb.jdbc.Driver}"
+          jdbc_connection_string => "${ACUMOS_ELK_JDBC_CONNECTION_STRING:jdbc:mariadb://cognita-ist2-vm01-db.eastus.cloudapp.azure.com:3306/acumosist_1_14_0}"
+       jdbc_user => "${ACUMOS_ELK_JDBC_USERNAME:acumos_ro}"
+       jdbc_password => "${ACUMOS_ELK_JDBC_PASSWORD:istro2017}"
+       jdbc_validate_connection => true
+       statement => "select solution.name,CONCAT(user.first_name,' ',user.last_name) from c_solution solution inner join c_user user on user.USER_ID = solution.OWNER_ID"
+       type => "name_model"
+       tags => ["database"]
+      }
+
+
+
+
+
   beats {
         port => 5000
         codec => plain {
@@ -33,7 +134,18 @@ filter {
 
 
 output {
-        elasticsearch { hosts => ["elasticsearch:9200"]
+       stdout { codec => json_lines }
+       if "database" in [tags]{
+       elasticsearch {
+       hosts => ["elasticsearch:9200"]
+       index => "testdb"
+       document_type => "%{type}"
        }
-
+      }
+    else {
+     elasticsearch {
+       hosts => ["elasticsearch:9200"]
+       index => "logstash"
+           }
+      }
 }