@@ -39,6 +39,7 @@ public class MetricsOutput implements MessageOutput {
3939 public static final String CK_RUN_RATE = "run_rate" ;
4040 public static final String CK_FIELDS = "fields" ;
4141 public static final String CK_INCLUDE_SOURCE = "include_source" ;
42+ public static final String CK_INCLUDE_TYPE = "include_type" ;
4243
4344 private final AtomicBoolean isRunning = new AtomicBoolean (false );
4445 private Configuration configuration ;
@@ -97,7 +98,7 @@ public void write(Message message) throws Exception {
9798
9899 LOG .trace ("Trying to read field [{}] from message <{}>." , field , message .getId ());
99100 if (!message .getFields ().containsKey (field )) {
100- LOG .error ("Message <{}> does not contain field [{}]. Can not send data to metrics store." , message .getId (), field );
101+ LOG .debug ("Message <{}> does not contain field [{}]:[{}] . Can not send data to metrics store." , message .getId (), field , fieldType );
101102 continue ;
102103 }
103104
@@ -120,7 +121,7 @@ public void write(Message message) throws Exception {
120121 continue ;
121122 }
122123
123- final String metricName = configuration . getBoolean ( CK_INCLUDE_SOURCE ) ? ( message .getSource () + "." + field ) : field ;
124+ final String metricName = getMetricName ( field , fieldType , message .getSource ()) ;
124125
125126 switch (fieldType .toLowerCase ()) {
126127 case "gauge" :
@@ -241,6 +242,13 @@ public ConfigurationRequest getRequestedConfiguration() {
241242 "Metric name will be 'prefix + message source + field name'." )
242243 );
243244
245+ configurationRequest .addField (new BooleanField (
246+ CK_INCLUDE_TYPE ,
247+ "Include field type in metric name" ,
248+ false ,
249+ "Metric name will be 'field name + type'." )
250+ );
251+
244252 return configurationRequest ;
245253 }
246254 }
@@ -258,6 +266,24 @@ public Descriptor() {
258266 }
259267 }
260268
269+ private String getMetricName (String field , String fieldType , String messageSource ) {
270+ String metricName ;
271+
272+ /* prefix message source to metric name */
273+ if (configuration .getBoolean (CK_INCLUDE_SOURCE )) {
274+ metricName = messageSource + "." + field ;
275+ } else {
276+ metricName = field ;
277+ }
278+
279+ /* postfix field type to metric name */
280+ if (configuration .getBoolean (CK_INCLUDE_TYPE )) {
281+ metricName = metricName + "." + fieldType ;
282+ }
283+
284+ return metricName ;
285+ }
286+
261287 private URI parseUrl (String url ) {
262288 URI uri = null ;
263289 try {
0 commit comments