Skip to content

Collect GCP logs and query them instantly with SQL! Open source CLI. No DB required.

License

Notifications You must be signed in to change notification settings

turbot/tailpipe-plugin-gcp

GCP Plugin for Tailpipe

Tailpipe is an open-source CLI tool that allows you to collect logs and query them with SQL.

GCP provides on-demand cloud computing platforms and APIs to authenticated customers on a metered pay-as-you-go basis.

The GCP Plugin for Tailpipe allows you to collect and query GCP logs using SQL to track activity, monitor trends, detect anomalies, and more!

Collect and query logs: image

Getting Started

Install Tailpipe from the downloads page:

# MacOS
brew install turbot/tap/tailpipe
# Linux or Windows (WSL)
sudo /bin/sh -c "$(curl -fsSL https://tailpipe.io/install/tailpipe.sh)"

Install the plugin:

tailpipe plugin install gcp

Configure your connection credentials, table partition, and data source (examples):

vi ~/.tailpipe/config/gcp.tpc
connection "gcp" "my_project" {
  project = "my-project"
}

partition "gcp_audit_log" "my_logs" {
  source "gcp_storage_bucket" {
    connection = connection.gcp.my_project
    bucket     = "gcp-audit-logs-bucket"
  }
}

Download, enrich, and save logs from your source (examples):

tailpipe collect gcp_audit_log

Enter interactive query mode:

tailpipe query

Run a query:

select
  service_name as event_source,
  method_name as event_name,
  count(*) as event_count
from
  gcp_audit_log
group by
  service_name,
  method_name
order by
  event_count desc;
+-------------------------+-------------------------------------------------------+-------------+
| event_source            | event_name                                            | event_count |
+-------------------------+-------------------------------------------------------+-------------+
| storage.googleapis.com  | storage.objects.get                                   | 104349      |
| logging.googleapis.com  | google.logging.v2.LoggingServiceV2.ListLogEntries     | 28193       |
| compute.googleapis.com  | v1.compute.instanceGroupManagers.listManagedInstances | 27236       |
| storage.googleapis.com  | storage.objects.create                                | 11817       |
| cloudkms.googleapis.com | Decrypt                                               | 4171        |
+-------------------------+-------------------------------------------------------+-------------+

Detections as Code with Powerpipe

Pre-built dashboards and detections for the GCP plugin are available in Powerpipe mods, helping you monitor and analyze activity across your GCP accounts.

For example, the GCP Audit Log Detections mod scans your CloudTrail logs for anomalies, such as an Storage bucket being made public or a change in your Compute network infrastructure.

Dashboards and detections are open source, allowing easy customization and collaboration.

To get started, choose a mod from the Powerpipe Hub.

image

Developing

Prerequisites:

Clone:

git clone https://github.com/turbot/tailpipe-plugin-gcp.git
cd tailpipe-plugin-gcp

After making your local changes, build the plugin, which automatically installs the new version to your ~/.tailpipe/plugins directory:

make

Re-collect your data:

tailpipe collect gcp_audit_log

Try it!

tailpipe query
> .inspect gcp_audit_log

Open Source & Contributing

This repository is published under the Apache 2.0 (source code) and CC BY-NC-ND (docs) licenses. Please see our code of conduct. We look forward to collaborating with you!

Tailpipe is a product produced from this open source software, exclusively by Turbot HQ, Inc. It is distributed under our commercial terms. Others are allowed to make their own distribution of the software, but cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our Open Source FAQ.

Get Involved

Join #tailpipe on Slack →

Want to help but don't know where to start? Pick up one of the help wanted issues: