使用Azure Kusto查询比较Jmeter结果

ve7v8dk2  于 2022-11-09  发布在  其他
关注(0)|答案(2)|浏览(193)

我正在尝试创建一个Kusto查询来比较两个Jmeter结果,我已经有了这个查询,它显示了1个测试的结果,但我不知道如何添加另一个查询并将结果保存。
随附查询和图片以供参考。
有人可以帮助我完成查询吗?

let testName = "jmeter";
let TestStartTime = "{Startime}";
requests
| where name == testName
    and customDimensions.TestStartTime == TestStartTime
| summarize
    Samples = count(),
    Average = tolong(avg(duration)),
    (L50, L90, L95, L99)
        = percentiles(duration, 50, 90, 95, 99),
    Min = min(duration),
    Maximum = max(duration),
    ErrorCount = countif(success == false),
    StartTime = min(tolong(customDimensions.SampleStartTime)),
    EndTime = max(tolong(customDimensions.SampleEndTime))
    by Label = tostring(customDimensions.SampleLabel)
| extend s = 0
| union (
requests
| where name == testName
    and customDimensions.TestStartTime == TestStartTime
| summarize
    Samples = count(),
    Average = tolong(avg(duration)),
    (L50, L90, L95, L99)
        = percentiles(duration, 50, 90, 95, 99),
    Min = min(duration),
    Maximum = max(duration),
    ErrorCount = countif(success == false),
    StartTime = min(tolong(customDimensions.SampleStartTime)),
    EndTime = max(tolong(customDimensions.SampleEndTime))
| extend Label = 'TOTAL', s = 9
)
| extend
    tp = Samples / ((EndTime - StartTime) / 1000.0),
    KBPeriod = (EndTime - StartTime) * 1024 / 1000.0
| sort by s asc
| project
    Label, Samples, Average,
    Median = round(L50),
    ['90% Line'] = round(L90),
    ['95% Line'] = round(L95),
    ['99% Line'] = round(L99),
    Min, Maximum,
    ['Error %'] = strcat(round(ErrorCount * 100.0 / Samples, 2), '%'),
    ['Throughput'] = iif(tp < 1.0,
                        strcat(round(tp * 60, 1), '/min'),
                        strcat(round(tp, 1), '/sec')
                     )
| project-reorder
    Label, Samples, Average,
    ['Median'], ['90% Line'], ['95% Line'], ['99% Line'],
    Min, Maximum, ['Error %'], ['Throughput']

7gcisfzg

7gcisfzg1#

为了能够“比较”,你需要以某种方式区分2个不同的运行,我看不到任何指标,你可以使用。
因此,最简单的选择是首先运行Merge Results Tool,它将创建一个aggregate .jtl结果文件,然后使用KQL解析它。
可以使用JMeter Plugins Manager安装合并结果工具

ej83mcc0

ej83mcc02#

我解决了这个问题,下面是比较结果的脚本
希望这对你有帮助

requests
| where name == "{TestNameA}"
    and customDimensions.TestStartTime == "{TestStartTimeA}"
| summarize
    Samples_A = count(),
    Average_A = tolong(avg(duration)),
    (L95_A)
        = percentiles(duration, 95),
    Min_A = min(duration),
    Maximum_A = max(duration),
    ErrorCount_A = countif(success == false),
    StartTime = min(tolong(customDimensions.SampleStartTime)),
    EndTime = max(tolong(customDimensions.SampleEndTime))
    by Label = tostring(customDimensions.SampleLabel)
| extend s = 0
| join (
requests
| where name == "{TestNameB}"
    and customDimensions.TestStartTime == "{TestStartTimeB}"
| summarize
    Samples_B = count(),
    Average_B = tolong(avg(duration)),
    (L95_B)
        = percentiles(duration, 95),
    Min_B = min(duration),
    Maximum_B = max(duration),
    ErrorCount_B = countif(success == false),
    StartTime = min(tolong(customDimensions.SampleStartTime)),
    EndTime = max(tolong(customDimensions.SampleEndTime))
    by Label = tostring(customDimensions.SampleLabel)
| extend s = 1
) on Label
| sort by s asc
| project
    Label, Samples_A, Samples_B, Average_A, Average_B,
    ['95% Line_A'] = round(L95_A),
    ['95% Line_B'] = round(L95_B),
    Min_A, Min_B, Maximum_A, Maximum_B,
    ['Error_A %'] = strcat(round(ErrorCount_A * 100.0 / Samples_A, 2), '%'),
    ['Error_B %'] = strcat(round(ErrorCount_B * 100.0 / Samples_B, 2), '%')
| project-reorder
   Label, Samples_A, Samples_B, Average_A, Average_B,
    ['95% Line_A'], ['95% Line_B'], Min_A, Min_B, Maximum_A, Maximum_B, ['Error_A %'], ['Error_B %']

Script

相关问题