Closed bahamat closed 3 years ago
That's a good question. To demonstrate this, I mocked up an example that can be linted with promtool.
Here's the example bad text
> { printf '# HELP unescaped_total wtf\n'
printf '# TYPE unescaped_total counter\n'
printf 'unescaped_total{badquote=""quote",badnewline="newline\n",badbackslash="\backslash"} 1\n'
}
# HELP unescaped_total wtf
# TYPE unescaped_total counter
unescaped_total{badquote=""quote",badnewline="newline
",badbackslash=ackslash"} 1
When passing this to promtool, it fails linting
> { printf '# HELP unescaped_total wtf\n'
printf '# TYPE unescaped_total counter\n'
printf 'unescaped_total{badquote=""quote",badnewline="newline\n",badbackslash="\backslash"} 1\n'
} | promtool check metrics
error while linting: text format parsing error in line 3: unexpected end of label value ""
> echo $?
1
And here's the same text, but properly escaped.
> { printf '# HELP escaped_total wtf\n'
printf '# TYPE escaped_total counter\n'
printf 'escaped_total{badquote="\"quote",badnewline="newline\\n",badbackslash="\\\\backslash"} 1\n'
}
# HELP escaped_total wtf
# TYPE escaped_total counter
escaped_total{badquote="\"quote",badnewline="newline\n",badbackslash="\\backslash"} 1
When this is passed to promtool, linting validation succeeds.
> { printf '# HELP escaped_total wtf\n'
printf '# TYPE escaped_total counter\n'
printf 'escaped_total{badquote="\"quote",badnewline="newline\\n",badbackslash="\\\\backslash"} 1\n'
} | promtool check metrics
> echo $?
0
This also brings in the change from #26.