File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ to use them.
6161
6262 # # Sanitize Tag Names
6363 # # If true, all tag names will have invalid characters replaced with
64- # # underscores that do not match the regex: ^[a-zA-Z_: ][a-zA-Z0-9_: ]*.
64+ # # underscores that do not match the regex: ^[a-zA-Z_][a-zA-Z0-9_]*.
6565 # sanitize_label_names = false
6666
6767 # # Metric Name Label
Original file line number Diff line number Diff line change @@ -208,12 +208,12 @@ func (l *Loki) writeMetrics(s Streams) error {
208208 return nil
209209}
210210
211- // Verify the label name matches the regex [a-zA-Z_: ][a-zA-Z0-9_: ]*
211+ // Verify the label name matches the regex [a-zA-Z_][a-zA-Z0-9_]*
212212func sanitizeLabelName (name string ) string {
213- re := regexp .MustCompile (`^[^a-zA-Z_: ]` )
213+ re := regexp .MustCompile (`^[^a-zA-Z_]` )
214214 result := re .ReplaceAllString (name , "_" )
215215
216- re = regexp .MustCompile (`[^a-zA-Z0-9_: ]` )
216+ re = regexp .MustCompile (`[^a-zA-Z0-9_]` )
217217 return re .ReplaceAllString (result , "_" )
218218}
219219
Original file line number Diff line number Diff line change @@ -620,6 +620,11 @@ func TestSanitizeLabelName(t *testing.T) {
620620 input : "foobar.foobar.2002" ,
621621 expected : "foobar_foobar_2002" ,
622622 },
623+ {
624+ name : "replace colon" ,
625+ input : "foo:bar" ,
626+ expected : "foo_bar" ,
627+ },
623628 }
624629
625630 for _ , tt := range tests {
Original file line number Diff line number Diff line change 2626
2727 ## Sanitize Tag Names
2828 ## If true, all tag names will have invalid characters replaced with
29- ## underscores that do not match the regex: ^[a-zA-Z_: ][a-zA-Z0-9_: ]*.
29+ ## underscores that do not match the regex: ^[a-zA-Z_][a-zA-Z0-9_]*.
3030 # sanitize_label_names = false
3131
3232 ## Metric Name Label
You can’t perform that action at this time.
0 commit comments