gpt4 book ai didi

具有多个动态标记筛选器的 Azure 资源管理器查询

转载 作者:行者123 更新时间:2023-12-02 08:17:16 25 4
gpt4 key购买 nike

我正在尝试查询 Azure 成本管理 API,并且希望能够根据 2 种不同类型的资源标签来筛选结果,但我无法确定格式。我可以让单个标签过滤器正常工作,但我对多个标签的格式空白。有人可以捐出 2 美分吗?

工作单个过滤器查询:

{
"type": "Usage",
"timeframe": "{TimeFrame}",
"dataset": {
"granularity": "None",
"filter": {
"tags": {
"name": "Environment",
"operator": "In",
"values": [
{Environment}
]
}
},
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "{Aggregation}"
}
]
}
}

我尝试添加多个过滤器:

{
"type": "Usage",
"timeframe": "{TimeFrame}",
"dataset": {
"granularity": "None",
"filter": {
"tags": [
{
"name": "Environment",
"operator": "In",
"values": [
{Environment}
]
},
{
"name": "Location",
"operator": "In",
"values": [
{Location}
]
}
]
},
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "{Aggregation}"
}
]
}
}

我对 Azure 很陌生,所以请不要太严厉地 mock 我,哈哈。

感谢所有看过我的问题的人,即使您没有给我答案,我也非常感激。

最佳答案

我的参数设置方式存在问题,导致查询错误。以下是具有用于过滤的多个标签属性的工作代码:

{
"type": "Usage",
"timeframe": "{TimeFrame}",
"dataset": {
"granularity": "None",
"filter": {
"and": [
{
"tags": {
"name": "Location",
"operator": "In",
"values": [{LocationTag}]
}
},
{
"tags": {
"name": "Environment",
"operator": "In",
"Values": [{EnvironmentTag}]
}
},
{
"tags": {
"name": "Integrated-System",
"operator": "In",
"Values": [{IntegratedSystemTag}]
}
}
]
},
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "{Aggregation}"
}
]
}

}

关于具有多个动态标记筛选器的 Azure 资源管理器查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72492809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com