关于通过API/PowerShell访问Cloudyn并集成Datadog的技术咨询
Great questions—let's break this down clearly for you, since Cloudyn's full integration into Azure Cost Management + Billing changes some of the tools you'll rely on.
Accessing Cloudyn Data via PowerShell
Absolutely, but you'll want to use Azure's native PowerShell modules rather than standalone Cloudyn tools (since Cloudyn is now part of Azure Cost Management):
- The
Az.CostManagementmodule gives you direct access to the same cost and utilization data that was shown in the Cloudyn dashboard. You'll need the appropriate permissions (like Cost Management Reader or Contributor) on your Azure subscription first. - Here's a sample script to pull monthly Azure storage cost data, mirroring what you'd see in Cloudyn:
# Connect to your Azure account (use Connect-AzAccount -TenantId <tenant-id> if needed) Connect-AzAccount # Define your subscription scope and time period (last 3 months, monthly granularity) $subscriptionScope = "/subscriptions/your-subscription-id-here" $startDate = (Get-Date).AddMonths(-3).ToString("yyyy-MM-dd") $endDate = (Get-Date).ToString("yyyy-MM-dd") # Fetch aggregated monthly storage cost data Get-AzCostManagementQuery -Scope $subscriptionScope ` -TimePeriod (New-Object Microsoft.Azure.Commands.CostManagement.Models.PSQueryTimePeriod -ArgumentList $startDate, $endDate) ` -Dataset (New-Object Microsoft.Azure.Commands.CostManagement.Models.PSQueryDataset -Property @{ Granularity = "Monthly" Aggregation = @{ TotalCost = @{ Name = "Cost"; Function = "Sum" } } Filter = @{ Dimensions = @{ Name = "ResourceType"; Operator = "In"; Values = @("Microsoft.Storage/storageAccounts") } } }) - This script returns summed monthly costs for all your storage accounts, which you can further filter or export as needed.
Cloudyn API for Datadog Integration
Yes, but again, the Azure Cost Management REST API is the recommended replacement for the legacy Cloudyn API (which is deprecated but still functional for now):
- For integrating with Datadog, you have two solid approaches:
- Custom Datadog Check: Write a script (Python, shell, etc.) that authenticates with Azure, calls the Cost Management API to fetch storage cost/utilization data, then sends that data to Datadog using their API or
dogstatsd. Schedule this script to run periodically (e.g., monthly) via cron, Azure Functions, or Datadog's own scheduled tasks. - Azure Logic Apps: Build a no-code workflow that triggers on a schedule, pulls data from the Cost Management API, transforms it to match Datadog's metric format, and pushes it directly to Datadog's endpoint. This is great if you don't want to maintain custom code.
- Custom Datadog Check: Write a script (Python, shell, etc.) that authenticates with Azure, calls the Cost Management API to fetch storage cost/utilization data, then sends that data to Datadog using their API or
- If you must use the legacy Cloudyn API, you can authenticate with your Cloudyn credentials and use endpoints like
/api/v1/reports/costto pull structured data. Just note that Microsoft will eventually retire this API, so migrating to Azure's native API is better for long-term support. - When sending data to Datadog, include tags like
subscription-id,storage-account-name, andresource-groupto make your metrics more actionable in Datadog's dashboard.
内容的提问来源于stack exchange,提问作者Manjunath Rao




