我是 Azure 新手,对 Azure 中的自定义指标功能有一些疑问。我的应用程序正在向 Azure Application Insights 发送自定义指标信号。如果我转到 Azure 中的日志,我可以清楚地看到信号以及以 customDimentions 形式表示的内容。此信号由 Azure 警报捕获,该警报将有效负载发送到指定的 Webhook。问题是我找不到将 customDImentions 对象添加到警报有效负载中。我知道警报有自定义属性,但这些属性是静态的。
有人知道解决方案或解决方法吗?
从我的应用程序发送信号后,我可以在警报中获取一些信息,例如信号名称和值,但不是其属性
cbiebcfo
TelemetryClient
设置自定义属性。确保将 "CustomProperty1"
和 "CustomProperty2"
替换为您实际的自定义维度名称import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.telemetry.MetricTelemetry;
public class MyApp {
private static TelemetryClient telemetry = new TelemetryClient();
public static void main(String[] args) {
// Your custom telemetry object
MyTelemetryObject customTelemetry = new MyTelemetryObject();
// Track custom metric
telemetry.trackMetric(new MetricTelemetry("MetricName", customTelemetry.getValue()));
// Add custom dimensions
telemetry.getContext().getProperties().put("CustomProperty1", customTelemetry.getCustomProperty1());
telemetry.getContext().getProperties().put("CustomProperty2", customTelemetry.getCustomProperty2());
// Flush telemetry data
telemetry.flush();
}
}
customDimensions.CustomProperty1 == "Value1" and customDimensions.CustomProperty2 == "Value2"
我们需要检查 Log Analytics 查询是否在结果集中包含必要的自定义维度。