Fix issue with '_' as tagName
This commit is contained in:
@@ -14,7 +14,7 @@ import org.apache.commons.cli.ParseException;
|
||||
|
||||
public class Cli {
|
||||
|
||||
public final static String VER = "1.0";
|
||||
public final static String VER = "1.1";
|
||||
public static Options options = new Options();
|
||||
public static Option help = new Option( "help", "Print this message" );
|
||||
public static Option version = new Option( "version", "Print the version information and exit" );
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Parser extends TailerListenerAdapter {
|
||||
sb.append(metricLine);
|
||||
tagName = null;
|
||||
tagValue = null;
|
||||
field = "";
|
||||
field = "value=1";
|
||||
|
||||
// iterate on all match pattern
|
||||
boolean hasDate = false;
|
||||
@@ -73,14 +73,14 @@ public class Parser extends TailerListenerAdapter {
|
||||
{
|
||||
tagName = entry.getKey();
|
||||
// Keep only key with lowercase
|
||||
if ( StringUtils.isAllLowerCase( tagName ) )
|
||||
if ( StringUtils.isAllLowerCase( tagName.replaceAll("_", "") ) )
|
||||
{
|
||||
tagValue = entry.getValue().toString();
|
||||
// if key name end with '_value', it's not a tag, but a field !
|
||||
if ( tagName.endsWith("_value") ) {
|
||||
// check if tag value is not empty
|
||||
if (!tagValue.equalsIgnoreCase("") ) {
|
||||
field += sanitizeString(tagName.replaceAll("_value", "")) + "=" + sanitizeString(tagValue) + " ";
|
||||
field += "," + sanitizeString(tagName.replaceAll("_value", "")) + "=" + sanitizeString(tagValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -134,13 +134,9 @@ public class Parser extends TailerListenerAdapter {
|
||||
}
|
||||
sb.append(" ");
|
||||
//Field
|
||||
if ( !field.isEmpty() ) {
|
||||
|
||||
sb.append(field);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("value=1");
|
||||
}
|
||||
|
||||
// TimeStamp
|
||||
sb.append(" ");
|
||||
if (hasDate){
|
||||
|
||||
Reference in New Issue
Block a user