CUD expiry alert

Hi Team , 
I need to send alerts about expiry of CUD(Committed Use Discounts) at before 30 days via email. There is no API available to fetch both resource-based and spend-based cud's . How will i get both cud data associated for billing account?

0 1 105
1 REPLY 1

Yes, Google Cloud does not offer an API to access comprehensive details on both resource-based and spend-based Committed Use Discounts (CUDs). Resource-based CUDs are accessible via the Compute Engine API, whereas spend-based CUDs are managed within the Cloud Billing system. However, you can still achieve your goal of sending alerts about the expiry of CUDs 30 days in advance by using a combination of Google Cloud services and a bit of creativity. Here's a general approach you can take:

  1. Leveraging Combined Data Analysis:

    • Cloud Billing and BigQuery: By exporting Cloud Billing data to BigQuery, you can perform detailed analyses. Craft SQL queries to identify discount applications, including start dates and associated billing labels, which may hint at the presence of spend-based CUDs. However, pinpointing their exact expiration might necessitate additional logic.
    • Compute Engine API for Resource-based CUDs: Access detailed information on resource-based CUDs, including their expiration dates, through the Compute Engine API.
    • Data Correlation with Heuristics: Employ heuristics or specific business logic to correlate spend-based and resource-based CUD data. This might involve analyzing discount start dates, amounts, typical CUD terms, and usage patterns, alongside meticulously applied billing labels to accurately match CUDs.
  2. Automation and Alerting Mechanism:

    • Script Development: Create a script in Python (or another suitable language) that orchestrates API calls, conducts BigQuery analysis, correlates data, and generates alerts for CUDs nearing expiration within the next 30 days.
    • Email Alerts: Integrate your script with an email service (such as SendGrid, Mailgun, or Gmail) to dispatch proactive alerts regarding upcoming CUD expirations.
    • Regular Monitoring: Set up Cloud Scheduler to periodically run your script, ensuring consistent monitoring of CUD expirations.

Additional Enhancements:

  • CUD Utilization Insights: Augment your script to also assess how effectively you're utilizing the resources under your CUDs, aiding in cost optimization and informed renewal decisions.
  • Visualization for Better Oversight: Consider creating a dashboard using Google Data Studio (or a similar tool) to visualize expiring CUDs and track historical utilization trends, facilitating easier management oversight.
  • Consistent Use of Billing Labels: Advocate for the consistent application of billing labels, especially for resource-based CUDs, to improve the accuracy of your BigQuery analyses.
  • Exploring Third-Party Tools: Look into third-party cloud cost management platforms that may offer more streamlined CUD management features and insightful optimization recommendations.