Skip to main content
Sumo Logic

Install the PostgreSQL app, Alerts, and view the dashboards

This page provides instructions for installing the Sumo App for PostgreSQL, as well as the descriptions of each of the app dashboards.

This page provides instructions for installing the Sumo Appand Alerts for PostgreSQL, as well as the descriptions of each of the app dashboards.

Pre-Packaged Alerts

Sumo Logic has provided out of the box alerts available through Sumo Logic monitors to help you monitor your PostgreSQL cluster. These alerts are built based on metrics and logs datasets and include preset thresholds based on industry best practices and recommendations.

For details on the individual alerts,  please see this page.

Installing Alerts

  • To install these alerts, you need to have the Manage Monitors role capability.
  • Alerts can be installed by either importing them a JSON or a Terraform script.

Method 1: Install the alerts by importing a JSON file

  1. Download the JSON file describing all the monitors. 
    1. The JSON contains the alerts that are based on Sumo Logic searches that do not have any scope filters and therefore will be applicable to all PostgreSQL clusters, the data for which has been collected via the instructions in the previous sections. However, if you would like to restrict these alerts to specific clusters or environments, update the JSON file by replacing the text ‘db_system=postgresql with ‘<Your Custom Filter> db_system=postgresql’. 

      Custom filter examples: 

      1. For alerts applicable only to a specific cluster, your custom filter would be:  ‘db_cluster=postgresql-prod.01’.

      2. For alerts applicable to all clusters that start with postgresql-prod, your custom filter would be: ‘db_cluster=postgresql-prod*’.

      3. For alerts applicable to a specific cluster within a production environment, your custom filter would be: 

        • db_cluster=postgresql-1 and environment=prod (This assumes you have set the optional environment tag while configuring collection)

  2. Go to Manage Data > Alerts > Monitors.
  3. Click Add:
    Add monitors page.png
  4. Click Import to import monitors from the JSON above.

Method 2: Install the alerts using a Terraform script

Step 1: Generate a Sumo Logic access key and ID

Generate an access key and access ID for a user that has the Manage Monitors role capability in Sumo Logic using these instructions. Please identify which deployment your Sumo Logic account is in, using this  link.

Step 3: Download the Sumo Logic Terraform package for PostgreSQL alerts

The alerts package is available in the Sumo Logic github repository. You can either download it through the “git clone” command or as a zip file. 

Step 4: Alert Configuration 

After the package has been extracted, navigate to the package directory terraform-sumologic-sumo-logic-monitor/monitor_packages/postgresql/

Edit the postgresql.auto.tfvars file and add the Sumo Logic Access Key, Access Id and Deployment from Step 1 .

access_id   = "<SUMOLOGIC ACCESS ID>"

access_key  = "<SUMOLOGIC ACCESS KEY>"

environment = "<SUMOLOGIC DEPLOYMENT>"

The Terraform script installs the alerts without any scope filters, if you would like to restrict the alerts to specific clusters or environments, update the variable ’postgresql_data_source’. Custom filter examples: 

  1. A specific cluster ‘db_cluster=postgresql.prod.01’
  2. All clusters in an environment ‘environment=prod’
  3. For alerts applicable only to a specific cluster, your custom filter would be:  ‘db_cluster=postgresql-.prod.01’
  4. For alerts applicable to all clusters that start with postgresql-prod, your custom filter would be: ‘db_cluster=postgresql-prod*’
  5. For alerts applicable to a specific cluster within a production environment, your custom filter would be: 

db_cluster=postgresql-1 and environment=prod (This assumes you have set the optional environment tag while configuring collection)

All monitors are disabled by default on installation, if you would like to enable all the monitors, set the parameter monitors_disabled to false in this file.

By default, the monitors are configured in a monitor folder called “PostgreSQL”, if you would like to change the name of the folder, update the monitor folder name in this file.

If you would like the alerts to send email or connection notifications, configure these in the file postgresql_notifications.auto.tfvars. For configuration examples, refer to the next section.

Step 5: Email and Connection Notification Configuration Examples

To configure notifications, modify the file postgresql_notifications.auto.tfvars file and fill in the connection_notifications and email_notifications sections. See the examples for PagerDuty and email notifications below. See this document for creating payloads with other connection types.

Pagerduty Connection Example:
connection_notifications = [
    {
      connection_type       = "PagerDuty",
      connection_id         = "<CONNECTION_ID>",
      payload_override      = "{\"service_key\": \"your_pagerduty_api_integration_key\",\"event_type\": \"trigger\",\"description\": \"Alert: Triggered {{TriggerType}} for Monitor {{Name}}\",\"client\": \"Sumo Logic\",\"client_url\": \"{{QueryUrl}}\"}",
      run_for_trigger_types = ["Critical", "ResolvedCritical"]
    },
    {
      connection_type       = "Webhook",
      connection_id         = "<CONNECTION_ID>",
      payload_override      = "",
      run_for_trigger_types = ["Critical", "ResolvedCritical"]
    }
  ]

Replace <CONNECTION_ID> with the connection id of the webhook connection. The webhook connection id can be retrieved by calling the Monitors API.

Email Notifications Example:
email_notifications = [
    {
      connection_type       = "Email",
      recipients            = ["abc@example.com"],
      subject               = "Monitor Alert: {{TriggerType}} on {{Name}}",
      time_zone             = "PST",
      message_body          = "Triggered {{TriggerType}} Alert on {{Name}}: {{QueryURL}}",
      run_for_trigger_types = ["Critical", "ResolvedCritical"]
    }
  ]
Step 6: Install the Alerts
  1. Navigate to the package directory terraform-sumologic-sumo-logic-monitor/monitor_packages/postgresql/ and run terraform init. This will initialize Terraform and will download the required components.
  2. Run terraform plan to view the monitors which will be created/modified by Terraform.
  3. Run terraform apply.
Step 7: Post Installation

If you haven’t enabled alerts and/or configured notifications through the Terraform procedure outlined above, we highly recommend enabling alerts of interest and configuring each enabled alert to send notifications to other people or services. This is detailed in Step 4 of this document.

Install the app

This section demonstrates how to install the PostgreSQL App.

Now that you have set up log and metric collection for PostgreSQL, you can install the Sumo Logic App for PostgreSQL to use the pre-configured Searches and Dashboards.

To install the app, do the following:

Locate and install the app you need from the App Catalog. If you want to see a preview of the dashboards included with the app before installing, click Preview Dashboards.

  1. From the App Catalog, search for and select the app. 
  2. Select the version of the service you're using and click Add to Library.
  3. To install the app, complete the following fields.
    1. App Name. You can retain the existing name, or enter a name of your choice for the app.


    2. Data Source. Choose Enter a Custom Data Filter, and enter a custom PostgreSQL cluster filter. Examples: 

      • For all PostgreSQL clusters
        db_cluster=*

      • For a specific cluster:
        db_cluster=postgresql.dev.01.


      • Clusters within a specific environment:
        db_cluster=postgresql-1 and environment=prod 
        (This assumes you have set the optional environment tag while configuring collection)

    3. Advanced. Select the Location in Library (the default is the Personal folder in the library), or click New Folder to add a new folder.

  4. Click Add to Library.

Once an app is installed, it will appear in your Personal folder, or other folder that you specified. From here, you can share it with your organization. 

Panels will start to fill automatically. It's important to note that each panel slowly fills with data matching the time range query and received since the panel was created. Results won't immediately be available, but with a bit of time, you'll see full graphs and maps.

Dashboard Filters with template variables   

Template variables provide dynamic dashboards that can rescope data on the fly. As you apply variables to troubleshoot through your dashboard, you view dynamic changes to the data for a quicker resolution to the root cause. For more information, see the Filter with template variables help page.

PostgreSQL - Overview Dashboard

The PostgreSQL - Overview dashboard gives you an at-a-glance view of the state of your database clusters by monitoring errors, failed logins, slow queries and trends over time.

Use this dashboard to:

  • Determine the number of active databases, clusters and deadlocks.
  • Drill-down into database errors, failed logins and slow queries.
  • Determine if your database or queries need to be tuned based on comparing the number slow queries. 
  • Monitor the number of insert, update, delete operations by cluster.

PostgreSQL - Query Execution Dashboard

The PostgreSQL Query Execution dashboard gives you insights into the number and time taken to execute queries:

Use this dashboard to: 

  • Monitor query performance and identify slow queries.
  • Examine query execution trends.

PostgreSQL - Database Metrics Dashboard

The PostgreSQL - Database Metrics dashboard allows you to monitor the database performance, which includes disk usage, deadlocks, buffer hits, server processes, commits, rollbacks, and scans.

Use this dashboard to:

  • Understand the behavior and performance of your database clusters.  
  • Monitor database size and disk usage.  
  • Identify top 5 and least 5 frequently scanned indexes.

clipboard_eb58b4bb028181f834559cd1b6bf8cda8.png

PostgreSQL - Relation and Schema Metrics Dashboard

The PostgreSQL - Relation and Schema Metrics dashboard allows you to view and analyze the metrics for monitoring the relations and schema in a cluster.

Use this dashboard to:

  • Monitor PostgreSQL relation and schema metrics trends over time.
  • Monitor sequential scans and index scans and determine if executed queries are accessing them.
  • Monitor the size of tables, and query operations which will determine the performance of your queries.

clipboard_ef2babfd97071c147eb5f5d14a99225e3.png

PostgreSQL - Security Dashboard

The PostgreSQL - Security dashboard provides insight into locations of incoming connections, failed authentications and top database errors and warnings. 

Use this dashboard to:

  • Monitor incoming connections, failed authorization requests, and outliers in the number of queries executed outlier.
  • Identify known malicious IPs that are accessing your databases and use firewall access control lists to prevent them from sending you traffic going forward.

PostgreSQL - Error Logs Dashboard

The PostgreSQL - Error Logs dashboard provides insight into database error  logs by specifically monitoring errors, user activity, database activity and database shutdown/start events.

Use this dashboard to:

  • Quickly identify errors and patterns in logs for troubleshooting
  • Monitor error trends and quickly identify outliers
  • Identify unexpected database or user activity

PostgreSQL - Slow Queries Dashboard

The PostgreSQL - Slow Queries dashboard provides insights into all slow queries executed on the database.

Use this dashboard to:

  • Identify all slow queries
  • Monitor users and databases running slow queries
  • Determine which SQL commands are slower than others
  • Examine slow query trends to determine if there are periodic performance bottlenecks in your database clusters