以编程方式获取 ADF 管道消耗报告

问题描述

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

enter image description here

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

谢谢

解决方法

从 Azure 市场 Azure Data Factory Analytics (Preview)结帐

Azure 数据工厂分析(预览版)将诊断日志发送到特定于资源的目标表。您可以针对以下表编写查询:ADFPipelineRun、ADFTriggerRun 和 ADFActivityRun。此解决方案为您提供数据工厂整体健康状况的摘要,以及用于深入了解细节和排除意外行为模式故障的选项。 借助丰富的开箱即用视图,您可以深入了解关键处理,包括:

  • 数据工厂管道、活动和触发器概览 运行
  • 能够深入了解按类型运行的数据工厂活动
  • 数据工厂顶级管道、活动错误摘要

先决条件:要利用此解决方案,数据工厂应启用日志分析以将诊断数据推送到 OMS 工作区。

Azure 文档说“管道运行消耗视图显示特定管道运行的每个 ADF 仪表消耗的数量,但不显示实际收取的价格”。我们需要通过定价计算器手动计算成本。

在您的 Log Analytics 工作区中尝试使用 KQL

Usage
| join ADFPipelineRun on $left.DataType == $right.Type
| where IsBillable == true
| summarize TotalVolumeGB = sum(Quantity)by PipelineName
| render barchart 

Total Data consumed

By Activity Count

Pipeline run counts aggrigated

您可以尝试使用不同的图表或聚合或拆分来满足您的需要。使用 BI 共享、导出、固定到仪表板和监控

enter image description here

使用 Usage Details API 获取所有 Azure 第一方资源的费用和使用情况数据。信息采用使用详细记录的形式,目前每米每个资源每天发出一次。信息可用于汇总所有资源的成本或调查特定资源的成本/使用情况。

示例 Usage Details API requestsPipelineRunFrequently Asked Questions

查询管道在工厂中根据输入过滤条件运行。

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/queryPipelineRuns?api-version=2018-06-01

enter image description here

并比较输出以分析管道运行的持续时间,进而分析其估计成本。

"pipelineName": "pipeline1","runStart": "2021-06-17T13:16:00.1423227Z","runEnd": "2021-06-17T13:16:07.5701497Z","durationInMs": 7427,"pipelineName": "pipeline2","runStart": "2021-06-17T14:11:46.3663925Z","runEnd": "2021-06-17T14:11:54.0281037Z","durationInMs": 7661,

我也看到几个月前有一个类似的问题。

如前所述,目前唯一的方法是手动查看消费明细并检查 Azure 定价计算器。

您也可以添加类似这样的反馈:(毕竟这个管道消耗报告也是由于反馈provide better billing statistics

,

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

import React,{ Component } from 'react';
import { StaticQuery,graphql } from 'gatsby';

class Layout extends Component {
  render() {
    return (
      <StaticQuery
        query={graphql`
          query SiteTitleQuery {
            site {
              siteMetadata {
                title
              }
            }
          }
        `}
        render={data => {
          return (
            <main>
              {!data && <p>Loading...</p>}
              {data && data.site.siteMetadata.title}
            </main>
          )
        }}
      />
    );
  }
}

输出示例:

enter image description here

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

enter image description here

参考:

  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}