@@ -31,6 +31,7 @@ type Options struct {
31
31
ShowHiddenMetricsForVersion string
32
32
DisabledMetrics []string
33
33
AllowListMapping map [string ]string
34
+ AllowListMappingManifest string
34
35
}
35
36
36
37
// NewOptions returns default metrics options
@@ -81,6 +82,10 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
81
82
"The map from metric-label to value allow-list of this label. The key's format is <MetricName>,<LabelName>. " +
82
83
"The value's format is <allowed_value>,<allowed_value>..." +
83
84
"e.g. metric1,label1='v1,v2,v3', metric1,label2='v1,v2,v3' metric2,label1='v1,v2,v3'." )
85
+ fs .StringVar (& o .AllowListMappingManifest , "allow-metric-labels-manifest" , o .AllowListMappingManifest ,
86
+ "The path to the manifest file that contains the allow-list mapping. " +
87
+ "The format of the file is the same as the flag --allow-metric-labels. " +
88
+ "Note that the flag --allow-metric-labels will override the manifest file." )
84
89
}
85
90
86
91
// Apply applies parameters into global configuration of metrics.
@@ -97,6 +102,8 @@ func (o *Options) Apply() {
97
102
}
98
103
if o .AllowListMapping != nil {
99
104
SetLabelAllowListFromCLI (o .AllowListMapping )
105
+ } else if len (o .AllowListMappingManifest ) > 0 {
106
+ SetLabelAllowListFromManifest (o .AllowListMappingManifest )
100
107
}
101
108
}
102
109
@@ -122,7 +129,7 @@ func validateAllowMetricLabel(allowListMapping map[string]string) error {
122
129
for k := range allowListMapping {
123
130
reg := regexp .MustCompile (metricNameRegex + `,` + labelRegex )
124
131
if reg .FindString (k ) != k {
125
- return fmt .Errorf ("--allow-metric-labels must has a list of kv pair with format `metricName:labelName=labelValue, labelValue,...`" )
132
+ return fmt .Errorf ("--allow-metric-labels must have a list of kv pair with format `metricName:labelName=labelValue, labelValue,...`" )
126
133
}
127
134
}
128
135
return nil
0 commit comments