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