OpenWhisk log forwarder

J Thomas has written an OpenWhisk forwarder, which is another OpenWhisk function. This function will push the OpenWhisk actions log to the local ELK stack. Let's see how this is done. First, we need to clone the public repository that he has created, make a few changes, and then deploy the function to the Bluemix portal for the particular space. This function will push the logs into the local ELK using burrow tunneled host and port: 

  1. Git clone the j thomas repository using the following code:
$ git clone https://github.com/jthomas/OpenWhisk-logstash-forwarder.git
  1. Export the OpenWhisk auth and api host for deploying to the Bluemix portal. You need to log into the portal to get the latest details using the following code:
$ export OW_AUTH=00700a7f-2b1a-4831-bf32-3a566263ed44:4TBcM7f8g0gj5UPgSVHXwNmMkfpbX36OdWximngOwqZYAJrDSkZwPjeSPjQ45Wm1
$ export OW_APIHOST=OpenWhisk.eu-gb.bluemix.net
  1. Install the serverless OpenWhisk plugin and the latest version of Serverless Framework (if it is not already installed) using the following code:

$ npm install --global serverless serverless-openwhisk

/usr/local/bin/serverless -> /usr/local/lib/node_modules/serverless/bin/serverless
/usr/local/bin/slss -> /usr/local/lib/node_modules/serverless/bin/serverless
/usr/local/bin/sls -> /usr/local/lib/node_modules/serverless/bin/serverless
> serverless@1.26.1 postinstall /usr/local/lib/node_modules/serverless
> node ./scripts/postinstall.js
serverless@1.26.1
+ serverless-OpenWhisk@0.12.0
added 5 packages, removed 2 packages and updated 38 packages in 13.232s
  1. Install the dependencies, as shown in the following code:
$ npm install
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw== integrity checksum failed when using sha512: wanted sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw== but got sha1-ygtl2gLtYpNYh4COb1EDgQNOM1Y=. (57090 bytes)
---
---
> fsevents@1.1.2 install /Users/shashi/Documents/packt/chapter5/ELK/OpenWhisk-logstash-forwarder/node_modules/fsevents

> node install
[fsevents] Success: "/Users/shashi/Documents/packt/chapter5/ELK/OpenWhisk-logstash-forwarder/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
> OpenWhisk-logstash-forwarder@0.1.0 postinstall /Users/shashi/Documents/packt/chapter5/ELK/OpenWhisk-logstash-forwarder
> npm link serverless-OpenWhisk
/Users/shashi/Documents/packt/chapter5/ELK/OpenWhisk-logstash-forwarder/node_modules/serverless-OpenWhisk -> /usr/local/lib/node_modules/serverless-OpenWhisk
added 606 packages in 9.933s

Update available 5.5.1 → 5.8.0
Run npm i -g npm to update
  1. Deploy the action with serverless, as shown in the following code:
 $ serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling Functions...
Serverless: Compiling Packages...
Serverless: Compiling API Gateway definitions...
Serverless: Compiling Rules...
Serverless: Compiling Triggers & Feeds...
Serverless: Deploying Functions...
Serverless: Deploying Triggers...
Serverless: Binding Feeds To Triggers...
Serverless: Deploying Rules...
Serverless: Deployment successful!

Service Information
platform: OpenWhisk.eu-gb.bluemix.net
namespace: _
service: logging
packages:
no packages deployed
actions:

logging-dev-logstash-forwarder myTEST weatherReport-dev-main
triggers:
logging_logstash-forwarder_schedule_trigger
rules:
logging_logstash-forwarder_schedule_rule
endpoints (api-gw):
**failed to fetch routes**
api gateway key is wrong or has expired! if it has expired, please refresh with wsk bluemix login
endpoints (web actions):

no web actions deployed

Once the action or function is successfully deployed, we will see the logs following your local ELK stack, and we should be able to view them.