aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/influxdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/influxdb.c')
-rw-r--r--src/plugins/influxdb.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/influxdb.c b/src/plugins/influxdb.c
index b8f85d2..f2f8fe1 100644
--- a/src/plugins/influxdb.c
+++ b/src/plugins/influxdb.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 "IoT.bzh"
+ * Copyright (C) 2018-2019 "IoT.bzh"
* Author "Romain Forlot" <romain.forlot@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -133,18 +133,25 @@ void unpacking_from_api(void* s, json_object* valueJ, const char* key)
/* Treat the 2 static key that could have been specified */
if (strcasecmp("name", key) == 0)
serie->name = json_object_get_string(valueJ);
+
else if (strcasecmp("timestamp", key) == 0)
serie->timestamp = (json_object_is_type(valueJ, json_type_int)) ? json_object_get_int64(valueJ) : 0;
+
+ // metadata (AKA tags) are indexed into influxdb
else if (strcasecmp("metadata", key) == 0)
wrap_json_object_for_all(valueJ, unpack_metadata, (void*)&serie->serie_columns.tags);
+
+ // value (AKA fields) are NOT indexed into influxdb
else if (strcasecmp("value", key) == 0 || strcasecmp("values", key) == 0)
wrap_json_object_for_all(valueJ, unpack_values, (void*)&serie->serie_columns.fields);
+
/* Treat all key looking for tag and field object. Those ones could be find
with the last 2 character. '_t' for tag and '_f' that are the keys that
could be indefinite. Cf influxdb documentation:
https://docs.influxdata.com/influxdb/v1.5/write_protocols/line_protocol_reference/ */
else if (strncasecmp(&key[key_length - 2], "_t", 2) == 0)
add_elt(&serie->serie_columns.tags, key, "", valueJ);
+
else if (strncasecmp(&key[key_length - 2], "_f", 2) == 0)
add_elt(&serie->serie_columns.fields, key, "", valueJ);
}