Skip to content
This repository was archived by the owner on Oct 26, 2023. It is now read-only.
This repository was archived by the owner on Oct 26, 2023. It is now read-only.

Default filterPattern often causes setup problems #16

@blimmer

Description

@blimmer

By default, this filter-pattern doesn't usually work:

const filterPattern = !!this.serverless.service.custom.shipLogs.filterPattern
? this.serverless.service.custom.shipLogs.filterPattern
: "[timestamp=*Z, request_id=\"*-*\", event]";

The reason is because most of my logs have the log level before the first timestamp:

e.g.

[WARNING] 2018-07-10T22:34:59.702Z 78c487eb-8491-11e8-a9be-abc1234241 blocklist: set() 

This causes no logs to be delivered to the Lambda.

I'd like to propose two options instead of this default.

No filterPattern by default

This is probably the easiest and most effective in most cases. This would change the default behavior to have filterPattern be a blank string if you don't explicitly set it.

Pros

  • Straight-forward to implement
  • Originally what I expected to happen

Cons

  • The Lambda function start / end / report blocks would be sent to SumoLogic
  • Change in default behavior might be undesirable for users as they upgrade

filterPattern using ... instead

From the AWS docs on the topic, it states that you can use the ellipses when you don't know the number of fields present.

In cases where you don't know the number of fields, you can use shorthand notification using an ellipsis (…). For example:

[..., status_code, bytes]
[ip, user, ..., status_code, bytes]
[ip, user, ...]

We could instead use something like this to try to extract just the logs.

Pros

  • If executed properly, would remove the Lambda start / end / report blocks

Cons

  • Prone to breaking again if CloudWatch changes the format in some way

Thoughts?

What do you think? I think either way this should be changed since, by default, this has stopped reporting all of my logs with the default filter because of the log_level introduction as the first param.

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