Skip to content

feat(logestimator): introduce EstimatedCountPreset for rough query log estimation - #926

Merged
kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ymutqkvrusnz
Aug 31, 2026
Merged

kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ymutqkvrusnz

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

Introduces EstimatedCountPreset (including EstimatedCountPreset.Few) to support predefined rough query volume estimation categories across backend task execution, API definitions, and frontend inspection parameter dialogs, and applies it to Compute API Audit and Serial Port log queries.

Background & Motivation

In KHI dry-run mode, query volume is estimated using Cloud Monitoring metrics and time-bounded probe queries. However, queries such as Compute API Audit logs and Serial Port output match sparse or sporadic events where exact count estimation is either unfeasible prior to node discovery or unnecessary. Tagging such queries with EstimatedCountPresetFew avoids unnecessary probe calls and clearly informs the user in the UI that few logs are expected.

Key Changes

  • Protobuf API (proto/api/v1/inspection.proto):
    • Adds enum EstimatedCountPreset (UNSPECIFIED = 0, FEW = 1).
    • Adds estimated_count_preset field to InspectionQuery.
    • Regenerates Go and TypeScript Connect-RPC bindings.
  • Log Estimator (pkg/api/googlecloud/logestimator/):
    • Adds EstimatedCountPreset enum to types.go.
    • Updates StructuredLogEstimator and CachedStructuredLogEstimator to short-circuit estimation and return preset results immediately without remote network calls.
  • Query Metadata & Inspection Tasks (pkg/core/inspection/metadata/, pkg/task/...):
    • Adds SetQueryWithPreset to QueryMetadata.
    • Updates googlecloudlogcomputeapiaudit to tag dry-run query with EstimatedCountPresetFew.
    • Updates googlecloudlogserialport to tag dry-run query with EstimatedCountPresetFew.
    • Updates structured_listlogentries_task.go and pkg/server/api/v1/inspection.go to propagate preset to API responses.
  • Frontend Dialog UI (web/src/app/):
    • Updates inspection-converter.ts to map proto presets to metadata-types.ts.
    • Updates new-inspection.component.html to display "Few logs estimated" badge.
    • Updates computeTotalEstimatedLogs in new-inspection.component.ts to treat preset queries as resolved.
  • Tests:
    • Adds unit tests for query metadata, estimator, cached estimator, API converter, compute API task, serial port task, and Angular dialog logic.

Verification

  • make pre-commit passed with 0 errors.
  • make build-go && make test-go passed cleanly.
  • make test-web (1053 tests) passed cleanly.
  • make lint-go && make lint-web passed with 0 issues.
  • make lint-proto 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 predefined rough estimation tier, "EstimatedCountPreset" (specifically "Few"), to bypass exact log count estimation when it is unfeasible. The changes span the backend estimators, proto definitions, and the Angular frontend to correctly propagate and display this preset (e.g., showing "Few logs estimated"). A review comment points out that the frontend check for unestimated queries is fragile because it explicitly checks against "EstimatedCountPreset.Few", which will break if more presets are added in the future; it suggests checking for undefined or unspecified presets instead.

@kyasbal kyasbal added area:backend-core Core backend frameworks, DAG task runner, and server API area:frontend Web frontend application and UI components labels Aug 31, 2026
@kyasbal
kyasbal merged commit 979772a into GoogleCloudPlatform:main Aug 31, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-ymutqkvrusnz branch August 31, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API area:frontend Web frontend application and UI components

1 participant