Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export PostgreSQL logs of a RDS instance in CloudFormation to CloudWatch?

I am attempting to get the postgreSQL logs from an RDS instance that is using version 10.6, which is set up in a cloudformation template. When I run it through out system I'm getting the error message

You cannot use the log types 'Postgresql' with engine version postgres 10.6. For supported log types, see the documentation.

The documentation seems pretty straight forward in what it asks for. A list of strings to for the parameters, and postgreSQL supports both Postgresql log and Upgrade log. I know this to be true as I am able to export these logs though the AWS console. The documentation doesn't mention what strings are expected. So I've tried 'postgres', 'postgresql', 'postgresql_log', and so on but nothing is catching. I'm sure I must be missing something important but I can't find it, and the only example I have found on the internet ahsn't been able to enlighten me.

   RDSInstance:
        Type: AWS::RDS::DBInstance
        DependsOn: RDSMonitoringRole
        Properties:
            ****
            EnableCloudwatchLogsExports:
                - Postgresql
            MonitoringInterval: 60
            MonitoringRoleArn: !GetAtt ["RDSMonitoringRole", "Arn"]
            ****

    RDSMonitoringRole:
        Type: AWS::IAM::Role
        Properties:
            ManagedPolicyArns:
                - arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole
            AssumeRolePolicyDocument:
                Version: '2008-10-17'
                Statement:
                    -
                        Effect: Allow
                        Principal:
                            Service: 'monitoring.rds.amazonaws.com'
                        Action: 'sts:AssumeRole'
like image 452
Jay Cork Avatar asked Sep 06 '25 01:09

Jay Cork


1 Answers

The docs are quiet confusing, but if you read carefully you can see that under Publishing PostgreSQL Logs to CloudWatch Logs it is written that:

You can publish the following log types to CloudWatch Logs for RDS for PostgreSQL:

Postgresql log

Upgrade log (not available for Aurora PostgreSQL)

When navigating to the AWS CLI examples:

1 ) You can see under: Example Modify an instance to publish logs to CloudWatch Logs:

The key for this object is EnableLogTypes, and its value is an array of strings with any combination of postgresql and upgrade.

2 ) Further on under: Example Create an instance to publish logs to CloudWatch Logs:

The strings can be any combination of postgresql and upgrade.


For those who use Aurora PostgreSQL - taken from here:

Be aware of the following: Aurora PostgreSQL supports publishing logs to CloudWatch Logs for versions 9.6.12 and above and versions 10.7 and above.
From Aurora PostgreSQL, only postgresql logs can be published.
Publishing upgrade logs isn't supported.

like image 104
RtmY Avatar answered Sep 09 '25 02:09

RtmY