我正在尝试使用REST API来检索AppInsights自定义指标,并在查询中使用过滤器。
创建指标的代码:
JDBC
运行此代码时,指标在Azure中创建。
现在,我想使用REST API来检索指标并在查询中使用过滤器。当我使用过滤器
Connection conn;
try{
conn = DriverManager.getConnection(CONN_STRING,USERNAME,PASSWORD);
PreparedStatement pstmt=conn.prepareStatement("SELECT * FROM airplane.airlinedb WHERE
ORIGIN = ? AND DESTINATION = ? LIMIT 100;");
pstmt.setString(1,j.from); // from is the string variable
pstmt.setString(2,j.destination); //destination is another string variable
ResultSet rs=pstmt.executeQuery();
User user;
while(rs.next())
{
user = new User(rs.getString("ORIGIN"),
rs.getString("DESTINATION"),rs.getInt("FLIGHT_NUMBER"), rs.getInt("TIME_TRAVEL") ,
rs.getInt("PRICE"));
usersList.add(user);
}
conn.close();
}
catch(SQLException e){
System.err.println(e);
}
return usersList;
}
查询以错误结束
以下维度在该指标的过滤条件子句中无效:类别
查询网址为:
var telemetry = new MetricTelemetry();
telemetry.Context.InstrumentationKey = instrumentationKey;
telemetry.Name = FacebookFupMetricName;
telemetry.Value = amount;
telemetry.Timestamp = DateTime.Now;
telemetry.Properties["agencyCode"] = agencyCode;
telemetry.Properties["accountCode"] = accountCode;
telemetry.Properties["category"] = category;
telemetry.Properties["action"] = action;
var client = new TelemetryClient();
client.TrackMetric(telemetry);
client.Flush();
问题是,是否可以按维度过滤自定义指标?