@cryptotaxi247 / netdata-1 / commits / c178805fc

added opentsdb host tags option; fixes #2217

Costa Tsaousis (ktsaou) committed May 22, 2017 at 23:41 UTC c178805fc8883ae6dbfe3c6c1eba4e5955197395
1 file changed +12 -2
src/backends.c
+12 -2
@@ -193,6 +193,8 @@ static inline int process_graphite_response(BUFFER *b) {
193 // ----------------------------------------------------------------------------
194 // opentsdb backend
195
196 +static const char *opentsdb_host_tags = NULL;
197 +
198 static inline int format_dimension_collected_opentsdb_telnet(
199 BUFFER *b // the buffer to write data to
200 , const char *prefix // the prefix to use
@@ -211,13 +213,15 @@ static inline int format_dimension_collected_opentsdb_telnet(
213
214 buffer_sprintf(
215 b
214 - , "put %s.%s.%s %u " COLLECTED_NUMBER_FORMAT " host=%s\n"
216 + , "put %s.%s.%s %u " COLLECTED_NUMBER_FORMAT " host=%s%s%s\n"
217 , prefix
218 , st->id
219 , rd->id
220 , (uint32_t)rd->last_collected_time.tv_sec
221 , rd->last_collected_value
222 , hostname
223 + , (opentsdb_host_tags)?" ":""
224 + , (opentsdb_host_tags)?opentsdb_host_tags:""
225 );
226
227 return 1;
@@ -242,13 +246,15 @@ static inline int format_dimension_stored_opentsdb_telnet(
246
247 buffer_sprintf(
248 b
245 - , "put %s.%s.%s %u " CALCULATED_NUMBER_FORMAT " host=%s\n"
249 + , "put %s.%s.%s %u " CALCULATED_NUMBER_FORMAT " host=%s%s%s\n"
250 , prefix
251 , st->id
252 , rd->id
253 , (uint32_t) before
254 , value
255 , hostname
256 + , (opentsdb_host_tags)?" ":""
257 + , (opentsdb_host_tags)?opentsdb_host_tags:""
258 );
259
260 return 1;
@@ -475,6 +481,10 @@ void *backends_main(void *ptr) {
481 default_port = 4242;
482 backend_response_checker = process_opentsdb_response;
483
484 + const char *tags = config_get(CONFIG_SECTION_BACKEND, "opentsdb host tags", "");
485 + if(tags && *tags)
486 + opentsdb_host_tags = tags;
487 +
488 if(options & BACKEND_SOURCE_DATA_AS_COLLECTED)
489 backend_request_formatter = format_dimension_collected_opentsdb_telnet;
490 else