Jay Cork
Jay Cork

Reputation: 414

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'

Upvotes: 4

Views: 4438

Answers (4)

Tony BenBrahim
Tony BenBrahim

Reputation: 7290

The allowed values of EnableCloudwatchLogsExports are listed here. As of this writing, they are:

  • Amazon Aurora: Not applicable. CloudWatch Logs exports are managed by the DB cluster.
  • RDS Custom: Not applicable.
  • MariaDB: Possible values are audit, error, general, and slowquery.
  • Microsoft SQL Server: Possible values are agent and error.
  • MySQL: Possible values are audit, error, general, and slowquery.
  • Oracle: Possible values are alert, audit, listener, trace, and oemagent.
  • PostgreSQL: Possible values are postgresql and upgrade.

Upvotes: 1

Gramos
Gramos

Reputation: 63

Pretty late but might help someone else:

According to docs https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-enablecloudwatchlogsexports

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

Upvotes: 0

Rotem jackoby
Rotem jackoby

Reputation: 22128

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.

Upvotes: 1

Emil Burzo
Emil Burzo

Reputation: 463

For anyone else, I also struggled with this, the docs weren't really helpful either.

Until I opened the "AWS CLI" section:

aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --cloudwatch-logs-export-configuration '{"EnableLogTypes":["postgresql", "upgrade"]}'

And those values worked for me.

I see that you mentioned you already tried them, so then maybe you ran into the version limitation?

Publishing log files to CloudWatch Logs is only supported for PostgreSQL versions 9.6.6 and above and 10.4 and above.

Upvotes: 0

Related Questions