Giter Site home page Giter Site logo

central-logging's Introduction

Central logging

Description: Central logging system for all requests to alizz islamic bank middleware.

Copyright © 2020 alizz islamic Bank. All Rights Reserved.

Author: Revanth Nemani [email protected]

Introduction

The central logging system for alizz islamic bank is a service to log all incoming requests and their corresponding outgoing responses to/from the middleware.

Install and Uninstall

Install

Install in node user home:

Get the package

cd /home/node/

wget -O central-logging.tar.gz 'http://10.10.103.3:8080/it/node/central-logging/-/archive/v1.0.0/cental-logging-v1.0.0.tar.gz'

tar -xzf central-logging.tar.gz

Go into the newly extracted package and run the install script.

Edit the install script to suite your requirement.

cd /cental-logging-v1.0.0

sh install.sh

<CENTRAL_LOGGING_HOME> is reference to the install location. In this case /home/node/central-logging-v1.0.0

Uninstall

cd /home/node/

sh uninstall.sh

Administration

Start, stop and restart

This service once installed uses systemd. The service name is central-logging.service and can be used with systemctl commands.

To restart the service:

systemctl restart central-logging

To stop the service:

By default stopping will restart the service. In case you need to entirely stop the service without it auto restarting, edit the service file /lib/systemd/system/central-logging.service. In the service section find Restart=always and change it to Restart=on-failure. reload the system daemon: sudo systemctl daemon-reload. Run the below command to stop the service.

systemctl stop central-logging

In case you've changed the restart option either in the install script or after installation, you might need to start the service manually with the following command:

systemctl start central-logging

By default the install script will enable the service to run after startup of the server. To disable this: systemctl disable central-logging

To re-enable it: systemctl enable central-logging

MongoDB connection and other environment variables

The environment variables can be set/found in the .env file in <CENTRAL_LOGGING_HOME>

The environment variable can be divided into 3 categories:

  1. Development
  2. Test
  3. Production

Based on the value you set for NODE_ENV the service will pickup the relevent environment variables.

NODE_ENV can be set to development, test or production. For production scenario, always use production.

Following table will explain the rest of the environment variables:

development environment variable test environment variable prod environment variable Description
DEV_DB_USERNAME TEST_DB_USERNAME PROD_DB_USERNAME MongoDB username to connect with
DEV_DB_PASSWORD TEST_DB_PASSWORD PROD_DB_PASSWORD MongoDB password to connect with
DEV_DB_DATABASE_AUTH TEST_DB_DATABASE_AUTH PROD_DB_DATABASE_AUTH MongoDB authentication database
DEV_DB_DATABASE TEST_DB_DATABASE PROD_DB_DATABASE MongoDB database to store logs
DEV_DB_HOST TEST_DB_HOST PROD_DB_HOST MongoDB Hostname/IP
DEV_DB_PORT TEST_DB_PORT PROD_DB_PORT MongoDB Port
DEV_APP_HOST TEST_APP_HOST PROD_APP_HOST The hostname/IP of the server where the service is deployed
DEV_APP_PORT TEST_APP_PORT PROD_APP_PORT The port of the server where the service is deployed. Default is 5143
DEV_SERVER_TYPE TEST_SERVER_TYPE PROD_SERVER_TYPE Is the reverse proxy address type 'http' or 'https'? default is http
DEV_SERVER_NAME TEST_SERVER_NAME PROD_SERVER_NAME The hostname/IP of the reverse proxy
DEV_PROXY_PORT TEST_PROXY_PORT PROD_PROXY_PORT The host port of the reverse proxy
DEV_SECRET_KEY TEST_SECRET_KEY PROD_SECRET_KEY For accessing admin APIs. currently no API is using this. This can be omitted for now and may be used in future releases.

After setting the environment variables to suite your needs restart the service. These can be set in the install script prior to installation.

REST Services

This system natively supports json data, just follow the example requests/responses below.

For xml, text or other kind of requests:

Send the incoming request/ outgoing response as text as part of request/response object. Please do not forget to escape the quotes(" as \").

Example:

{
  "auth": {
    "uuid": "{{UUID4}}"
  },
  "request": "<root xlmns=\"http://example.org\"><auth><channelId>DBSYS</channelId><dateTime>2020-07-07T12:30:56</dateTime><msgType>0200</msgType><supervisoryId>DBSYSUSR</supervisoryId><terminalId>MB</terminalId><tranCode>0023</tranCode><uuid>2942f904-e8ca-410c-8a7c-17865bcff9b6</uuid></auth><request><billerCode>3</billerCode><consumerNo>35327</consumerNo><serviceType>Electricity</serviceType></request></root>"
}

GET Services

Headers

Accept:application/json

Request 1: Get the request and response logged by the central logging system using UUID4 passed in the request/response

http://10.10.150.42:5143/logs/{{UUID4 used in the request}}

POST Services

Headers

Content-Type:application/json
Accept:application/json

Request 1: insert incoming request to mongoDB

http://10.10.150.42:5143/logs

Example request

{
  "auth": {
    "uuid": "{{UUID4}}"
  },
  "request": {
  }
}

Example Success response

{
    "auth": {
        "uuid": "{{UUID4}}"
    },
    "request": {}
}

Example error response

{
    "success": 0,
    "reason": {
        "errorCode": "7",
        "errorDesc": "DuplicatedGUID"
    }
}

PATCH Services

Headers

Content-Type:application/json
Accept:application/json

Request 1: insert outgoing response to mongoDB

http://10.10.150.42:5143/logs

Example request

{
  "auth": {
    "uuid": "{{Same UUID4 used in request}}"
  },
  "response": {
  }
}

Example Success response

{
    "auth": {
        "uuid": "{{UUID4}}"
    },
    "request": {}
}

Example error response

{
    "success": 0,
    "reason": {
        "errorCode": "128",
        "errorDesc": "Cannot overwrite already existing response"
    }
}

central-logging's People

Contributors

dependabot[bot] avatar revanthnemani avatar saqe66r avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.