awslabs / aws-athena-query-federation

The Amazon Athena Query Federation SDK allows you to customize Amazon Athena with your own data sources and code.
Apache License 2.0
562 stars 297 forks source link

[FEATURE] Support advanced logging controls for Lambda functions #2409

Open sergei-ivanov opened 6 days ago

sergei-ivanov commented 6 days ago

Is your feature request related to a problem? If yes, please describe.

Lambda function configuration now allows setting log level and switch between plain text and JSON logging. But unfortunately it's not currently being handled by the federation connectors. If I configure JSON logging, only Lambda runtime picks up that configuration. The connector still logs in plain text.

Describe the solution you'd like

Update Log4j2 configuration for all connectors according to the AWS guide.

For example, the logging configuration for Athena connector should be changed to:

<Configuration packages="com.amazonaws.services.lambda.runtime.log4j2">
    <Appenders>
        <Lambda name="Lambda" format="${env:AWS_LAMBDA_LOG_FORMAT:-TEXT}">
            <LambdaTextFormat>
                <PatternLayout>
                    <pattern>%d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1} - %m%n </pattern>
                </PatternLayout>
            </LambdaTextFormat>
            <LambdaJSONFormat>
                <JsonTemplateLayout eventTemplateUri="classpath:LambdaLayout.json" />
            </LambdaJSONFormat>
        </Lambda>
    </Appenders>
    <Loggers>
        <Logger name="com.amazonaws.athena.connector.lambda" level="${env:ATHENA_FEDERATION_SDK_LOG_LEVEL:-warn}" />
        <Logger name="com.amazonaws.athena.connectors.postgresql" level="${env:ATHENA_FEDERATION_SDK_LOG_LEVEL:-warn}" />
        <Root level="${env:AWS_LAMBDA_LOG_LEVEL:-INFO}">
            <AppenderRef ref="Lambda" />
        </Root>
    </Loggers>
</Configuration>

Describe alternatives you've considered N/A

Additional context N/A