github.com/m3db/m3@v1.5.0/src/query/test/compatibility/testdata/operators.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  	vector_matching_a{l="x"} 0+1x100
    13  	vector_matching_a{l="y"} 0+2x50
    14  	vector_matching_b{l="x"} 0+4x25
    15  
    16  
    17  eval instant at 50m SUM(http_requests) BY (job) - COUNT(http_requests) BY (job)
    18  	{job="api-server"} 996
    19  	{job="app-server"} 2596
    20  
    21  eval instant at 50m 2 - SUM(http_requests) BY (job)
    22  	{job="api-server"} -998
    23  	{job="app-server"} -2598
    24  
    25  # FAILING issue #53. eval instant at 50m -http_requests{job="api-server",instance="0",group="production"}
    26  #  {job="api-server",instance="0",group="production"} -100
    27  
    28  eval instant at 50m +http_requests{job="api-server",instance="0",group="production"}
    29    http_requests{job="api-server",instance="0",group="production"} 100
    30  
    31  eval instant at 50m - - - SUM(http_requests) BY (job)
    32  	{job="api-server"} -1000
    33  	{job="app-server"} -2600
    34  
    35  eval instant at 50m - - - 1
    36    -1
    37  
    38  # FAILING. eval instant at 50m -2^---1*3
    39  #  -1.5
    40  
    41  # FAILING. eval instant at 50m 2/-2^---1*3+2
    42  #  -10
    43  
    44  # FAILING. eval instant at 50m -10^3 * - SUM(http_requests) BY (job) ^ -1
    45  #	{job="api-server"} 1
    46  #	{job="app-server"} 0.38461538461538464
    47  
    48  eval instant at 50m 1000 / SUM(http_requests) BY (job)
    49  	{job="api-server"} 1
    50  	{job="app-server"} 0.38461538461538464
    51  
    52  eval instant at 50m SUM(http_requests) BY (job) - 2
    53  	{job="api-server"} 998
    54  	{job="app-server"} 2598
    55  
    56  eval instant at 50m SUM(http_requests) BY (job) % 3
    57  	{job="api-server"} 1
    58  	{job="app-server"} 2
    59  
    60  eval instant at 50m SUM(http_requests) BY (job) % 0.3
    61  	{job="api-server"} 0.1
    62  	{job="app-server"} 0.2
    63  
    64  eval instant at 50m SUM(http_requests) BY (job) ^ 2
    65  	{job="api-server"} 1000000
    66  	{job="app-server"} 6760000
    67  
    68  eval instant at 50m SUM(http_requests) BY (job) % 3 ^ 2
    69  	{job="api-server"} 1
    70  	{job="app-server"} 8
    71  
    72  eval instant at 50m SUM(http_requests) BY (job) % 2 ^ (3 ^ 2)
    73  	{job="api-server"} 488
    74  	{job="app-server"} 40
    75  
    76  eval instant at 50m SUM(http_requests) BY (job) % 2 ^ 3 ^ 2
    77  	{job="api-server"} 488
    78  	{job="app-server"} 40
    79  
    80  eval instant at 50m SUM(http_requests) BY (job) % 2 ^ 3 ^ 2 ^ 2
    81  	{job="api-server"} 1000
    82  	{job="app-server"} 2600
    83  
    84  eval instant at 50m COUNT(http_requests) BY (job) ^ COUNT(http_requests) BY (job)
    85  	{job="api-server"} 256
    86  	{job="app-server"} 256
    87  
    88  eval instant at 50m SUM(http_requests) BY (job) / 0
    89  	{job="api-server"} +Inf
    90  	{job="app-server"} +Inf
    91  
    92  eval instant at 50m SUM(http_requests) BY (job) + SUM(http_requests) BY (job)
    93  	{job="api-server"} 2000
    94  	{job="app-server"} 5200
    95  
    96  eval instant at 50m (SUM((http_requests)) BY (job)) + SUM(http_requests) BY (job)
    97  	{job="api-server"} 2000
    98  	{job="app-server"} 5200
    99  
   100  eval instant at 50m http_requests{job="api-server", group="canary"}
   101  	http_requests{group="canary", instance="0", job="api-server"} 300
   102  	http_requests{group="canary", instance="1", job="api-server"} 400
   103  
   104  eval instant at 50m http_requests{job="api-server", group="canary"} + rate(http_requests{job="api-server"}[5m]) * 5 * 60
   105  	{group="canary", instance="0", job="api-server"} 330
   106  	{group="canary", instance="1", job="api-server"} 440
   107  
   108  eval instant at 50m rate(http_requests[25m]) * 25 * 60
   109    {group="canary", instance="0", job="api-server"} 150
   110    {group="canary", instance="0", job="app-server"} 350
   111    {group="canary", instance="1", job="api-server"} 200
   112    {group="canary", instance="1", job="app-server"} 400
   113    {group="production", instance="0", job="api-server"} 50
   114    {group="production", instance="0", job="app-server"} 249.99999999999997
   115    {group="production", instance="1", job="api-server"} 100
   116    {group="production", instance="1", job="app-server"} 300
   117  
   118  eval instant at 50m (rate((http_requests[25m])) * 25) * 60
   119    {group="canary", instance="0", job="api-server"} 150
   120    {group="canary", instance="0", job="app-server"} 350
   121    {group="canary", instance="1", job="api-server"} 200
   122    {group="canary", instance="1", job="app-server"} 400
   123    {group="production", instance="0", job="api-server"} 50
   124    {group="production", instance="0", job="app-server"} 249.99999999999997
   125    {group="production", instance="1", job="api-server"} 100
   126    {group="production", instance="1", job="app-server"} 300
   127  
   128  
   129  # FAILING order of rows differs. eval instant at 50m http_requests{group="canary"} and http_requests{instance="0"}
   130  #	http_requests{group="canary", instance="0", job="api-server"} 300
   131  #	http_requests{group="canary", instance="0", job="app-server"} 700
   132  
   133  eval instant at 50m (http_requests{group="canary"} + 1) and http_requests{instance="0"}
   134  	{group="canary", instance="0", job="api-server"} 301
   135  	{group="canary", instance="0", job="app-server"} 701
   136  
   137  eval instant at 50m (http_requests{group="canary"} + 1) and on(instance, job) http_requests{instance="0", group="production"}
   138  	{group="canary", instance="0", job="api-server"} 301
   139  	{group="canary", instance="0", job="app-server"} 701
   140  
   141  eval instant at 50m (http_requests{group="canary"} + 1) and on(instance) http_requests{instance="0", group="production"}
   142  	{group="canary", instance="0", job="api-server"} 301
   143  	{group="canary", instance="0", job="app-server"} 701
   144  
   145  eval instant at 50m (http_requests{group="canary"} + 1) and ignoring(group) http_requests{instance="0", group="production"}
   146  	{group="canary", instance="0", job="api-server"} 301
   147  	{group="canary", instance="0", job="app-server"} 701
   148  
   149  eval instant at 50m (http_requests{group="canary"} + 1) and ignoring(group, job) http_requests{instance="0", group="production"}
   150  	{group="canary", instance="0", job="api-server"} 301
   151  	{group="canary", instance="0", job="app-server"} 701
   152  
   153  # FAILING order of rows differs. eval instant at 50m http_requests{group="canary"} or http_requests{group="production"}
   154  #	http_requests{group="canary", instance="0", job="api-server"} 300
   155  #	http_requests{group="canary", instance="0", job="app-server"} 700
   156  #	http_requests{group="canary", instance="1", job="api-server"} 400
   157  #	http_requests{group="canary", instance="1", job="app-server"} 800
   158  #	http_requests{group="production", instance="0", job="api-server"} 100
   159  #	http_requests{group="production", instance="0", job="app-server"} 500
   160  #	http_requests{group="production", instance="1", job="api-server"} 200
   161  #	http_requests{group="production", instance="1", job="app-server"} 600
   162  
   163  # On overlap the rhs samples must be dropped.
   164  # FAILING issue 34#. eval instant at 50m (http_requests{group="canary"} + 1) or http_requests{instance="1"}
   165  #	{group="canary", instance="0", job="api-server"} 301
   166  #	{group="canary", instance="0", job="app-server"} 701
   167  #	{group="canary", instance="1", job="api-server"} 401
   168  #	{group="canary", instance="1", job="app-server"} 801
   169  #	http_requests{group="production", instance="1", job="api-server"} 200
   170  #	http_requests{group="production", instance="1", job="app-server"} 600
   171  
   172  
   173  # Matching only on instance excludes everything that has instance=0/1 but includes
   174  # entries without the instance label.
   175  # FAILING issue 34#. eval instant at 50m (http_requests{group="canary"} + 1) or on(instance) (http_requests or cpu_count or vector_matching_a)
   176  #	{group="canary", instance="0", job="api-server"} 301
   177  #	{group="canary", instance="0", job="app-server"} 701
   178  #	{group="canary", instance="1", job="api-server"} 401
   179  #	{group="canary", instance="1", job="app-server"} 801
   180  #	vector_matching_a{l="x"} 10
   181  #	vector_matching_a{l="y"} 20
   182  
   183  # FAILING issue 34#. eval instant at 50m (http_requests{group="canary"} + 1) or ignoring(l, group, job) (http_requests or cpu_count or vector_matching_a)
   184  #	{group="canary", instance="0", job="api-server"} 301
   185  #	{group="canary", instance="0", job="app-server"} 701
   186  #	{group="canary", instance="1", job="api-server"} 401
   187  #	{group="canary", instance="1", job="app-server"} 801
   188  #	vector_matching_a{l="x"} 10
   189  #	vector_matching_a{l="y"} 20
   190  
   191  # FAILING issue 34#. eval instant at 50m http_requests{group="canary"} unless http_requests{instance="0"}
   192  #	http_requests{group="canary", instance="1", job="api-server"} 400
   193  #	http_requests{group="canary", instance="1", job="app-server"} 800
   194  
   195  # FAILING issue #35. eval instant at 50m http_requests{group="canary"} unless on(job) http_requests{instance="0"}
   196  
   197  # FAILING issue #34. eval instant at 50m http_requests{group="canary"} unless on(job, instance) http_requests{instance="0"}
   198  #	http_requests{group="canary", instance="1", job="api-server"} 400
   199  #	http_requests{group="canary", instance="1", job="app-server"} 800
   200  
   201  eval instant at 50m http_requests{group="canary"} / on(instance,job) http_requests{group="production"}
   202  	{instance="0", job="api-server"} 3
   203  	{instance="0", job="app-server"} 1.4
   204  	{instance="1", job="api-server"} 2
   205  	{instance="1", job="app-server"} 1.3333333333333333
   206  
   207  # FAILING issue #35. eval instant at 50m http_requests{group="canary"} unless ignoring(group, instance) http_requests{instance="0"}
   208  
   209  # FAILING. eval instant at 50m http_requests{group="canary"} unless ignoring(group) http_requests{instance="0"}
   210  #	http_requests{group="canary", instance="1", job="api-server"} 400
   211  #	http_requests{group="canary", instance="1", job="app-server"} 800
   212  
   213  # FAILING. eval instant at 50m http_requests{group="canary"} / ignoring(group) http_requests{group="production"}
   214  #	{instance="0", job="api-server"} 3
   215  #	{instance="0", job="app-server"} 1.4
   216  #	{instance="1", job="api-server"} 2
   217  #	{instance="1", job="app-server"} 1.3333333333333333
   218  
   219  # https://github.com/prometheus/prometheus/issues/1489
   220  # FAILING. eval instant at 50m http_requests AND ON (dummy) vector(1)
   221  #	http_requests{group="canary", instance="0", job="api-server"} 300
   222  #	http_requests{group="canary", instance="0", job="app-server"} 700
   223  #	http_requests{group="canary", instance="1", job="api-server"} 400
   224  #	http_requests{group="canary", instance="1", job="app-server"} 800
   225  #	http_requests{group="production", instance="0", job="api-server"} 100
   226  #	http_requests{group="production", instance="0", job="app-server"} 500
   227  #	http_requests{group="production", instance="1", job="api-server"} 200
   228  #	http_requests{group="production", instance="1", job="app-server"} 600
   229  
   230  # FAILING. eval instant at 50m http_requests AND IGNORING (group, instance, job) vector(1)
   231  #	http_requests{group="canary", instance="0", job="api-server"} 300
   232  #	http_requests{group="canary", instance="0", job="app-server"} 700
   233  #	http_requests{group="canary", instance="1", job="api-server"} 400
   234  #	http_requests{group="canary", instance="1", job="app-server"} 800
   235  #	http_requests{group="production", instance="0", job="api-server"} 100
   236  #	http_requests{group="production", instance="0", job="app-server"} 500
   237  #	http_requests{group="production", instance="1", job="api-server"} 200
   238  #	http_requests{group="production", instance="1", job="app-server"} 600
   239  
   240  
   241  # Comparisons.
   242  eval instant at 50m SUM(http_requests) BY (job) > 1000
   243  	{job="app-server"} 2600
   244  
   245  # FAILING (returns lhs instead of rhs). eval instant at 50m 1000 < SUM(http_requests) BY (job)
   246  #	{job="app-server"} 2600
   247  
   248  eval instant at 50m SUM(http_requests) BY (job) <= 1000
   249  	{job="api-server"} 1000
   250  
   251  eval instant at 50m SUM(http_requests) BY (job) != 1000
   252  	{job="app-server"} 2600
   253  
   254  eval instant at 50m SUM(http_requests) BY (job) == 1000
   255  	{job="api-server"} 1000
   256  
   257  eval instant at 50m SUM(http_requests) BY (job) == bool 1000
   258  	{job="api-server"} 1
   259  	{job="app-server"} 0
   260  
   261  eval instant at 50m SUM(http_requests) BY (job) == bool SUM(http_requests) BY (job)
   262  	{job="api-server"} 1
   263  	{job="app-server"} 1
   264  
   265  eval instant at 50m SUM(http_requests) BY (job) != bool SUM(http_requests) BY (job)
   266  	{job="api-server"} 0
   267  	{job="app-server"} 0
   268  
   269  eval instant at 50m 0 == bool 1
   270  	0
   271  
   272  eval instant at 50m 1 == bool 1
   273  	1
   274  
   275  eval instant at 50m http_requests{job="api-server", instance="0", group="production"} == bool 100
   276  	{job="api-server", instance="0", group="production"} 1
   277  
   278  # group_left/group_right.
   279  
   280  clear
   281  
   282  load 5m
   283    node_var{instance="abc",job="node"} 2
   284    node_role{instance="abc",job="node",role="prometheus"} 1
   285  
   286  load 5m
   287    node_cpu{instance="abc",job="node",mode="idle"} 3
   288    node_cpu{instance="abc",job="node",mode="user"} 1
   289    node_cpu{instance="def",job="node",mode="idle"} 8
   290    node_cpu{instance="def",job="node",mode="user"} 2
   291  
   292  load 5m
   293    random{foo="bar"} 1
   294  
   295  load 5m
   296    threshold{instance="abc",job="node",target="a@b.com"} 0
   297  
   298  # Copy machine role to node variable.
   299  eval instant at 5m node_role * on (instance) group_right (role) node_var
   300    {instance="abc",job="node",role="prometheus"} 2
   301  
   302  # FAILING. eval instant at 5m node_var * on (instance) group_left (role) node_role
   303  #  {instance="abc",job="node",role="prometheus"} 2
   304  
   305  # FAILING. eval instant at 5m node_var * ignoring (role) group_left (role) node_role
   306  #  {instance="abc",job="node",role="prometheus"} 2
   307  
   308  eval instant at 5m node_role * ignoring (role) group_right (role) node_var
   309    {instance="abc",job="node",role="prometheus"} 2
   310  
   311  # Copy machine role to node variable with instrumentation labels.
   312  # FAILING. eval instant at 5m node_cpu * ignoring (role, mode) group_left (role) node_role
   313  #  {instance="abc",job="node",mode="idle",role="prometheus"} 3
   314  #  {instance="abc",job="node",mode="user",role="prometheus"} 1
   315  
   316  # FAILING. eval instant at 5m node_cpu * on (instance) group_left (role) node_role
   317  #  {instance="abc",job="node",mode="idle",role="prometheus"} 3
   318  #  {instance="abc",job="node",mode="user",role="prometheus"} 1
   319  
   320  
   321  # Ratio of total.
   322  eval instant at 5m node_cpu / on (instance) group_left sum by (instance,job)(node_cpu)
   323    {instance="abc",job="node",mode="idle"} .75
   324    {instance="abc",job="node",mode="user"} .25
   325    {instance="def",job="node",mode="idle"} .80
   326    {instance="def",job="node",mode="user"} .20
   327  
   328  eval instant at 5m sum by (mode, job)(node_cpu) / on (job) group_left sum by (job)(node_cpu)
   329    {job="node",mode="idle"} 0.7857142857142857
   330    {job="node",mode="user"} 0.21428571428571427
   331  
   332  eval instant at 5m sum(sum by (mode, job)(node_cpu) / on (job) group_left sum by (job)(node_cpu))
   333    {} 1.0
   334  
   335  
   336  eval instant at 5m node_cpu / ignoring (mode) group_left sum without (mode)(node_cpu)
   337    {instance="abc",job="node",mode="idle"} .75
   338    {instance="abc",job="node",mode="user"} .25
   339    {instance="def",job="node",mode="idle"} .80
   340    {instance="def",job="node",mode="user"} .20
   341  
   342  eval instant at 5m node_cpu / ignoring (mode) group_left(dummy) sum without (mode)(node_cpu)
   343    {instance="abc",job="node",mode="idle"} .75
   344    {instance="abc",job="node",mode="user"} .25
   345    {instance="def",job="node",mode="idle"} .80
   346    {instance="def",job="node",mode="user"} .20
   347  
   348  eval instant at 5m sum without (instance)(node_cpu) / ignoring (mode) group_left sum without (instance, mode)(node_cpu)
   349    {job="node",mode="idle"} 0.7857142857142857
   350    {job="node",mode="user"} 0.21428571428571427
   351  
   352  eval instant at 5m sum(sum without (instance)(node_cpu) / ignoring (mode) group_left sum without (instance, mode)(node_cpu))
   353    {} 1.0
   354  
   355  
   356  # Copy over label from metric with no matching labels, without having to list cross-job target labels ('job' here).
   357  # FAILING. eval instant at 5m node_cpu + on(dummy) group_left(foo) random*0
   358  #  {instance="abc",job="node",mode="idle",foo="bar"} 3
   359  #  {instance="abc",job="node",mode="user",foo="bar"} 1
   360  #  {instance="def",job="node",mode="idle",foo="bar"} 8
   361  #  {instance="def",job="node",mode="user",foo="bar"} 2
   362  
   363  
   364  # Use threshold from metric, and copy over target.
   365  # FAILING. eval instant at 5m node_cpu > on(job, instance) group_left(target) threshold
   366  #  node_cpu{instance="abc",job="node",mode="idle",target="a@b.com"} 3
   367  #  node_cpu{instance="abc",job="node",mode="user",target="a@b.com"} 1
   368  
   369  # Use threshold from metric, and a default (1) if it's not present.
   370  # FAILING. eval instant at 5m node_cpu > on(job, instance) group_left(target) (threshold or on (job, instance) (sum by (job, instance)(node_cpu) * 0 + 1))
   371  #  node_cpu{instance="abc",job="node",mode="idle",target="a@b.com"} 3
   372  #  node_cpu{instance="abc",job="node",mode="user",target="a@b.com"} 1
   373  #  node_cpu{instance="def",job="node",mode="idle"} 8
   374  #  node_cpu{instance="def",job="node",mode="user"} 2
   375  
   376  
   377  # Check that binops drop the metric name.
   378  eval instant at 5m node_cpu + 2
   379    {instance="abc",job="node",mode="idle"} 5
   380    {instance="abc",job="node",mode="user"} 3
   381    {instance="def",job="node",mode="idle"} 10
   382    {instance="def",job="node",mode="user"} 4
   383  
   384  eval instant at 5m node_cpu - 2
   385    {instance="abc",job="node",mode="idle"} 1
   386    {instance="abc",job="node",mode="user"} -1
   387    {instance="def",job="node",mode="idle"} 6
   388    {instance="def",job="node",mode="user"} 0
   389  
   390  eval instant at 5m node_cpu / 2
   391    {instance="abc",job="node",mode="idle"} 1.5
   392    {instance="abc",job="node",mode="user"} 0.5
   393    {instance="def",job="node",mode="idle"} 4
   394    {instance="def",job="node",mode="user"} 1
   395  
   396  eval instant at 5m node_cpu * 2
   397    {instance="abc",job="node",mode="idle"} 6
   398    {instance="abc",job="node",mode="user"} 2
   399    {instance="def",job="node",mode="idle"} 16
   400    {instance="def",job="node",mode="user"} 4
   401  
   402  eval instant at 5m node_cpu ^ 2
   403    {instance="abc",job="node",mode="idle"} 9
   404    {instance="abc",job="node",mode="user"} 1
   405    {instance="def",job="node",mode="idle"} 64
   406    {instance="def",job="node",mode="user"} 4
   407  
   408  eval instant at 5m node_cpu % 2
   409    {instance="abc",job="node",mode="idle"} 1
   410    {instance="abc",job="node",mode="user"} 1
   411    {instance="def",job="node",mode="idle"} 0
   412    {instance="def",job="node",mode="user"} 0
   413  
   414  
   415  clear
   416  
   417  load 5m
   418    random{foo="bar"} 2
   419    metricA{baz="meh"} 3
   420    metricB{baz="meh"} 4
   421  
   422  # On with no labels, for metrics with no common labels.
   423  # FAILING issue #36. eval instant at 5m random + on() metricA
   424  #  {} 5
   425  
   426  # Ignoring with no labels is the same as no ignoring.
   427  eval instant at 5m metricA + ignoring() metricB
   428    {baz="meh"} 7
   429  
   430  eval instant at 5m metricA + metricB
   431    {baz="meh"} 7
   432  
   433  clear
   434  
   435  # Test duplicate labelset in promql output.
   436  load 5m
   437    testmetric1{src="a",dst="b"} 0
   438    testmetric2{src="a",dst="b"} 1
   439  
   440  # FAILING issue #32. eval_fail instant at 0m -{__name__=~'testmetric1|testmetric2'}