Skip to content

Log AWS and Custom Fields to AWS CloudWatch Log #115

Open
@matthewdfuller

Description

@matthewdfuller

I'm creating a Probot app using the sample code, like so:

const {
    createLambdaFunction,
    createProbot,
} = require("@probot/adapter-aws-lambda-serverless");
const appFn = require("./");

exports.handler = createLambdaFunction(appFn, {
    probot: createProbot(),
});

My NODE_ENV is set to production, which sets the pino logging output to JSON, which is logged to AWS CloudWatch.

Update: The environment variable is set, but the logging is not JSON; it's still pretty print.

However, the logs are missing some key pieces of information that I'd like to inject. Specifically: the AWS Request ID, CloudFront (or API Gateway) headers/trace IDs, and GitHub event IDs.

I found this issue that proposes something like:

const logger = pino.child({
      awsRequestId: context.awsRequestId,
})

But I can't figure out where to overwrite (or modify) the pino logger that Probot has already created.

Any ideas on where we could inject this additional info to make Lambda logs more useful?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions