Panda Sky 2.5 - Log Tailing for Sky Deployments
Sky 2.5 introduces a new, handy feature: log tailing. You can now look at your entire deployment’s log trace from the comfort of your own terminal.
The Inner Lives of Lambdas
Panda Sky adds value by stitching together existing Cloud technologies from AWS and guiding you toward an effective way to use them. But serverless architectures require a to developer to update their workflow and mental model.
I wrote previously about these changes, but what Sky lacked was a way to get at the internal state of the Lambdas it deploys. AWS automatically shuttles a given Lambda’s logs to CloudWatch, but as a corpus the logs are scattered (An issue people have complained about for two years running 🤣 ).
Now, Sky gathers the logs from every Lambda in your deployment and presents them in the terminal for you.
Usage
$ sky tail [environment] -v
That’s it.
sky tail
queries for every CloudWatch log associated with your deployment’s Lambdas, parses them, and outputs them together for you in the terminal. And, it does that dynamically. You can update and even publish entirely new Lambdas, while just leaving tail
running in another terminal. Sky will keep up, find the new log locations for you, and output the results to the screen.
tail
supports different verbosity levels. By default, it only displays ERROR
, WARN
, INFO
, and the generic CONSOLE
messages. With the -v
or --verbose
flags, Sky outputs all messages, including the START
, END
, REPORT
Lambda system messages along with any DEBUG
level messages.
You can access the message levels with a new helper in our panda-sky-helpers
library. Any explicit log statement that doesn’t use the logger appears with the level CONSOLE
and is presented by default. Here’s the code from the above output example.
import {log} from "panda-sky-helpers"
handler = (request, context) ->
name = request.url.path.name || "World"
throw new Error "This is a test error" if name == "test"
name = name.charAt(0).toUpperCase() + name.slice(1)
log.debug "The input name is #{name}"
log.info "The input name is #{name}"
log.warn "The input name is #{name}"
log.error "The input name is #{name}"
console.log "The input name is #{name}"
"Hello, #{name}!"
export default handler
Error Traces
Our helper library also now includes the logger in its dispatch
tool. So, when your handler encounters an error, it is intercepted like this:
Look closely at that error stack trace. Because Sky uses Babel to pipeline your code, you get traces with meaningful line numbers. That completes the workflow loop: Write locally, run remotely, and iterate quickly.
Limitations
While tail
is powerful, there is a noticeable delay (~10s) between when a Lambda runs and when its logs are output to your terminal. That delay is the time it takes for logs to be shuttled from a given Lambda execution to CloudWatch and is beyond Sky’s power to hasten.
Future
Logging is just one more way Sky makes it easy to build serverless APIs. Now that basic tailing is in place, the logging roadmap features more advanced configuration support, including retention and encryption configurations.
Final Notes
I’ll keep you posted with news from Sky. Here are some more resources to check out in the meantime.