The project displays running a sample nodejs app and elk dashboard in container environment Together the samples can be used to demonstrate or used for API Management demos.
Currently the API server only hosts two endpoints
/ and /api/nf1.
/nf1 is coded to randomly generate error
APIDemo image
- docker run --name apidemo1 -d -p 3000:3000 sbacker/apidemo
- curl http://localhost:3000/api/nf1 to access the app
ELK Dashboard
- docker run -e MAX_MAP_COUNT=262144 -p 5000:5000 -p 5601:5601 -p 9200:9200 -p 5044:5044 -it --name elk sbacker/elk
- Incase you update the grok filter for logstash. Restart logstash demon with command: service logstash restart
- Index is preconfigured on ELK image, incase you change it please create a new index
NGINX Image You need to procure license for NGINX+ or use opensource version
Steps to configure NGINX+ Gateway for logging
- Enable audit on NGINX+ (sample conf file attached)
log_format logstash '$remote_addr - "$api_client_name" [$time_local] "$request" $status $body_bytes_sent "$http_referer"
"$http_user_agent" "$http_x_forwarded_for" $apimgmt_environment $apimgmt_definition $apimgmt_entry_point .
"$apimgmt_environment_name" "$apimgmt_definition_name" $jwt_claim_sub'; - Install Filebeat NGIN+ image wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list sudo apt-get update sudo apt-get install filebeat
- Configure Filebeat (sample file attached)
- Edit etc/filebeat/fibeat.yml
- add your logstash location to output.logstash section
- add the location of logfile to filebeat input
- Restart filebeat services. service filebeat restart
Generate data Prereq: curl installed
- edit gendata.sh to reflect the correct IP address for server variable
- sh gendata.sh
Build Container Images Incase you want to extend the API and extend the code
- Copy the Dockerfile and exp_api.js in the same folder
- execute docker build -t apidemo