使用 ARM 模板格式的 Kusto 查询创建仪表板

如何解决使用 ARM 模板格式的 Kusto 查询创建仪表板

希望你们一切都好。 我正在研究针对 Azure Kubernetes 集群运行的 Kusto 查询。它工作正常,但当我尝试将其合并到 ARM 模板中以创建仪表板时,它会向我抛出与“预期标记‘RightParenthesis’和实际‘标识符’”相关的错误。

在日志分析工作区中运行查询如下:

let clusterName = 'AKS';
Perf
| where TimeGenerated > ago(2m)
| where ObjectName == "K8SNode" 
| where CounterName == "cpuAllocatableNanoCores" 
| where InstanceName contains clusterName
| summarize arg_max(TimeGenerated,*) by Computer
| summarize TotalCores=sum(CounterValue),x="join"
| join kind = inner (
    KubePodInventory
    | where TimeGenerated > ago(2m)
    | where ClusterName contains clusterName
    | summarize arg_max(TimeGenerated,*) by ContainerName
    | project Name,ContainerName,Namespace
    | join kind = inner (
        Perf
        | where TimeGenerated > ago(2m)
        | where ObjectName == 'K8SContainer'
        | where CounterName == 'cpuUsageNanoCores'
        | where InstanceName contains clusterName
        | extend ContainerNameParts = split(InstanceName,'/')
        | extend ContainerNamePartCount = array_length(ContainerNameParts)            
        | extend PodUIDIndex = ContainerNamePartCount - 2,ContainerNameIndex = ContainerNamePartCount - 1 
        | extend ContainerName = strcat(ContainerNameParts[PodUIDIndex],'/',ContainerNameParts[ContainerNameIndex])
        | summarize arg_max(TimeGenerated,*) by ContainerName
        | project ContainerName,CounterValue
        )
        on ContainerName
    | project Name,Namespace,CounterValue
    | summarize CoresPerNamespace=sum(CounterValue) by Namespace,x="join"
    )
    on x
| project UtcTime=now(),CpuUtilizationPerNamespace=(CoresPerNamespace / TotalCores) * 100

============================

后来我尝试将其与 ARM 模板合并,但它引发了错误。

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion": "1.0.0.0","parameters": {
    "dashboardName": {
      "defaultValue": "AKS-Temp-Dashboard","type": "String","metadata": {
        "description": "DASHBOARD name for Azure kubernetes service cluster"
      }
    },"resourceGroupName": {
      "defaultValue": "aks-rg","metadata": {
        "description": "Azure resourceGroup name for Azure kubernetes service cluster"
      }
    },"aksClusterName": {
      "defaultValue": "aks","metadata": {
        "description": "Azure kubernetes service cluster name"
      }
    }
  },"variables": {
    "dashboardName": "[concat(parameters('dashboardName'),'-DASHBOARD')]","aksResourceId": "[resourceId(parameters('resourceGroupName'),'Microsoft.ContainerService/managedClusters',parameters('aksClusterName'))]"
  },"resources": [
    {
      "properties": {
        "lenses": {
          "0": {
            "order": 0,"parts": {
                "1": {
                "position": {
                  "x": 0,"y": 3,"colSpan": 5,"rowSpan": 3
                },"metadata": {
                  "inputs": [
                    {
                      "name": "resourceTypeMode","isOptional": true
                    },{
                      "name": "ComponentId",{
                      "name": "Scope","value": {
                        "resourceIds": [
                          "/subscriptions/7777t-a1ae-4ca9-89bc-gfgf7577575/resourcegroups/rg-eus/providers/microsoft.operationalinsights/workspaces/aks""
                        ]
                      },{
                      "name": "PartId","value": "4ae7fd78-1a4f-4025-a091-7d57e08d6822",{
                      "name": "Version","value": "2.0",{
                      "name": "TimeRange",{
                      "name": "DashboardId",{
                      "name": "DraftRequestParameters",{
                      "name": "Query","value": "[concat('let clustername = \"',parameters('aksClusterName'),'\"; Perf\n| where TimeGenerated > ago(2m)\n| where ObjectName == \"K8SNode\" \n| where CounterName == \"cpuAllocatableNanoCores\" \n| where InstanceName contains clusterName\n| summarize arg_max(TimeGenerated,*) by Computer\n| summarize TotalCores=sum(CounterValue),x=\"join\"\n| join kind = inner (\n    KubePodInventory\n    | where TimeGenerated > ago(2m)\n    | where ClusterName contains clusterName\n    | summarize arg_max(TimeGenerated,*) by ContainerName\n    | project Name,Namespace\n    | join kind = inner (\n        Perf\n        | where TimeGenerated > ago(2m)\n        | where ObjectName == 'K8SContainer'\n        | where CounterName == 'cpuUsageNanoCores'\n        | where InstanceName contains clusterName\n        | extend ContainerNameParts = split(InstanceName,'/')\n        | extend ContainerNamePartCount = array_length(ContainerNameParts)            \n        | extend PodUIDIndex = ContainerNamePartCount - 2,ContainerNameIndex = ContainerNamePartCount - 1 \n        | extend ContainerName = strcat(ContainerNameParts[PodUIDIndex],ContainerNameParts[ContainerNameIndex])\n        | summarize arg_max(TimeGenerated,*) by ContainerName\n        | project ContainerName,CounterValue\n        )\n        on ContainerName\n    | project Name,CounterValue\n    | summarize CoresPerNamespace=sum(CounterValue) by Namespace,x=\"join\"\n    )\n    on x\n| project UtcTime=now(),CpuUtilizationPerNamespace=(CoresPerNamespace / TotalCores) * 100\n\n ')]",{
                      "name": "ControlType","value": "FrameControlChart",{
                      "name": "SpecificChart","value": "StackedColumn",{
                      "name": "PartTitle","value": "Analytics",{
                      "name": "PartSubTitle","value": "gaks-la1",{
                      "name": "Dimensions","value": {
                        "xAxis": {
                          "name": "UtcTime","type": "datetime"
                        },"yAxis": [
                          {
                            "name": "CpuUtilizationPerNamespace","type": "real"
                          }
                        ],"splitBy": [
                          {
                            "name": "Namespace","type": "string"
                          }
                        ],"aggregation": "Sum"
                      },{
                      "name": "LegendOptions","value": {
                        "isEnabled": true,"position": "Bottom"
                      },{
                      "name": "IsQueryContainTimeRange","value": true,"isOptional": true
                    }
                  ],"type": "Extension/Microsoft_OperationsManagementSuite_Workspace/PartType/LogsDashboardPart","settings": {}
                }
              }
            }
          }
        },"metadata": {
          "model": {}
        }
      },"name": "[variables('dashboardName')]","type": "Microsoft.Portal/dashboards","location": "[resourceGroup().location]","tags": {
        "hidden-title": "AKS-Monitoring-Dashboard"
      },"apiVersion": "2015-08-01-preview"
    }
  ]
}

请帮助我解决这个问题。 注意:对我来说,它看起来 concat() 函数产生了一个问题。

在下面找到错误截图:

Blocking didn't work

注意:似乎没有正确设置 Concat() 函数。

*****在苦苦挣扎后添加更新运行查询,以便最终用户可以得到帮助*****

 "[concat('let clustername = \"','\"; Perf \r\n| where TimeGenerated > ago(2m) \r\n| where ObjectName == \"K8SNode\" \r\n| where CounterName == \"cpuAllocatableNanoCores\" \r\n| where InstanceName contains clustername \r\n| summarize arg_max(TimeGenerated,*) by Computer \r\n| summarize TotalCores=sum(CounterValue),x=''join'' \r\n| join kind = inner (\r\n    KubePodInventory \r\n    | where TimeGenerated > ago(2m) \r\n    | where ClusterName contains clustername \r\n    | summarize arg_max(TimeGenerated,*) by ContainerName \r\n    | project Name,Namespace \r\n    | join kind = inner (\r\n        Perf \r\n        | where TimeGenerated > ago(2m) \r\n        | where ObjectName == ''K8SContainer'' \r\n        | where CounterName == ''cpuUsageNanoCores'' \r\n        | where InstanceName contains clustername \r\n        | extend ContainerNameParts = split(InstanceName,''/'') \r\n        | extend ContainerNamePartCount = array_length(ContainerNameParts)            \r\n        | extend PodUIDIndex = ContainerNamePartCount - 2 \r\n| extend ContainerNameIndex = ContainerNamePartCount - 1 \r\n        | extend ContainerName = strcat(ContainerNameParts[PodUIDIndex],''/'',ContainerNameParts[ContainerNameIndex]) \r\n        | summarize arg_max(TimeGenerated,*) by ContainerName\r\n        | project ContainerName,CounterValue\r\n        )\r\n        on ContainerName\r\n    | project Name,CounterValue\r\n    | summarize CoresPerNamespace=sum(CounterValue) by Namespace,x=''join''\r\n    )\r\n    on x \r\n| project UtcTime=now(),CpuUtilizationPerNamespace=(CoresPerNamespace / TotalCores) * 100')]"

解决方法

在您的 KQL 查询中,您有没有转义的撇号(例如 productRepository.getProductByCode(code: qrText) .sink(receiveCompletion: { completion in switch completion { case .failure(.error): print("ERROR on retrieving products") case .failure(.empty): print("EMPTY products") default: print("ALRIGHT") } },receiveValue: { value in print("Returned value: \(value)") updateLabel(value: value) // <- Function won't be called until this block fires and we have the `value` }) func updateLabel(value: String) { self.label.text = value } )。 ARM 将它们视为字符串的和,并需要逗号和 concat 函数的另一个参数,因此会出现错误。 AFAIR 你用另一个撇号转义:where CounterName == 'cpuUsageNanoCores'\n

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-