【问题标题】:Programatically Get ADF pipeline consumption report以编程方式获取 ADF 管道消耗报告
【发布时间】:2021-09-07 20:18:50
【问题描述】:

我有兴趣查询可从数据工厂监视器获得的管道消耗报告。 Log Analytics 或 PowerShell cmdlet 上是否有可以返回此信息的表?我检查了 ADFv2 PowerShell 模块,但没有找到。我的目标是汇总此报告中的可用信息,以确定成本最高的管道。

参考:https://techcommunity.microsoft.com/t5/azure-data-factory/new-adf-pipeline-consumption-report/ba-p/1394671

谢谢

【问题讨论】:

    标签: azure azure-data-factory cost-management


    【解决方案1】:

    在进行更多研究时,有人将我指向一个 GitHub 页面,产品团队在该页面上发布了一个 PowerShell 脚本来查找我正在寻找的部分内容{1}。所以我对脚本做了一些修改以获得我需要的输出。通过下面的输出,我可以从 MS 计算器中提取值,以获得每个管道运行的估计成本。 {2}

    $startTime = "21/6/2021 7:00:00"
    $endTime = "21/6/2021 10:00:00"
    $adf = '<data factory name>'
    $rg = '<resrouce group name>'
        
    
    $outputObj = @()
    $pipelineRuns = Get-AzDataFactoryV2PipelineRun -ResourceGroupName $rg -DataFactoryName $adf -LastUpdatedAfter $startTime -LastUpdatedBefore $endTime
    
    # loop through all pipelines and child activities to return billable information
    foreach ($pipelineRun in $pipelineRuns) {
        $activtiyRuns = Get-AzDataFactoryV2ActivityRun -ResourceGroupName $rg -DataFactoryName $adf -pipelineRunId $pipelineRun.RunId -RunStartedAfter $startTime -RunStartedBefore $endTime
    
        foreach ($activtiyRun in $activtiyRuns) {
            if ($null -ne $activtiyRun.Output -and $null -ne $activtiyRun.Output.SelectToken("billingReference.billableDuration")) {            
                
                $obj = @()
                $obj = $activtiyRun.Output.SelectToken("billingReference.billableDuration").ToString() | ConvertFrom-Json
                $obj | Add-Member -MemberType NoteProperty -Name activityType -value $activtiyRun.Output.SelectToken("billingReference.activityType").ToString()
                $obj | Add-Member -MemberType NoteProperty -Name pipelineName -value $pipelineRun.PipelineName
                $obj | Add-Member -MemberType NoteProperty -Name activtiyRuns -value $activtiyRuns.Count             
    
                $outputObj += $obj
            }
            else {}
        }
    }
    
    # output aggregated result set as table
    $groupedObj = $outputObj | Group-Object -Property pipelineName, activityType, meterType
    $groupedObj | ForEach-Object {
        $value = $_.name -split ', '
        New-Object psobject -Property @{ 
                                   
            activityType              = $value[1];
            meterType                 = $value[2];
            pipelineName              = $value[0];
            executionHours            = [math]::Round(($_.Group | Measure-object -Property duration -sum).Sum, 4)
            orchestrationActivityRuns = $groupedObj.group.activtiyRuns[0]
        } 
    } | Sort-Object -Property meterType | Format-Table
    

    输出样本:

    来自数据工厂监视器的消耗报告

    参考:

    1. https://github.com/Azure/Azure-DataFactory/tree/main/SamplesV2/PastRunDetails#simple-script-that-prints--activity-level-run-details-in-45-day-range{1}
    2. https://azure.microsoft.com/en-us/pricing/calculator/?service=data-factory%2F{2}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 2012-03-31
      • 2013-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多