Skip to content

feat(inspection): structured log query estimation and inspection log volume UI redesign - #895

Merged
kyasbal merged 6 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-tktmkkzp
Aug 24, 2026
Merged

kyasbal merged 6 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-tktmkkzp

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 24, 2026

Copy link
Copy Markdown
Member

Summary

This PR implements structured log query estimation for Google Cloud Logging queries, introduces caching & metric-based volume estimation, migrates all 14 Google Cloud query tasks to StructuredLogQuery, and improves the New Inspection dialog UI to display live log count estimates and progress indicators.

Key Changes

  1. Structured Log Query Estimator (pkg/api/googlecloud/logestimator):

    • Implemented StructuredLogQuery with structured matchers (ResourceLabel, LogID, CustomFilter, Comment).
    • Mapped structured query filters directly to Cloud Monitoring log entry metrics (logging.googleapis.com/log_entry_count) with fallback to probe sampling.
    • Built CachedStructuredLogEstimator with singleflight request deduplication, LRU caching, and cancellation of outdated in-flight queries.
  2. Inspection Framework Extensions (pkg/core/inspection/metadata, pkg/task/inspection/googlecloudcommon/contract):

    • Added StructuredListLogEntriesTask capable of generating structured queries and estimating log volumes during dry-run mode.
    • Added Incomplete and EstimatedCount metadata fields to InspectionMetadataQuery.
    • Added IsComplete() method to GoogleCloudClusterIdentity to skip estimation when required parameters are missing.
  3. Query Task Migrations (pkg/task/inspection/googlecloud*):

    • Migrated all 14 Google Cloud query tasks to StructuredLogQuery (k8scontainer, k8sevent, k8snode, k8scontrolplane, k8saudit, gkeautoscaler, gkeapiaudit, computeapiaudit, networkapiaudit, onpremapiaudit, multicloudapiaudit, composerapiaudit, clustercomposer, csm, csm traffic director, serialport).
    • Added comprehensive table-driven tests verifying query generation equivalence, filter order, and metric compatibility.
  4. Frontend UI Redesign (web/src/app/dialogs/new-inspection):

    • Added a dedicated total estimated logs callout banner under the Query section with spinner and color-coded severity (normal, warning for >= 1M, danger for >= 5M).
    • Moved estimated log counts to individual query card subtitles with loading spinners.
    • Refined status text (~N total logs estimated, >N logs estimated so far, Incomplete parameters).

Verification

  • make test-go: All backend tests passed.
  • make test-web: All 736 frontend tests passed.
  • make pre-commit: All formatters and linters passed with 0 issues.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a log volume estimation feature for Google Cloud Logging and Monitoring queries, refactoring various log query tasks to use a new structured query model and integrating these estimates into the frontend's 'New Inspection' dialog. The review feedback highlights several critical improvements: adding defensive nil checks in QueryMetricCount to prevent nil pointer dereferences, ensuring all active flights are cancelled in CachedStructuredLogEstimator.Close() to avoid goroutine leaks, and dynamically setting isEstimating in the frontend when some queries are incomplete but others are still estimating.

@kyasbal
kyasbal merged commit 0e9bab0 into GoogleCloudPlatform:main Aug 24, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-tktmkkzp branch August 24, 2026 03:15
@kyasbal kyasbal added the type:feature New feature or request label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New feature or request

1 participant