【问题标题】:Log Analyics adding Customer dimensions possible via powershell?Log Analytics 是否可以通过 powershell 添加自定义维度?
【发布时间】:2022-09-28 20:29:29
【问题描述】:

您好我正在尝试添加自定义维度或类似的属性。下面我添加了一个打印屏幕,所以在网上找到了类似的东西

这是我用来尝试创建它的代码

$JSON = @{
    Type             = \'SQL\'
    Subscriptionname = \"123\"
    property         = @{
        SQLServerName       = \"myServer\";
        DatabaseName        = \"myDatabase\";
 
    }
}

$json2 = $JSON | ConvertTo-Json
# $json2

# Submit the data to the API endpoint
Post-LogAnalyticsData -customerId $customerId -sharedKey $sharedKey -body ([System.Text.Encoding]::UTF8.GetBytes($json2)) -logType \"MyRecordTypetoo\"

但结果如下

任何人有任何想法让这个工作?

    标签: json azure powershell azure-log-analytics


    【解决方案1】:

    请按照以下方法解决问题:

    方式一

    #Import the AzurePowerShell Utility Function file from above github repo
    
    Import-Module AzurePowerShellUtilityFunctions.psd1
    
    #  Adding custom properties using Event Telemetry
    
    Send-AppInsightsEventTelemetry -InstrumentationKey '<Instrumentation Key of AI>' -EventName <Event Name> -CustomProperties @{ '<Custom Property>' = '<Property Value>'}
    

    方式二

    为了在应用程序洞察中添加自定义维度,我们有PSModule 在应用程序洞察中添加属性。详细步骤请参考here

    方式3

    • 使用REST API我希望你已经尝试过。通过调用休息 API与上述 PowerShell 模块中提到的相同。

    结果

    【讨论】:

      猜你喜欢
      • 2021-03-03
      • 1970-01-01
      • 2019-11-10
      • 1970-01-01
      • 1970-01-01
      • 2018-08-08
      • 1970-01-01
      • 2022-11-07
      相关资源
      最近更新 更多