github.com/m3db/m3@v1.5.0/src/query/test/compatibility/testdata/aggregators.test (about) 1 load 5m 2 http_requests{job="api-server", instance="0", group="production"} 0+10x10 3 http_requests{job="api-server", instance="1", group="production"} 0+20x10 4 http_requests{job="api-server", instance="0", group="canary"} 0+30x10 5 http_requests{job="api-server", instance="1", group="canary"} 0+40x10 6 http_requests{job="app-server", instance="0", group="production"} 0+50x10 7 http_requests{job="app-server", instance="1", group="production"} 0+60x10 8 http_requests{job="app-server", instance="0", group="canary"} 0+70x10 9 http_requests{job="app-server", instance="1", group="canary"} 0+80x10 10 11 load 5m 12 foo{job="api-server", instance="0", region="europe"} 0+90x10 13 foo{job="api-server"} 0+100x10 14 15 # Simple sum. 16 eval instant at 50m SUM BY (group) (http_requests{job="api-server"}) 17 {group="canary"} 700 18 {group="production"} 300 19 20 eval instant at 50m SUM BY (group) (((http_requests{job="api-server"}))) 21 {group="canary"} 700 22 {group="production"} 300 23 24 # Test alternative "by"-clause order. 25 eval instant at 50m sum by (group) (http_requests{job="api-server"}) 26 {group="canary"} 700 27 {group="production"} 300 28 29 # Simple average. 30 eval instant at 50m avg by (group) (http_requests{job="api-server"}) 31 {group="canary"} 350 32 {group="production"} 150 33 34 # Simple count. 35 eval instant at 50m count by (group) (http_requests{job="api-server"}) 36 {group="canary"} 2 37 {group="production"} 2 38 39 # Simple without. 40 eval instant at 50m sum without (instance) (http_requests{job="api-server"}) 41 {group="canary",job="api-server"} 700 42 {group="production",job="api-server"} 300 43 44 # Empty by. 45 eval instant at 50m sum by () (http_requests{job="api-server"}) 46 {} 1000 47 48 # No by/without. 49 eval instant at 50m sum(http_requests{job="api-server"}) 50 {} 1000 51 52 # Empty without. 53 eval instant at 50m sum without () (http_requests{job="api-server",group="production"}) 54 {group="production",job="api-server",instance="0"} 100 55 {group="production",job="api-server",instance="1"} 200 56 57 # Without with mismatched and missing labels. Do not do this. 58 eval instant at 50m sum without (instance) (http_requests{job="api-server"} or foo) 59 {group="canary",job="api-server"} 700 60 {group="production",job="api-server"} 300 61 {region="europe",job="api-server"} 900 62 {job="api-server"} 1000 63 64 # Lower-cased aggregation operators should work too. 65 eval instant at 50m sum(http_requests) by (job) + min(http_requests) by (job) + max(http_requests) by (job) + avg(http_requests) by (job) 66 {job="app-server"} 4550 67 {job="api-server"} 1750 68 69 # Test alternative "by"-clause order. 70 eval instant at 50m sum by (group) (http_requests{job="api-server"}) 71 {group="canary"} 700 72 {group="production"} 300 73 74 # Test both alternative "by"-clause orders in one expression. 75 # Public health warning: stick to one form within an expression (or even 76 # in an organization), or risk serious user confusion. 77 eval instant at 50m sum(sum by (group) (http_requests{job="api-server"})) by (job) 78 {} 1000 79 80 81 82 # Standard deviation and variance. 83 eval instant at 50m stddev(http_requests) 84 {} 229.12878474779 85 86 eval instant at 50m stddev by (instance)(http_requests) 87 {instance="0"} 223.60679774998 88 {instance="1"} 223.60679774998 89 90 eval instant at 50m stdvar(http_requests) 91 {} 52500 92 93 eval instant at 50m stdvar by (instance)(http_requests) 94 {instance="0"} 50000 95 {instance="1"} 50000 96 97 # Float precision test for standard deviation and variance 98 clear 99 load 5m 100 http_requests{job="api-server", instance="0", group="production"} 0+1.33x10 101 http_requests{job="api-server", instance="1", group="production"} 0+1.33x10 102 http_requests{job="api-server", instance="0", group="canary"} 0+1.33x10 103 104 eval instant at 50m stddev(http_requests) 105 {} 0.0 106 107 eval instant at 50m stdvar(http_requests) 108 {} 0.0 109 110 111 112 # Regression test for missing separator byte in labelsToGroupingKey. 113 clear 114 load 5m 115 label_grouping_test{a="aa", b="bb"} 0+10x10 116 label_grouping_test{a="a", b="abb"} 0+20x10 117 118 eval instant at 50m sum(label_grouping_test) by (a, b) 119 {a="a", b="abb"} 200 120 {a="aa", b="bb"} 100 121 122 123 124 # Tests for min/max. 125 clear 126 load 5m 127 http_requests{job="api-server", instance="0", group="production"} 1 128 http_requests{job="api-server", instance="1", group="production"} 2 129 http_requests{job="api-server", instance="0", group="canary"} NaN 130 http_requests{job="api-server", instance="1", group="canary"} 3 131 http_requests{job="api-server", instance="2", group="canary"} 4 132 133 eval instant at 0m max(http_requests) 134 {} 4 135 136 eval instant at 0m min(http_requests) 137 {} 1 138 139 eval instant at 0m max by (group) (http_requests) 140 {group="production"} 2 141 {group="canary"} 4 142 143 eval instant at 0m min by (group) (http_requests) 144 {group="production"} 1 145 {group="canary"} 3 146 147 clear 148 149 # Tests for topk/bottomk. 150 load 5m 151 http_requests{job="api-server", instance="0", group="production"} 0+10x10 152 http_requests{job="api-server", instance="1", group="production"} 0+20x10 153 http_requests{job="api-server", instance="2", group="production"} NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 154 http_requests{job="api-server", instance="0", group="canary"} 0+30x10 155 http_requests{job="api-server", instance="1", group="canary"} 0+40x10 156 http_requests{job="app-server", instance="0", group="production"} 0+50x10 157 http_requests{job="app-server", instance="1", group="production"} 0+60x10 158 http_requests{job="app-server", instance="0", group="canary"} 0+70x10 159 http_requests{job="app-server", instance="1", group="canary"} 0+80x10 160 foo 3+0x10 161 162 eval_ordered instant at 50m topk(3, http_requests) 163 http_requests{group="canary", instance="1", job="app-server"} 800 164 http_requests{group="canary", instance="0", job="app-server"} 700 165 http_requests{group="production", instance="1", job="app-server"} 600 166 167 eval_ordered instant at 50m topk((3), (http_requests)) 168 http_requests{group="canary", instance="1", job="app-server"} 800 169 http_requests{group="canary", instance="0", job="app-server"} 700 170 http_requests{group="production", instance="1", job="app-server"} 600 171 172 eval_ordered instant at 50m topk(5, http_requests{group="canary",job="app-server"}) 173 http_requests{group="canary", instance="1", job="app-server"} 800 174 http_requests{group="canary", instance="0", job="app-server"} 700 175 176 eval_ordered instant at 50m bottomk(3, http_requests) 177 http_requests{group="production", instance="0", job="api-server"} 100 178 http_requests{group="production", instance="1", job="api-server"} 200 179 http_requests{group="canary", instance="0", job="api-server"} 300 180 181 eval_ordered instant at 50m bottomk(5, http_requests{group="canary",job="app-server"}) 182 http_requests{group="canary", instance="0", job="app-server"} 700 183 http_requests{group="canary", instance="1", job="app-server"} 800 184 185 eval instant at 50m topk by (group) (1, http_requests) 186 http_requests{group="production", instance="1", job="app-server"} 600 187 http_requests{group="canary", instance="1", job="app-server"} 800 188 189 eval instant at 50m bottomk by (group) (2, http_requests) 190 http_requests{group="canary", instance="0", job="api-server"} 300 191 http_requests{group="canary", instance="1", job="api-server"} 400 192 http_requests{group="production", instance="0", job="api-server"} 100 193 http_requests{group="production", instance="1", job="api-server"} 200 194 195 eval_ordered instant at 50m bottomk by (group) (2, http_requests{group="production"}) 196 http_requests{group="production", instance="0", job="api-server"} 100 197 http_requests{group="production", instance="1", job="api-server"} 200 198 199 # Test NaN is sorted away from the top/bottom. 200 eval_ordered instant at 50m topk(3, http_requests{job="api-server",group="production"}) 201 http_requests{job="api-server", instance="1", group="production"} 200 202 http_requests{job="api-server", instance="0", group="production"} 100 203 http_requests{job="api-server", instance="2", group="production"} NaN 204 205 eval_ordered instant at 50m bottomk(3, http_requests{job="api-server",group="production"}) 206 http_requests{job="api-server", instance="0", group="production"} 100 207 http_requests{job="api-server", instance="1", group="production"} 200 208 http_requests{job="api-server", instance="2", group="production"} NaN 209 210 # Test topk and bottomk allocate min(k, input_vector) for results vector 211 eval_ordered instant at 50m bottomk(9999999999, http_requests{job="app-server",group="canary"}) 212 http_requests{group="canary", instance="0", job="app-server"} 700 213 http_requests{group="canary", instance="1", job="app-server"} 800 214 215 eval_ordered instant at 50m topk(9999999999, http_requests{job="api-server",group="production"}) 216 http_requests{job="api-server", instance="1", group="production"} 200 217 http_requests{job="api-server", instance="0", group="production"} 100 218 http_requests{job="api-server", instance="2", group="production"} NaN 219 220 # Bug #5276. 221 #eval_ordered instant at 50m topk(scalar(foo), http_requests) 222 # http_requests{group="canary", instance="1", job="app-server"} 800 223 # http_requests{group="canary", instance="0", job="app-server"} 700 224 # http_requests{group="production", instance="1", job="app-server"} 600 225 226 clear 227 228 # Tests for count_values. 229 load 5m 230 version{job="api-server", instance="0", group="production"} 6 231 version{job="api-server", instance="1", group="production"} 6 232 version{job="api-server", instance="2", group="production"} 6 233 version{job="api-server", instance="0", group="canary"} 8 234 version{job="api-server", instance="1", group="canary"} 8 235 version{job="app-server", instance="0", group="production"} 6 236 version{job="app-server", instance="1", group="production"} 6 237 version{job="app-server", instance="0", group="canary"} 7 238 version{job="app-server", instance="1", group="canary"} 7 239 240 eval instant at 5m count_values("version", version) 241 {version="6"} 5 242 {version="7"} 2 243 {version="8"} 2 244 245 eval instant at 5m count_values(((("version"))), version) 246 {version="6"} 5 247 {version="7"} 2 248 {version="8"} 2 249 250 251 eval instant at 5m count_values without (instance)("version", version) 252 {job="api-server", group="production", version="6"} 3 253 {job="api-server", group="canary", version="8"} 2 254 {job="app-server", group="production", version="6"} 2 255 {job="app-server", group="canary", version="7"} 2 256 257 # Overwrite label with output. Don't do this. 258 #eval instant at 5m count_values without (instance)("job", version) 259 # {job="6", group="production"} 5 260 # {job="8", group="canary"} 2 261 # {job="7", group="canary"} 2 262 263 # Overwrite label with output. Don't do this. 264 #eval instant at 5m count_values by (job, group)("job", version) 265 # {job="6", group="production"} 5 266 # {job="8", group="canary"} 2 267 # {job="7", group="canary"} 2 268 269 270 # Tests for quantile. 271 clear 272 273 load 10s 274 data{test="two samples",point="a"} 0 275 data{test="two samples",point="b"} 1 276 data{test="three samples",point="a"} 0 277 data{test="three samples",point="b"} 1 278 data{test="three samples",point="c"} 2 279 data{test="uneven samples",point="a"} 0 280 data{test="uneven samples",point="b"} 1 281 data{test="uneven samples",point="c"} 4 282 foo .8 283 284 eval instant at 1m quantile without(point)(0.8, data) 285 {test="two samples"} 0.8 286 {test="three samples"} 1.6 287 {test="uneven samples"} 2.8 288 289 # FAILING issue #56. scalar() as a quantile()/topk()/bottomk() argument produces NaN 290 #eval instant at 1m quantile without(point)(scalar(foo), data) 291 # {test="two samples"} 0.8 292 # {test="three samples"} 1.6 293 # {test="uneven samples"} 2.8 294 295 296 #eval instant at 1m quantile without(point)((scalar(foo)), data) 297 # {test="two samples"} 0.8 298 # {test="three samples"} 1.6 299 # {test="uneven samples"} 2.8