The CC Performance Adapter is a WordPress plugin that collects database health metrics and pushes them to Google BigQuery for monitoring and analysis.
WordPress (Metrics Collection) -> BigQuery <- Looker Studio
If you're setting up this plugin locally for development, follow these quick steps:
- XAMPP / Local WordPress (or any local WordPress installation)
- Git (for cloning the repository)
- PHP 7.4+ (usually included with XAMPP)
- A Google Cloud project (for testing BigQuery integration)
cd wp-content/plugins/
git clone https://github.com/ColoredCow/performance-adapter-wp.git
cd performance-adapter-wp- Copy the template configuration (if available) or create your own
- Download your Google Cloud service account key (see Step 1 in the full setup below)
- Place the JSON key file in your WordPress root directory (same level as
wp-config.php) - Update
includes/class-bigquery-client.phpwith your GCP Project ID and credentials
- Go to WordPress Admin Dashboard
- Navigate to Plugins
- Find "CC Performance Adapter" and click Activate
- Go to Tools → Costwatch
- Click "Collect & Push Now" to manually trigger data collection
- Check BigQuery to verify data is being received
- Debug Mode: Enable WP_DEBUG in
wp-config.phpto see detailed logs:define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false);
- Check Logs: View
wp-content/debug.logfor any errors - WP-CLI Testing: Run
wp cc-perf collectto manually trigger collection - Verify Cron: Ensure
DISABLE_WP_CRONis set tofalseinwp-config.php
Before setting up this plugin on another machine, ensure you have:
- WordPress Installation (v5.0+)
- PHP (v7.4+)
- cURL enabled (for API requests)
- Google Cloud Project with:
- BigQuery API enabled
- Service Account with BigQuery Editor permissions
- Service Account JSON key file
- Go to Google Cloud Console
- Create a new project (e.g., "WordPress Performance")
- Note your Project ID
- In Cloud Console, search for "BigQuery API"
- Click "Enable" to activate it
- Go to "IAM & Admin" → "Service Accounts"
- Click "Create Service Account"
- Fill in details:
- Service Account Name:
wordpress-adapter - Description: WordPress Performance Metrics
- Service Account Name:
- Click "Create and Continue"
- Grant the role: "BigQuery Editor"
- Click "Continue" then "Done"
- Click on the created service account
- Go to "Keys" tab
- Click "Add Key" → "Create new key"
- Select JSON format
- Click "Create"
- Save this file securely - you'll need it for Step 3
- Go to BigQuery console
- Click "Create Dataset"
- Dataset ID:
proactive_perf - Keep other defaults, click "Create dataset"
- Select the
proactive_perfdataset - Click "Create Table"
- Table name:
performance_metrics - Schema: Copy and paste the following JSON schema when creating the table:
[
{
"name": "timestamp_utc",
"type": "TIMESTAMP",
"mode": "NULLABLE"
},
{
"name": "autoloaded_option_count",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "autoloaded_option_size",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "site_url",
"type": "STRING",
"mode": "NULLABLE"
}
]- Copy the code from the same repo to your local machine.
- Rename your downloaded JSON key file to match the pattern for BigQuery.
REPLACE 'YOUR_SERVICE_ACCOUNT_KEY.json' with the actual file name ***
- Example:
wordpress-adapter-1a2b3c4d5e6f.json
- Example:
- Place it in the WordPress root directory (same level as
wp-config.php) - Important: Add this filename to
.gitignore
Edit wp-content/plugins/properf/includes/class-bigquery-client.php:
Find the __construct() method and update:
private $project_id = 'YOUR_PROJECT_ID'; // Replace with your actual GCP Project ID
private $dataset_id = 'proactive_perf'; // Keep unless you renamed it
private $table_id = 'performance_metrics'; // Keep unless you renamed itAnd update the credentials array:
$this->credentials = array(
'type' => 'service_account',
'project_id' => 'YOUR_PROJECT_ID',
'private_key_id' => 'YOUR_PRIVATE_KEY_ID',
'private_key' => "YOUR_PRIVATE_KEY",
'client_email' => 'YOUR_SERVICE_ACCOUNT_EMAIL',
'client_id' => 'YOUR_CLIENT_ID',
'auth_uri' => 'https://accounts.google.com/o/oauth2/auth',
'token_uri' => 'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs',
);Get these values from your downloaded JSON key file.
- Go to WordPress Admin → Plugins
- Find "CC Performance Adapter"
- Click "Activate"
- The plugin will automatically schedule daily metric collection at midnight (00:00:00) in your site's timezone
- Go to Tools → Costwatch
- Click "Collect & Push Now" button
- You should see: "Data collected and pushed to BigQuery!"
wp cc-perf collect- Go to BigQuery Console
- Query your table:
SELECT * FROM `YOUR_PROJECT_ID.proactive_perf.performance_metrics`
LIMIT 10;You should see your WordPress metrics!
- Default Time: Midnight (00:00:00) in site's timezone
- Frequency: Daily
- Location: Managed by WordPress cron
To change the collection time, edit properf_get_next_midnight() in properf-wordpress-adapter.php:
$today_midnight = new DateTime('00:00:00', $target_tz); // Change 00:00:00 to your desired time- Autoloaded Options Count: Number of database options set to autoload
- Autoloaded Options Size: Total bytes of autoloaded data
- Top 5 Options: The 5 largest autoloaded options by size
- Timestamp: UTC timestamp of collection
Solutions:
- Verify service account email has BigQuery Editor permissions
- Check that the
private_keyin credentials is correctly formatted (includes newlines) - Ensure token_uri is correct:
https://oauth2.googleapis.com/token
Solutions:
- Verify
project_id,dataset_id, andtable_idare correct - Ensure the table schema matches the data being inserted
- Check that BigQuery API is enabled in your GCP project
Solutions:
- Ensure WordPress cron is enabled (check
define('DISABLE_WP_CRON', false);in wp-config.php) - Click "Collect & Push Now" manually to test functionality
- Check WordPress error logs:
wp-content/debug.log
Solutions:
- Ensure the private key string includes proper newline characters:
\n - The key should start with
-----BEGIN PRIVATE KEY-----and end with-----END PRIVATE KEY-----
wp-content/plugins/properf/
├── properf-wordpress-adapter.php # Main plugin file
├── includes/
│ ├── class-data-collector.php # Collects metrics from WordPress
│ └── class-bigquery-client.php # Handles BigQuery API communication
└── README.md # This file
Once data is flowing to BigQuery, you can visualize it in LookerStudio:
- Go to LookerStudio
- Click "Create" → "Report"
- Search for BigQuery connector
- Select your project and table
- Create visualizations from your performance metrics
✅ Automatic Daily Collection - Runs at scheduled time
✅ Manual Collection - "Collect & Push Now" button in Tools menu
✅ Admin Dashboard - View current metrics in WordPress admin
✅ WP-CLI Support - wp cc-perf collect command
✅ Error Logging - All errors logged to WordPress error log
✅ Token Caching - Optimized BigQuery API token management
- Never commit service account keys to version control
- Add service account filename to
.gitignore - Use environment variables for sensitive data in production
- Restrict BigQuery API to specific tables/datasets at the IAM level
For issues or questions:
- Check WordPress error log:
wp-content/debug.log - Enable WordPress debug in
wp-config.php:define('WP_DEBUG', true); define('WP_DEBUG_LOG', true);
- Check BigQuery logs for API errors
- Current Version: 1.0.0
- Requires: WordPress 5.0+, PHP 7.4+
- License: GPL v2 or later =======
A WordPress plugin that collects important WordPress metrics and sends them to a data warehouse.
Performance Adapter for WordPress is designed to gather key performance and operational metrics from WordPress sites and transmit them to a centralized data warehouse. This plugin is part of the ColoredCow Proactive Performance tool ecosystem.
ColoredCow
- Upload the plugin files to the
/wp-content/plugins/performance-adapter-wpdirectory - Activate the plugin through the 'Plugins' menu in WordPress
- WordPress 5.0 or higher
- PHP 7.4 or higher