Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Overview of this book

Table of Contents (19 chapters)
PostgreSQL 9 Administration Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Producing a daily summary of log file errors


PostgreSQL can generate gigabytes of logs per day. Lots of data is good if you want to investigate some specific event, but it is not what you will use for daily monitoring of database health.

In this recipe, we'll see how to perform a post analysis of our log files and get reports (and insights) about what has happened in a given period of time.

PostgreSQL 9.2 enhances real-time analysis of queries through the pg_stat_statements extension, which will be covered in the next recipe.

Getting ready

Make sure that your PostgreSQL is set up to rotate the log files, for example, daily. I personally prefer to integrate PostgreSQL with rsyslog and logrotate for log management on Linux or Unix systems, but you can use any method that is allowed by PostgreSQL (CSV or standard error, for example).

A typical default setup will divert log messages to stderr, and you can set up log rotation directly in PostgreSQL through the log_rotation_age configuration option...