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