@@ -845,11 +845,17 @@ func TestInstance_Volume(t *testing.T) {
845
845
err := instance .Push (context .TODO (), & logproto.PushRequest {
846
846
Streams : []logproto.Stream {
847
847
{
848
- Labels : `{host="other"}` ,
848
+ Labels : `{fizz="buzz", host="other"}` ,
849
849
Entries : []logproto.Entry {
850
850
{Timestamp : time .Unix (0 , 1e6 ), Line : `msg="other"` },
851
851
},
852
852
},
853
+ {
854
+ Labels : `{foo="bar", host="other", log_stream="worker"}` ,
855
+ Entries : []logproto.Entry {
856
+ {Timestamp : time .Unix (0 , 1e6 ), Line : `msg="other worker"` },
857
+ },
858
+ },
853
859
},
854
860
})
855
861
require .NoError (t , err )
@@ -864,15 +870,16 @@ func TestInstance_Volume(t *testing.T) {
864
870
From : 0 ,
865
871
Through : 1.1 * 1e3 , //milliseconds
866
872
Matchers : "{}" ,
867
- Limit : 3 ,
873
+ Limit : 5 ,
868
874
AggregateBy : seriesvolume .Series ,
869
875
})
870
876
require .NoError (t , err )
871
877
872
878
require .Equal (t , []logproto.Volume {
873
879
{Name : `{host="agent", job="3", log_stream="dispatcher"}` , Volume : 90 },
874
880
{Name : `{host="agent", job="3", log_stream="worker"}` , Volume : 70 },
875
- {Name : `{host="other"}` , Volume : 11 },
881
+ {Name : `{foo="bar", host="other", log_stream="worker"}` , Volume : 18 },
882
+ {Name : `{fizz="buzz", host="other"}` , Volume : 11 },
876
883
}, volumes .Volumes )
877
884
})
878
885
@@ -882,7 +889,7 @@ func TestInstance_Volume(t *testing.T) {
882
889
From : 0 ,
883
890
Through : 1.1 * 1e3 , //milliseconds
884
891
Matchers : `{log_stream="dispatcher"}` ,
885
- Limit : 3 ,
892
+ Limit : 5 ,
886
893
AggregateBy : seriesvolume .Series ,
887
894
})
888
895
require .NoError (t , err )
@@ -898,7 +905,7 @@ func TestInstance_Volume(t *testing.T) {
898
905
From : 5 ,
899
906
Through : 1.1 * 1e3 , //milliseconds
900
907
Matchers : "{}" ,
901
- Limit : 3 ,
908
+ Limit : 5 ,
902
909
AggregateBy : seriesvolume .Series ,
903
910
})
904
911
require .NoError (t , err )
@@ -932,15 +939,15 @@ func TestInstance_Volume(t *testing.T) {
932
939
From : 0 ,
933
940
Through : 1.1 * 1e3 , //milliseconds
934
941
Matchers : `{}` ,
935
- Limit : 3 ,
942
+ Limit : 5 ,
936
943
TargetLabels : []string {"log_stream" },
937
944
AggregateBy : seriesvolume .Series ,
938
945
})
939
946
require .NoError (t , err )
940
947
941
948
require .Equal (t , []logproto.Volume {
942
949
{Name : `{log_stream="dispatcher"}` , Volume : 90 },
943
- {Name : `{log_stream="worker"}` , Volume : 70 },
950
+ {Name : `{log_stream="worker"}` , Volume : 88 },
944
951
}, volumes .Volumes )
945
952
})
946
953
@@ -950,7 +957,7 @@ func TestInstance_Volume(t *testing.T) {
950
957
From : 0 ,
951
958
Through : 1.1 * 1e3 , //milliseconds
952
959
Matchers : `{log_stream="dispatcher"}` ,
953
- Limit : 3 ,
960
+ Limit : 5 ,
954
961
TargetLabels : []string {"host" },
955
962
AggregateBy : seriesvolume .Series ,
956
963
})
@@ -967,7 +974,7 @@ func TestInstance_Volume(t *testing.T) {
967
974
From : 0 ,
968
975
Through : 1.1 * 1e3 , //milliseconds
969
976
Matchers : `{log_stream=~".+"}` ,
970
- Limit : 3 ,
977
+ Limit : 5 ,
971
978
TargetLabels : []string {"host" , "job" },
972
979
AggregateBy : seriesvolume .Series ,
973
980
})
@@ -987,32 +994,39 @@ func TestInstance_Volume(t *testing.T) {
987
994
From : 0 ,
988
995
Through : 1.1 * 1e3 , //milliseconds
989
996
Matchers : "{}" ,
990
- Limit : 3 ,
997
+ Limit : 5 ,
991
998
AggregateBy : seriesvolume .Labels ,
992
999
})
993
1000
require .NoError (t , err )
994
1001
995
1002
require .Equal (t , []logproto.Volume {
996
- {Name : `host` , Volume : 171 },
1003
+ {Name : `host` , Volume : 189 },
1004
+ {Name : `log_stream` , Volume : 178 },
997
1005
{Name : `job` , Volume : 160 },
998
- {Name : `log_stream` , Volume : 160 },
1006
+ {Name : `foo` , Volume : 18 },
1007
+ {Name : `fizz` , Volume : 11 },
999
1008
}, volumes .Volumes )
1000
1009
})
1001
1010
1002
- t .Run ("with matchers" , func (t * testing.T ) {
1011
+ t .Run ("with matchers it returns intersecting labels " , func (t * testing.T ) {
1003
1012
instance := prepareInstance (t )
1004
1013
volumes , err := instance .GetVolume (context .Background (), & logproto.VolumeRequest {
1005
1014
From : 0 ,
1006
1015
Through : 1.1 * 1e3 , //milliseconds
1007
- Matchers : `{log_stream="dispatcher "}` ,
1008
- Limit : 3 ,
1016
+ Matchers : `{log_stream="worker "}` ,
1017
+ Limit : 5 ,
1009
1018
AggregateBy : seriesvolume .Labels ,
1010
1019
})
1011
1020
require .NoError (t , err )
1012
1021
1013
1022
require .Equal (t , []logproto.Volume {
1014
- {Name : `log_stream` , Volume : 90 },
1023
+ {Name : `host` , Volume : 88 },
1024
+ {Name : `log_stream` , Volume : 88 },
1025
+ {Name : `job` , Volume : 70 },
1026
+ {Name : `foo` , Volume : 18 },
1015
1027
}, volumes .Volumes )
1028
+
1029
+ require .NotContains (t , volumes .Volumes , logproto.Volume {Name : `fizz` , Volume : 11 })
1016
1030
})
1017
1031
1018
1032
t .Run ("excludes streams outside of time bounds" , func (t * testing.T ) {
@@ -1021,7 +1035,7 @@ func TestInstance_Volume(t *testing.T) {
1021
1035
From : 5 ,
1022
1036
Through : 1.1 * 1e3 , //milliseconds
1023
1037
Matchers : "{}" ,
1024
- Limit : 3 ,
1038
+ Limit : 5 ,
1025
1039
AggregateBy : seriesvolume .Labels ,
1026
1040
})
1027
1041
require .NoError (t , err )
@@ -1045,7 +1059,7 @@ func TestInstance_Volume(t *testing.T) {
1045
1059
require .NoError (t , err )
1046
1060
1047
1061
require .Equal (t , []logproto.Volume {
1048
- {Name : `host` , Volume : 171 },
1062
+ {Name : `host` , Volume : 189 },
1049
1063
}, volumes .Volumes )
1050
1064
})
1051
1065
@@ -1056,14 +1070,14 @@ func TestInstance_Volume(t *testing.T) {
1056
1070
From : 0 ,
1057
1071
Through : 1.1 * 1e3 , //milliseconds
1058
1072
Matchers : `{}` ,
1059
- Limit : 3 ,
1073
+ Limit : 5 ,
1060
1074
TargetLabels : []string {"host" },
1061
1075
AggregateBy : seriesvolume .Labels ,
1062
1076
})
1063
1077
require .NoError (t , err )
1064
1078
1065
1079
require .Equal (t , []logproto.Volume {
1066
- {Name : `host` , Volume : 171 },
1080
+ {Name : `host` , Volume : 189 },
1067
1081
}, volumes .Volumes )
1068
1082
})
1069
1083
@@ -1073,7 +1087,7 @@ func TestInstance_Volume(t *testing.T) {
1073
1087
From : 0 ,
1074
1088
Through : 1.1 * 1e3 , //milliseconds
1075
1089
Matchers : `{log_stream="dispatcher"}` ,
1076
- Limit : 3 ,
1090
+ Limit : 5 ,
1077
1091
TargetLabels : []string {"host" },
1078
1092
AggregateBy : seriesvolume .Labels ,
1079
1093
})
@@ -1090,7 +1104,7 @@ func TestInstance_Volume(t *testing.T) {
1090
1104
From : 0 ,
1091
1105
Through : 1.1 * 1e3 , //milliseconds
1092
1106
Matchers : `{log_stream=~".+"}` ,
1093
- Limit : 3 ,
1107
+ Limit : 5 ,
1094
1108
TargetLabels : []string {"host" , "job" },
1095
1109
AggregateBy : seriesvolume .Labels ,
1096
1110
})
0 commit comments