DataSunrise Achieves AWS DevOps Competency Status in AWS DevSecOps and Monitoring, Logging, Performance

Database Audit in YugabyteDB

Database Audit in YugabyteDB

Introduction

In today’s digital landscape, implementing robust database audit trails is crucial for maintaining security and compliance in database operations. Moreover, YugabyteDB, a distributed SQL database, offers built-in capabilities for tracking database activities. At the same time, it supports enhanced monitoring through third-party solutions.

Native Audit Capabilities in YugabyteDB

YugabyteDB utilizes the PostgreSQL Audit Extension (pgaudit) to provide comprehensive audit logging. This integration, therefore, enables detailed session and object audit logging through YB-TServer logging, which is essential for meeting various compliance requirements.

Setting Up Native Audit Logging

To enable audit logging in YugabyteDB, administrators can configure several approaches. Below are the key steps for setup:

  1. Cluster Startup Configuration – You can configure audit logging using YB-TServer flags. For example:

    --ysql_pg_conf_csv="pgaudit.log='all, -misc',pgaudit.log_parameter=on,pgaudit.log_relation=on"
  2. Enable pgaudit Extension – In your YSQL session, you can create the extension with the following command:

    CREATE EXTENSION IF NOT EXISTS pgaudit;
  3. Configure Audit Logging Parameters – Set specific audit logging options. For instance:

    -- Enable DDL logging
    SET pgaudit.log = 'DDL';
    
    -- Log parameters with statements
    SET pgaudit.log_parameter = ON;
    
    -- Enable client-side logging
    SET pgaudit.log_client = ON;
    SET pgaudit.log_level = notice;

Sample Native Audit Log Output Examples

Once pgaudit is configured and active, YugabyteDB logs key activities to the YB-TServer logs. These logs can then be parsed or viewed using monitoring tools. Below are two sample output table examples that demonstrate typical audit log entries:

Example 1: General Activity Log

This table captures a variety of operations (SELECT, INSERT, UPDATE, DELETE) across different sessions.

Log TimeUserDatabaseSession IDCommandObject TypeObject NameDetails
2025-02-11 10:15:23adminyugadb8a1b2c3dSELECTtablecustomer_dataExecuted SELECT on table customer_data
2025-02-11 10:17:45adminyugadb8a1b2c3dINSERTtableordersInserted a new order record
2025-02-11 10:20:11analystyugadbd4e5f6g7UPDATEtableordersUpdated order status to ‘shipped’
2025-02-11 10:22:05analystyugadbd4e5f6g7DELETEtableobsolete_dataDeleted record with id 123

Example 2: Detailed DDL and Write Operations Log

This output is focused on Data Definition Language (DDL) and data-modification operations, including extra parameters and relation details as configured with pgaudit. Here are some sample entries:

Log TimeUserDatabaseSession IDCommandObject TypeObject NameQuery Parameters
2025-02-11 11:05:10dbayugadbf7g8h9i0CREATEtablesensitive_dataCREATE TABLE sensitive_data ( … )
2025-02-11 11:06:50dbayugadbf7g8h9i0ALTERtablesensitive_dataALTER TABLE sensitive_data ADD COLUMN …
2025-02-11 11:10:32app_useryugadbj1k2l3m4INSERTtablesensitive_dataINSERT INTO sensitive_data (username, email, …)
2025-02-11 11:15:44app_useryugadbj1k2l3m4UPDATEtablesensitive_dataUPDATE sensitive_data SET email = ‘…’ WHERE …

Advanced Auditing with Detailed Examples

Comprehensive Audit Rule Example

-- Create a sample table to audit
CREATE TABLE sensitive_data (
    user_id SERIAL PRIMARY KEY,
    username TEXT,
    email TEXT,
    credit_card_last4 TEXT
);

-- Configure extensive auditing
SET pgaudit.log = 'all';
SET pgaudit.log_parameter = ON;
SET pgaudit.log_relation = ON;

-- Perform some sample operations
INSERT INTO sensitive_data (username, email, credit_card_last4) 
VALUES ('johndoe', 'john@example.com', '1234');

UPDATE sensitive_data 
SET email = 'john.doe@newexample.com' 
WHERE username = 'johndoe';

Enhanced Auditing with DataSunrise

While native capabilities provide basic auditing, DataSunrise’s database activity monitoring solution offers advanced features specifically designed for distributed databases like YugabyteDB. Thus, it provides a more comprehensive solution.

DataSunrise proxy managing multiple database connections

Key Features:

DataSunrise Session Trails hub allows you to manage ongoing connections to YugabyteDB

Best Practices for YugabyteDB Auditing

  1. Performance Optimization – In order to optimize performance, it is crucial to implement selective audit rules. For instance:
    • Use targeted logging configurations
    • Monitor the system’s performance impact
    -- Example of selective logging
    SET pgaudit.log = 'DDL, WRITE';  -- Only log DDL and write operations
    SET pgaudit.log_catalog = OFF;   -- Reduce noise from system catalog logs
  2. Security Considerations – Additionally, it is important to protect audit logs, implement granular access controls, and regularly review and rotate logs. These measures are essential for maintaining the security of your audit data.

Conclusion

In conclusion, effective database auditing in YugabyteDB requires a balanced approach between native capabilities and enhanced solutions. While native pgaudit provides essential logging features, organizations with complex compliance requirements may greatly benefit from the advanced monitoring and security features offered by specialized solutions like DataSunrise.

For more information about implementing comprehensive database auditing in YugabyteDB, consult the YugabyteDB security documentation.

If you want to learn more about comprehensive database audit in YugabyteDB with DataSunrise, we highly recommend scheduling our online demo or downloading the tool to explore it yourself.

Next

Data Audit for Hydra

Learn More

Need Our Support Team Help?

Our experts will be glad to answer your questions.

Countryx
United States
United Kingdom
France
Germany
Australia
Afghanistan
Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belgium
Belize
Benin
Bermuda
Bhutan
Bolivia
Bosnia and Herzegovina
Botswana
Bouvet
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Canada
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Congo, Republic of the
Congo, The Democratic Republic of the
Cook Islands
Costa Rica
Cote D'Ivoire
Croatia
Cuba
Cyprus
Czech Republic
Denmark
Djibouti
Dominica
Dominican Republic
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard Island and Mcdonald Islands
Holy See (Vatican City State)
Honduras
Hong Kong
Hungary
Iceland
India
Indonesia
Iran, Islamic Republic Of
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Japan
Jersey
Jordan
Kazakhstan
Kenya
Kiribati
Korea, Democratic People's Republic of
Korea, Republic of
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Libyan Arab Jamahiriya
Liechtenstein
Lithuania
Luxembourg
Macao
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States of
Moldova, Republic of
Monaco
Mongolia
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
North Macedonia, Republic of
Northern Mariana Islands
Norway
Oman
Pakistan
Palau
Palestinian Territory, Occupied
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Saint Helena
Saint Kitts and Nevis
Saint Lucia
Saint Pierre and Miquelon
Saint Vincent and the Grenadines
Samoa
San Marino
Sao Tome and Principe
Saudi Arabia
Senegal
Serbia and Montenegro
Seychelles
Sierra Leone
Singapore
Slovakia
Slovenia
Solomon Islands
Somalia
South Africa
South Georgia and the South Sandwich Islands
Spain
Sri Lanka
Sudan
Suriname
Svalbard and Jan Mayen
Swaziland
Sweden
Switzerland
Syrian Arab Republic
Taiwan, Province of China
Tajikistan
Tanzania, United Republic of
Thailand
Timor-Leste
Togo
Tokelau
Tonga
Trinidad and Tobago
Tunisia
Turkey
Turkmenistan
Turks and Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Venezuela
Viet Nam
Virgin Islands, British
Virgin Islands, U.S.
Wallis and Futuna
Western Sahara
Yemen
Zambia
Zimbabwe
Choose a topicx
General Information
Sales
Customer Service and Technical Support
Partnership and Alliance Inquiries
General information:
info@datasunrise.com
Customer Service and Technical Support:
support.datasunrise.com
Partnership and Alliance Inquiries:
partner@datasunrise.com