OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

GCS connector: `total_bytes` container metric always reports 0 (DOUBLE/INT64 value type mismatch in _fetch_metric)

Open kalecgoss opened this issue 3 months ago • 0 comments

Affected module

Connector

Describe the bug

The GCS storage connector's total_bytes container metric is always 0, even for buckets with confirmed non-zero data in Cloud Monitoring.

Root cause: _fetch_metric() in metadata/ingestion/source/storage/gcs/metadata.py reads the value from the Cloud Monitoring Point the same way for both metrics it queries:

point = list(timeseries)[-1].points[-1]
return point.value.int64_value

storage.googleapis.com/storage/object_count is valueType: INT64, so this works. storage.googleapis.com/storage/total_bytes is valueType: DOUBLE (confirmed via the metricDescriptors API, see below), so point.value.int64_value reads the wrong oneof field. In protobuf this does not raise — it silently returns the type's zero-default. The except Exception / "Failed fetching metric ... returning 0" branch never fires, because no exception happens. The result: total_bytes is always 0 for every bucket, silently, with no warning or error anywhere in the logs.

object_count is unaffected and reports correctly.

To Reproduce

  1. Query the metric descriptors directly (no ingestion needed to see the root cause):
    GET https://monitoring.googleapis.com/v3/projects/{project}/metricDescriptors/storage.googleapis.com/storage/total_bytes
    → "valueType": "DOUBLE"
    
    GET https://monitoring.googleapis.com/v3/projects/{project}/metricDescriptors/storage.googleapis.com/storage/object_count
    → "valueType": "INT64"
    
  2. Confirm (e.g. via Metrics Explorer, filtering on a specific bucket_name) that total_bytes actually has recent non-zero data points for a real bucket.
  3. Run metadata ingest against a GCS service connection that includes that bucket.
  4. Open the resulting Container entity in OpenMetadata — numberOfObjects is correct, size is 0 Bytes.

Connection / ingestion config

source:
  type: gcs
  serviceName: your-service-name
  serviceConnection:
    config:
      type: GCS
      credentials:
        gcpConfig:
          type: gcp_credential_path
          path: /path/to/key.json
          projectId: your-project-id
  sourceConfig:
    config:
      type: StorageMetadata

sink:
  type: metadata-rest
  config: {}

workflowConfig:
  loggerLevel: INFO
  openMetadataServerConfig:
    hostPort: "https://your-openmetadata-host/api"
    authProvider: openmetadata
    securityConfig:
      jwtToken: "<redacted>"
    storeServiceConnection: true

Logs

No error or warning is logged for the affected buckets — that's the point of the bug. For comparison, this is what a genuine metric-fetch failure looks like (this only happened before the service account had roles/monitoring.viewer; once that permission was granted, these warnings disappeared but total_bytes stayed 0 anyway):

[INFO] Running GetMetrics...
[INFO] Test connection results: ... TestConnectionStepResult(name='GetMetrics', mandatory=False, passed=True, ...)
[INFO] Looking for metadata template file at - gs://your-bucket/openmetadata.json
[WARNING] No metadata file found at gs://your-bucket/openmetadata.json

— i.e. after the permission fix, GetMetrics test step passes, object_count populates correctly, and there is nothing in the logs at all pointing at total_bytes being wrong. It's only visible by comparing the entity's size field against the real Cloud Monitoring value.

Expected behavior

size on the Container entity should reflect the real total_bytes value from Cloud Monitoring (in our repro, a multi-TiB bucket), not 0.

OS

macOS 26 (Darwin 25.5.0)

Python version

3.12

OpenMetadata version

1.13.3

OpenMetadata Ingestion package version

openmetadata-ingestion==1.13.4

Additional context

Suggested fix direction: _fetch_metric should pick the value field based on the metric's actual value type instead of hardcoding int64_value — e.g. via point.value.WhichOneof("value"), or by reading the value type once from the MetricDescriptor and branching accordingly. Since object_count (INT64) and total_bytes (DOUBLE) are fetched through the same helper, the fix should keep both paths working rather than hardcoding either field.

Pre-submission checklist

  • [x] I searched for duplicate issues.
  • [x] I removed credentials, hostnames, emails, and other sensitive data from logs and config.

kalecgoss avatar Sep 02 '26 05:09 kalecgoss