github.com/munnerz/test-infra@v0.0.0-20190108210205-ce3d181dc989/metrics/configs/build-stats.yaml (about)

     1  metric: build-stats
     2  description: Calculate the number of builds started and passed each day
     3  query: |
     4    #standardSQL
     5    select
     6      unix_seconds(day) day,
     7      invocations,
     8      passes,
     9      if (invocations > 0, passes / invocations, 1) rate
    10    from (
    11    SELECT
    12      timestamp_trunc(started, day) day,
    13      COUNT(started) invocations,
    14      countif(result = 'SUCCESS') passes
    15    FROM
    16      `k8s-gubernator.build.all`
    17    where
    18      started >= TIMESTAMP_SECONDS(<LAST_DATA_TIME>)
    19      and started < timestamp_trunc(current_timestamp(), day)
    20    group by day
    21    order by day
    22    )
    23    where day is not null
    24    order by day
    25  jqfilter: |
    26    ([(.[] | .day|tonumber)] | max) as $newestday |
    27    [(.[] | select((.day|tonumber)==$newestday) | {
    28      day: .day,
    29      invocations: (.invocations|tonumber),
    30      passes: (.passes|tonumber),
    31      rate: (.rate|tonumber)
    32    })]
    33  
    34  measurements:
    35    backfill: build_stats
    36    jq: |
    37      [(.[] | {
    38        measurement: "build_stats",
    39        time: (.day|tonumber),
    40        tags: {
    41          day: (.day|tonumber)
    42        },
    43        fields: {
    44          invocations: (.invocations|tonumber),
    45          passes: (.passes|tonumber),
    46          rate: (.rate|tonumber)
    47        }
    48      })]