One-Line Command For Newest OpenWhisk Logs

One of my current project uses OpenWhisk, which is an open source serverless technology stack. IBM has it on their Bluemix platform, and since I work there, I get to play with it as much as I like! One thing that did seem clunky is that it takes more than one step to get the logs of the most recent function run via commandline – first you list the activations, then you request the logs of the activation you’re interested in. Of course, when you’re developing, that’s usually the most recent one so here’s my shortcut for that:

wsk activation list -l1 | tail -n1 | cut -d ' ' -f1 | xargs wsk activation logs

From left to right, sections separated by the pipe | character, this is what happens:

  • get a list of activations, limited to just one activation (it sorts the newest one first by default)
  • grab only the last line of that output (there’s some extra titles and stuff in there)
  • use the `cut` command with the space character as a field delimiter, and use only the first field (this gets the ID of the activation)
  • get the logs of that activation

Of course it’s wrapped up in a script so I just run that from the commandline and check where I went wrong this time …

4 thoughts on “One-Line Command For Newest OpenWhisk Logs

  1. Pingback: Alexa Project Name Generator on OpenWhisk | LornaJane

  2. Pingback: Serverless Swift on OpenWhisk | Rob Allen's DevNotes

  3. Pingback: Serverless Swift on OpenWhisk – scribdbook

  4. The [code]wsk [/code] tool has been updated recently and there’s now a shortcut to getting the lots for the last activation:

    [code]wsk activation logs –last[/code]

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.