Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

GCP Filestore Instance Capacity Exhaustion Watchdog

Audits GCP Filestore NFS instances via Cloud Monitoring to detect disk capacity exhaustion, delivering proactive scaling alerts to SREs via Slack.

Categories
CloudInfrastructure

Enterprise software architectures and high-performance computing workloads hosted on Google Cloud rely on Google Cloud Filestore for fully managed, multi-writer Network Attached Storage (NFSv3). Filestore instances power persistent volume claims (PVCs) across Google Kubernetes Engine (GKE) clusters, shared application media directories, and analytics scratch spaces. However, when shared volumes fill up due to log explosion, temporary model checkpoint dumps, or uncompressed database exports, the NFS file server refuses new write operations with No space left on device (ENOSPC) errors. When stateful Kubernetes pods encounter a full NFS volume, write threads block indefinitely, causing health checks to fail and pods to enter crash loops. This watchdog queries Google Cloud Monitoring hourly for the nfs/server/used_bytes_percent metric, detects when disk usage crosses 85%, and notifies DevOps on Slack with exact gcloud filestore instances update expansion commands before production outages occur.

How it works

  1. Scheduled triggering: Executes hourly via automated cron trigger (0 * * * *) or runs on-demand via manual execution.
  2. Metric query construction: Builds a Google Cloud Monitoring query filtering for file.googleapis.com/nfs/server/used_bytes_percent on the target instance.
  3. Capacity telemetry retrieval: Evaluates time series data points across a 15-minute rolling window to capture true current disk consumption.
  4. Threshold comparison: Verifies whether the used disk percentage exceeds max_disk_usage_percent_threshold.
  5. Conditional alerting: An io.kestra.plugin.core.flow.If flowable checks if capacity limits are breached and dispatches a Slack incident card.
  6. Manifest export: Logs operational telemetry and returns a structured JSON manifest detailing disk metrics and expansion runbooks.

Architecture diagram

flowchart TD
  A[hourly_filestore_capacity_audit Schedule Trigger] --> B[scan_filestore_capacity Python Script]
  B --> C[check_capacity_exhaustion Flowable If]
  C -- Capacity Limit Breached --> D[notify_slack_storage_exhaustion Webhook]
  C -- Storage Nominal --> E[log_storage_health_state Log]
  D --> E
  E --> F[export_filestore_manifest Return]

What you get

  • Proactive visibility into shared NFS volume capacity before file system write lockouts.
  • Automated detection of rapid disk growth on shared GKE Persistent Volumes.
  • Contextual Slack alerts containing exact disk utilization percentages and gcloud expansion commands.
  • Structured JSON manifests supporting multi-cluster storage capacity auditing.

Who it's for

  • Cloud Infrastructure Engineers managing shared Filestore NFS backends on Google Cloud.
  • Site Reliability Engineers safeguarding GKE clusters against stateful volume lockups.
  • DevOps Teams operating shared storage for CI/CD runners, CMS uploads, and model weights.

Why orchestrate this with Kestra

While Google Cloud Monitoring provides alerting policies, integrating storage utilization into unified multi-cloud operations and ChatOps workflows requires flexible orchestration. Kestra queries GCP Monitoring APIs securely, evaluates custom capacity thresholds, formats actionable incident cards, and can trigger automated storage expansion. With Kestra's containerized Python runner and native secret management, teams manage cloud storage reliability without deploying brittle custom daemons.

Use cases

  • GKE Persistent Volume Fullness Warning: Detect when shared NFS volumes used by container pods approach full capacity before write failures crash workloads.
  • Machine Learning Checkpoint Scratch Space Guard: Monitor shared Filestore volumes used for model weights and training datasets to prevent out-of-space training run aborts.
  • Multi-Tenant Shared Storage Governance: Ensure that shared corporate storage volumes maintain sufficient buffer headroom across business hours.

Inputs

Name Type Default Description
gcp_project_id STRING company-prod-infrastructure Google Cloud project identifier where the Filestore instance is provisioned.
filestore_instance_id STRING shared-nfs-filestore-01 Unique identifier of the target GCP Filestore instance to audit.
max_disk_usage_percent_threshold FLOAT 85.0 Maximum allowable disk space utilization percentage before triggering capacity warnings.
alert_on_exhaustion BOOL true Whether to dispatch automated Slack incident notifications when Filestore disk capacity exceeds safety limits.

Expected outputs

  • {{ outputs.scan_filestore_capacity.vars.instance_id }}: Identifier of the evaluated Filestore instance.
  • {{ outputs.scan_filestore_capacity.vars.used_percent }}: Current disk space utilization percentage.
  • {{ outputs.scan_filestore_capacity.vars.is_exhausted }}: Boolean flag indicating whether the disk utilization breached safety limits.
  • {{ outputs.export_filestore_manifest.value }}: Structured dictionary containing the consolidated Filestore diagnostic manifest.

Prerequisites

  • Outbound HTTPS network access from Kestra execution workers to Google Cloud Monitoring APIs.
  • A GCP Service Account JSON key configured with roles/monitoring.viewer permissions.
  • A Slack Incoming Webhook URL configured in Kestra secrets.

Secrets

  • GCP_SERVICE_ACCOUNT_KEY: Service account credentials JSON with permissions to query Cloud Monitoring metrics.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used to dispatch storage capacity alerts.

Quick start

  1. Register GCP_SERVICE_ACCOUNT_KEY and SLACK_WEBHOOK_URL in your Kestra secret storage.
  2. Import this blueprint into your Kestra instance under the company.cloud namespace.
  3. Update gcp_project_id and filestore_instance_id with your GCP project and instance names.
  4. Run a manual execution to test Cloud Monitoring connectivity and confirm diagnostic output format.

Common pitfalls and troubleshooting

  • Metric Ingestion Delay: Cloud Monitoring metrics for Filestore have a 3 to 5 minute ingestion latency; querying a 15-minute window ensures valid data points.
  • Service Account Permissions: Ensure the service account has monitoring.timeSeries.list permission on the project; missing permissions cause 403 Forbidden errors.
  • Filestore Tier Minimum Sizes: Basic HDD Filestore minimum size is 1 TiB; expansion commands must specify valid increments allowed by the instance tier.

How to extend

  • Automated Filestore Expansion: Add a downstream task using gcloud filestore instances update to dynamically increase storage capacity when disk usage hits 90%.
  • GKE StatefulSet Pod Eviction Safeguard: Trigger a drainage flow to evict non-critical workloads when storage capacity drops below 5%.
  • Multi-Instance Fleet Audit: Wrap the evaluation in an io.kestra.plugin.core.flow.Loop task to scan all Filestore instances across multiple Google Cloud projects.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.