Allow multiples fields ( end with _value )
This commit is contained in:
@@ -25,7 +25,7 @@ public class Parser extends TailerListenerAdapter {
|
||||
private String metricLine = "";
|
||||
String tagName = null;
|
||||
String tagValue = null;
|
||||
String value = null;
|
||||
String field = null;
|
||||
private Log log = Log.getLogger(Parser.class.getName());
|
||||
private Random randomGenerator = new Random();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Parser extends TailerListenerAdapter {
|
||||
sb.append(metricLine);
|
||||
tagName = null;
|
||||
tagValue = null;
|
||||
value = null;
|
||||
field = "";
|
||||
|
||||
// iterate on all match pattern
|
||||
boolean hasDate = false;
|
||||
@@ -76,9 +76,12 @@ public class Parser extends TailerListenerAdapter {
|
||||
if ( StringUtils.isAllLowerCase( tagName ) )
|
||||
{
|
||||
tagValue = entry.getValue().toString();
|
||||
// if key name is 'value', it's not a tag, but a field
|
||||
if ( tagName.equalsIgnoreCase("value") ) {
|
||||
value = tagValue;
|
||||
// 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) + " ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -131,9 +134,8 @@ public class Parser extends TailerListenerAdapter {
|
||||
}
|
||||
sb.append(" ");
|
||||
//Field
|
||||
if ( StringUtils.isNumeric(value) ) {
|
||||
sb.append("value=")
|
||||
.append(value);
|
||||
if ( !field.isEmpty() ) {
|
||||
sb.append(field);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user