Home Knowledge Base WP Activity Log WP Activity Log plugin & activity log database documentation

WP Activity Log plugin & activity log database documentation

WP Activity Log stores activity data in its own tables within the WordPress database by default.
Upgrade to the Enterprise edition to store logs in an external database, send them to a SIEM, or archive them externally for long-term retention.

This knowledge base entry explains how the activity log data is stored in the database.

WP Activity Log database tables structure & documentation

WP Activity Log creates six tables in the WordPress database. It uses these tables to store the activity log and the pluginโ€™s settings. This KB article lists each table and its structure.

Note: The wp_ prefix is the default WordPress database prefix. If you have changed yours, the pluginโ€™s table will use your configured prefix.

Table: wp_wsal_custom_notifications

The plugin saves definitions for Custom Notifications in this table, including who to notify, which channels, notification triggers, and message templates. This table has the following columns:

Column nameTypeDescription
idintA unique ID for the notification
notification_user_idintThe WordPress user ID of the notification creator/owner
notification_usernamevarcharThe WordPress username of the notification creator/owner
notification_settingsjsonSpecifies whether to send
notification_titlevarcharHuman-readable notification title
notification_emailvarchar/textA comma-separated list of email recipients
notification_email_bccvarchar/textA comma-separated list of BCC email recipients
notification_email_usertinyint(1)A boolean-like value specifiying whether to email the affected WordPress user
notification_phonevarchar/text
notification_templatejsonThe subject and body template of the email notification (with placeholder support)
notification_sms_templatejsonThe SMS notification template (with placeholder support)
notification_slackvarchar/textThe Slack webhook URL or channel identifier destination
notification_slack_templatejsonThe Slack message template (with placeholder support)
notification_queryjsonThe notification query triggers used to trigger the notification
notification_query_sqltextThe SQL equivalent of the notification query triggers
notification_statustinyint(1)Details whether the notification is enabled (1) or disabled (0)
notification_view_statetinyint(1)The view state of the notification in the UI
created_onintThe UNIX epoch of when the notification was created

Table: wp_wsal_generated_reports

The plugin stores generated reports metadata in this table, including who created the report, filters used, output format, and processing state, among other data. This table has the following columns:

Column nameTypeDescription
idintA unique ID for the report
generated_report_user_idintThe WordPress user ID of the user who requested the report
generated_report_usernamevarcharThe WordPress username of the user who requested the report
generated_report_filtersjsonThe report filters (date range, users, alert IDs, etc)
generated_report_filters_normalizedjsonNormalized/flattened subset of report filters
generated_report_header_columnsjsonHuman-readable report headers
generated_report_where_clausetextSQL WHERE clause string precompiled from the filters
generated_report_finishedtinyint(1)Report status – 0 while generating, 1 when finished
generated_report_to_datefloat/decimalUTC epoch in seconds marking the โ€œtoโ€ boundary of the report period
generated_report_namevarcharInternal name of the report
generated_report_filevarcharFilename of the generated artifact (such as CSV or HTML)
generated_report_tagvarcharOptional tag label
generated_report_formattinyint/smallintOutput format code (such as CSV or HTML)
generated_report_number_of_recordsintReport row count
created_onintThe UNIX epoch of when the notification was created

Table: wp_wsal_metadata

Table structure

The plugin saves the metadata of each event in this table. Metadata includes data such as post titles, post URLs, order status, SKUs, etc. This table has the following columns:

Column nameTypeDescription
idbigintA unique ID that is assigned to every row in the table
occurrence_idbigintThe ID that correlates the metadata in this table to the alert ID stored in the wp_wsal_occurrences table
namevarcharThe name of the row that describes the data stored in that row
valuelongtextThe actual metadata value, such as post title, URL, etc

You can view event metadata through the Event data inspector by clicking on the More detailsโ€ฆ button in the Log Viewer. Learn more about WordPress activity log data and metadata.

Table: wp_wsal_occurrences

The plugin saves the event data in this table. Each row represents a single activity log event that occurred on the WordPress website, as seen in the Log Viewer. This table has the following columns:

Column nameTypeDescription
idbigintA unique ID is assigned to every row in the table
site_idbigintThe ID of the website in a WordPress multisite network (in non-multisite environments, this is set to 1)
alert_idbigintThe ID of the event in the activity log
created_ondoubleThe date and time in Unix time of when the change happened
client_ipvarcharThe IP address of the entity actioning the activity
severityvarcharThe severity measures the potential impact of the recorded activity
objectvarcharThe object of the activity
event_typevarcharThe type of activity that took place
user_agentvarcharThe browser user agent
user_rolesvarcharThe role of the user actioning the activity
usernamevarcharThe WordPress username of the user that actioned the activity
user_idbigintThe ID of the WordPress user
session_idvarcharThe ID of the session during which the activity took place
post_statusvarcharIf the activity concerns a post, the post status (published, draft, future, pending, etc) is recorded here
post_typevarcharThe type of post (such as post, custom post type, or page)
post_idbigintThe unique WordPress ID of that post

Table: wp_wsal_periodic_reports

The plugin stores periodic reports metadata in this table, including who created the report, filters used, and processing state, among other data. This table has the following columns:

Column nameTypeDescription
idintA unique ID for the periodic report
report_user_idintThe WordPress user ID of the user who created the report
report_usernamevarcharThe denormalized WordPress username of the user who created the report
report_namevarcharHuman-readable report name
report_frequencytinyint/smallintInternal code representing report frequency
report_formattinyint/smallintInternal code representing export format
report_emailvarchar/textA comma-separated list of email recipients
report_datajsonReport’s filters
report_tagvarcharOptional tag label
report_disabledtinyint(1)Details whether the report is enabled (1) or disabled (0)
last_sentintThe UNIX epoch of when the report was last sent (0 means never sent)
created_onintThe UNIX epoch of when the report was created

Table: wp_wsal_sessions

The plugin saves users’ session data in this table. Whenever someone logs in to the WordPress website, the plugin keeps a record of this login. When the user logs out, that session data is deleted from the table. As such, in this table, you can see who is logged in to your website at any point in time. The plugin uses this data for the WordPress usersโ€™ session management features, such termination of idle WordPress usersโ€™ sessions. This table has the following columns:

[table โ€œxlโ€ not found /]

Examples of how WordPress activity log data is stored in the database

The wp_wsal_occurences table holds the data that we can see in the Log Viewer. The default view does not show all data. However, you can click the More detailsโ€ฆ button to view all information pertaining to a single event (including metadata as discussed in the previous section). 

examples of how wordpress activity log data is stored in the database

In the next sections, we will look at a couple of examples to showcase actual WordPress activity data as it is stored in the wp_wsal_occurences table.

User login

In this example, we can see an administrator with the username โ€˜joelโ€™ logging in from a local machine. The alert ID is 1000, which can be cross-referenced with the list of activity log event IDs. The created_on shows us a Unix timestamp of 1690899814.031139, which tells us that the event happened on Tuesday, the 1st of August 2023, at 4:23:34.031 PM.

user login

Plugin installation

In the example below, we see the same user (he likes to keep himself busy) installing a plugin. We know this because the alert ID is listed as 5000.

plugin installation

We can cross-reference this with wp_wsal_metadata table by looking for entries where the occurrence_id field in wp_wsal_metadata matches the id in wp_wsal_occurrences. This tells us that the user installed the CAPTCHA 4WP plugin.

captcha 4wp plugin

Using the activity log viewer

Use the log viewer to see all the events in the WordPress activity log. When you open the viewer, the plugin retrieves the metadata and event IDs from the WordPress database and uses this data to show the events, as shown in the below screenshot.

using activity log viewer

To keep database access to a minimum, the plugin only retrieves the data it needs for that view.

Integrating the activity logs with your central logging system

WP Activity Log plugin has out-of-the-box support for mirroring the activity log to Log Management Services such as AWS, CloudWatch, and Loggly. However, if you use a service that we do not support, you can easily integrate the WordPress activity log with your logs management system of choice using the information provided in this document. All you need to do is allow access to the database where the logs are and configure MySQL connectors to read the data.

Alternatively, you can mirror the WordPress website activity log to a log file and configure your logs management system to read directly from the log file.

Close the CTA
Were you able to find what you were looking for?