Skip to content

Customise logging for lambda function components deployed in Greengrass v2

0

Hello,

we have written some lambdaFunction components (migrated from Greengrass v1) e.g. MySpecialComponent in Java (Kotlin) and are logging messages to stdout and stderr respectively.

The messsages in the recorded com.redbite.MySpecialComponent.log look something like below:

2025-02-24T15:17:34.010Z [INFO] (pool-3-thread-14) com.redbite.MySpecialComponent: [DefaultDispatcher-worker-3] u.d.t.FaultTolerantTagSender - Publishing 0 persisted tags. {serviceInstance=0, serviceName=com.redbite.MySpecialComponent, currentState=RUNNING}

where both the prefix

2025-02-24T15:17:34.010Z [INFO] (pool-3-thread-14) com.redbite.MySpecialComponent: 

and suffix

{serviceInstance=0, serviceName=com.redbite.MySpecialComponent, currentState=RUNNING}

are added by the Greengrass service.

We would like Greengrass to not add any information and just include whatever the application logs.

asked 10 months ago56 views
1 Answer
0
Accepted Answer

Unfortunately, it's not possible to completely remove the additional logging information added by AWS IoT Greengrass for Lambda function components. The Greengrass service automatically adds certain metadata to the log entries for context and easier troubleshooting.

However, you can customize the logging behavior to some extent:

  1. Log Level: You can configure the minimum log level that Greengrass writes to file system logs. This allows you to control the verbosity of the logs, potentially reducing some of the additional information.

  2. JSON Structured Logging: While not removing the Greengrass-added information, you could consider using JSON structured logging in your Lambda function. This would make it easier to parse and extract just your application's log messages programmatically if needed.

  3. Custom Logging: Instead of using standard output/error streams, you could implement a custom logging mechanism in your component that writes logs to a separate file. This would give you full control over the log format, but you'd need to manage log rotation and other aspects yourself.

  4. Log Manager Configuration: You can configure the log manager component to customize some aspects of logging, such as the maximum disk space for each log and the minimum log level written to CloudWatch Logs.

While these options don't completely remove the Greengrass-added information, they provide some level of customization for your logging needs. If you absolutely need raw application logs without any additions, you might need to consider alternative logging strategies within your application code.
Sources
Monitor AWS IoT Greengrass logs - AWS IoT Greengrass
JSON Structured Logging for .NET Lambda Functions | AWS Developer Tools Blog

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.