-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphite metrics should clean metrics names #637
Comments
Are there characters other than |
Newlines for sure; they are used as a line separator in the text protocol: http://graphite.readthedocs.org/en/latest/feeding-carbon.html I'd suggest sanitising anything that isn't healthy in a UNIX filename, so any control chars too. |
Is there any status on the desired requirements of this issue? I'd love to help out, I'm just not sure what steps to take. |
This is my static helper class. I got the regex somewhere from the graphite source code. public final class GraphiteSanitizer {
public static final Pattern DISALLOWED_CHARS = Pattern.compile("[^a-zA-Z0-9!#\\$%&\"'\\*\\+\\-:;<=>\\?@\\[\\\\\\]\\^_`\\|~]");
private GraphiteSanitizer() {
}
/**
* Graphite only supports alphanumeric characters + !#$%&"'*+-.:;<=>?@[\]^_`|~ so each metric name segment has to
* be cleared from other chars.
* <p/>
* <pre>
* metric path/segment delimiter
* _|_
* | |
* metrics.cpu.utilisation <- metric name
* | | |
* -------------
* |
* metric name segments
* </pre>
*
* @param metricNameSegment the metric name segment (see diagram above for a explanation of what a metric name segment is)
* @return the metricNameSegment that contains only characters that graphite can handle
*/
public static String sanitizeGraphiteMetricSegment(String metricNameSegment) {
return DISALLOWED_CHARS.matcher(metricNameSegment.replace('.', ':').replace(' ', '-').replace('/', '|')).replaceAll("_");
}
} |
So do people think it would be better to remove the offending metrics or sanitize the names? Should we support both with an option to determine which? If so, what should the default be? |
I believe the default should be to sanitize. There are few worse things than missing a metric when debugging. On Fri, Dec 19, 2014 at 5:46 AM, Tyler Tolley notifications@github.com
|
FYI, I just ran into a bug(?) triggered in Graphite when a metric had a parenthesis in it. Filename was |
Graphite only supports alphanumeric characters + !#$%&"'*+-.:;<=>?@[]^_`|~ |
@felixbarny Thanks! Do you have a reference for this list? As stated in the initial description, |
I've found it somewhere in Graphite's source code. Can't remember where though... |
I've gone with the following regex: [^a-z0-9!#\$%&"'*+-.:;<=>\?@[]^_`|~]+ If there are no objections then I will be releasing 3.1.1 today. |
I think the regex is missing the backslash character ( |
So it is. Thanks! |
Forward slash is legal then? |
No, that's one of the most illegal chars ;) |
With #936 merged, should this be closed? |
Yep looks like it. |
Graphite does not allow metrics/sensors with names containing
'
, but Metrics happily submits them. This makes Graphite log a bunch of errors not being able to create the whisper files yada yada.I see three different solutions to this:
Input welcome.
The text was updated successfully, but these errors were encountered: