Skip to content

Add resource activity report script for bulk CSV export#980

Draft
rajlearner17 wants to merge 8 commits into
mainfrom
feature/snapshot-activity-report
Draft

Add resource activity report script for bulk CSV export#980
rajlearner17 wants to merge 8 commits into
mainfrom
feature/snapshot-activity-report

Conversation

@rajlearner17

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Python script to export resource create/delete/update activity from Guardrails workspaces to CSV via GraphQL API
  • Supports multiple workspaces in a single run (--profile is repeatable), configurable resource types (--resource-type), and configurable time ranges (--days)
  • Auto-detects the Turbot automation identity per workspace
  • Handles large notification datasets that cause the console Resource Activities report to time out (avoids the slow actorIdentityId + timestamp combined filter by fetching all resource CRUD and filtering dates client-side)

Use case

Customers with large workspaces (millions of notifications) cannot use the console's "Export to CSV" on the Resource Activities report — it times out. This script provides a reliable alternative that completes in under a minute.

Files

  • guardrails_utilities/python_utils/notifications/get-resource-activity-report/resource_activity_report.py — Main script
  • guardrails_utilities/python_utils/notifications/get-resource-activity-report/README.md — Full documentation with usage examples
  • guardrails_utilities/python_utils/notifications/get-resource-activity-report/requirements.txt — Dependencies (requests, PyYAML)

Test plan

  • Tested against production workspace with 12.8M notifications — completes in ~30s
  • Verified CSV output matches console Resource Activities report format
  • Multi-workspace --profile flag works
  • Auto-detection of Turbot Identity actor ID works
  • Pagination handles >500 results correctly
  • Timeout retry logic works (retry once after 10s on timeout)
  • Test with --resource-type for non-snapshot resources (S3 buckets, EC2 instances)

🤖 Generated with Claude Code

Python script to export resource create/delete/update activity from
Guardrails workspaces via GraphQL API. Supports multiple workspaces,
configurable resource types, and auto-detection of the Turbot automation
identity. Designed for cases where the console Resource Activities report
times out on large notification datasets.
@rajlearner17 rajlearner17 force-pushed the feature/snapshot-activity-report branch from b8a31fc to 3e3545d Compare May 1, 2026 16:22
@rajlearner17 rajlearner17 marked this pull request as draft May 1, 2026 16:39
rajlearner17 and others added 3 commits May 1, 2026 22:18
Large workspaces with millions of notifications can take over 180s on
the first query. Bumps timeout to 300s and retries up to 3 times with
progressive backoff (15s, 30s, 45s).
…aries

Add fetch_resource_deletions.py that uses `turbot graphql` CLI for reliable
paginated fetches of resource deletion notifications. Defaults to all resource
types when a time boundary is set, supports --date for midnight-to-midnight
UTC boundaries (no overlap between days), resource type aliases, and a safety
guard against unbounded queries. Includes reference GraphQL queries captured
from the Guardrails console and updated README with comprehensive examples.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace Koch workspace names, URLs, actor identity IDs, real resource
IDs, and paging cursors with generic placeholders throughout the script,
README, and GraphQL reference files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rajlearner17 and others added 4 commits May 8, 2026 15:20
…tivity page

Remove graphql-diff/ directory containing console query samples with
workspace-specific variables. Fix Detail URL in CSV output to link to
the resource activity page (/apollo/resources/{id}/activity) instead
of the notification page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ials

Auto-detect Turbot Identity ID via GraphQL query when --auto-detect-actor
is passed. Auto-read workspace URL from credentials.yml so --workspace-url
is no longer needed. Updated README case study and examples to use the
simplified workflow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…README

Separate workspace URL extraction from auth token construction in
resource_activity_report.py to prevent CodeQL from tracing secrets
through to print statements. Delete secret variables after use.
Add resource type URI lookup command to README aliases section.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rrors

Auto-detect now uses exit_on_error=False so transient CLI failures don't
kill the script — it falls back to fetching by all actors. Error messages
now include stdout when stderr is empty for better debugging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rajlearner17 rajlearner17 requested a review from vkumbha May 8, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants