将Application Insights'可用性'流式传输到SQL

时间:2016-10-19 11:56:46

标签: azure-application-insights azure-stream-analytics

我似乎无法使用Stream Analytics将可用性遥测数据推送到Azure SQL数据库。没有错误。只是没有插入数据。

输入

我将输入设置到Application Insights导出的blob位置。我已经使用“示例数据”功能成功测试了这个:

Input Details

以下是抽取的样本数据的示例(请注意,我已简化了内容):

[
    {
        "availability": [ {
            "testRunId": "75e32865-36fa-4853-b9be-43e315a63f6e",
            "testTimestamp": "2016-10-19T11:38:58.7370000Z",
            "testName": "mytest-prod-pingtest",
            "runLocation": "BR : Sao Paulo",
            "durationMetric": {
                "name": "duration",
                "value": 14610000.0,
                "count": 1.0,
                "min": 14610000.0,
                "max": 14610000.0,
                "stdDev": 0.0,
                "sampledValue": 14610000.0
            },
            "result": "Pass",
            "count": 1
        } ],
        "internal": {...},
        "context": {...},
        "EventProcessedUtcTime": "2016-10-19T11:45:53.9144151Z"
    }
]

输出继电器

输出配置为Azure SQL DB表tt.AvailabilityRequests。测试成功:

Output testing

此表具有以下架构:

CREATE TABLE [tt].[AvailabilityRequests](
    [Id] [uniqueidentifier] NOT NULL DEFAULT (newsequentialid()),
    [Timestamp] [datetime] NOT NULL,
    [AppInsightsTestRunId] [varchar](max) NULL,
    [TestName] [varchar](max) NULL,
    [RunLocation] [varchar](max) NULL,
    [IsSuccessful] [bit] NULL,
    [DurationInMilliseconds] [int] NULL,
    [InsertedDate] [datetime] NOT NULL DEFAULT (getdate())
)

查询

我配置了以下查询:

SELECT
    Flat.ArrayValue.testTimestamp as [Timestamp],
    Flat.ArrayValue.testRunId as [AppInsightsTestRunId],
    Flat.ArrayValue.testName as [TestName],
    Flat.ArrayValue.runLocation as [RunLocation],
    CASE WHEN Flat.ArrayValue.result = 'Pass' THEN 1 ELSE 0 END as [IsSuccessful],
    CAST(Flat.ArrayValue.durationMetric.value / Flat.ArrayValue.durationMetric.count / 10000 AS BIGINT) as [DurationInMilliseconds]
INTO
    availabilityRequests
FROM
    availability A
CROSS APPLY 
    GetElements(A.[availability]) as Flat

我正在使用Request遥测做类似的事情,这很好用:

Query

1 个答案:

答案 0 :(得分:1)

Stream Analytics does not support the "boolean" type;在SQL Server中进行BIT。

[IsSuccessful]字段更改为[int]后,正在推送数据。