Azure Log аналитика для запросов на основе дат - PullRequest
0 голосов
/ 09 мая 2018

Я хочу запросить таблицу в журнале аналитики, получить количество записей за последний час для текущей даты и сравнить число, полученное в тот же час на предыдущей неделе (7 дней назад) в тот же день.

Я не уверен, что приведенный ниже запрос поможет мне. Пожалуйста, помогите мне в этом.

Table1 | где TimeGenerated> сейчас (-1 ч) и responseCode_d == 200 | суммировать recount = count (responseCode) по responseCode | код отклика проекта, пересчет | присоединиться вид = внутренний ( Таблица 1 | где TimeGenerated> сейчас (-7d) и responseCode_d == 200 | суммировать recount1 = count (responseCode) по responseCode | responseCode_d проекта, recount1 ) в коде отклика

1 Ответ

0 голосов
/ 23 августа 2018

Как насчет этого?

Table1
| where TimeGenerated >= ago(1h) and TimeGenerated < now()
| where responseCode_d == 200
| summarize responseCountLastWeek=count() by responseCode
| project responseCode, responseCountLastWeek
| join kind=fullouter (
    Table1
    | where TimeGenerated >= ago(1h) - 7d and TimeGenerated < now() - 7d
    | responseCode_d == 200
    | summarize responseCountThisWeek=count() by responseCode
    | project responseCode, responseCountThisWeek
) on responseCode
| project
    responseCode = coalesce(responseCode, responseCode1),
    responseCountPrevWeek = coalesce(responseCountPrevWeek, 0),
    responseCountThisWeek = coalesce(responseCountThisWeek, 0)
...