summaryrefslogtreecommitdiffstats
path: root/src/plugins/influxdb.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-04-17 10:23:07 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-07-10 23:41:14 +0200
commit4b6d97da2d4bc1a9e328cf861e75f5ee1bb968e3 (patch)
tree5d05a7fef6ddb17ec938dd9959ed33b856cfb607 /src/plugins/influxdb.c
parent5d50f0426699a06b5720e10f1feaef35c8b59f57 (diff)
Fully handle array of metrics to be writen in DB
Move a function code. Change-Id: I35a90e08e7019e634676915858aa0a666d46f711 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/plugins/influxdb.c')
-rw-r--r--src/plugins/influxdb.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/plugins/influxdb.c b/src/plugins/influxdb.c
index b8a733b..c33d167 100644
--- a/src/plugins/influxdb.c
+++ b/src/plugins/influxdb.c
@@ -93,20 +93,17 @@ void unpacking_from_api(void *s, json_object *valueJ, const char *key)
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->series_columns.tags, key, valueJ);
+ add_elt(&serie->serie_columns.tags, key, valueJ);
else if(strncasecmp(&key[key_length-2], "_f", 2) == 0)
- add_elt(&serie->series_columns.fields, key, valueJ);
+ add_elt(&serie->serie_columns.fields, key, valueJ);
}
-int unpack_metric_from_api(json_object *m, struct series_t **serie)
+int unpack_metric_from_api(json_object *m, struct series_t *serie)
{
- *serie = malloc(sizeof(struct series_t));
- bzero(*serie, sizeof(struct series_t));
+ wrap_json_object_for_all(m, unpacking_from_api, serie);
- wrap_json_object_for_all(m, unpacking_from_api, *serie);
-
- if(!(*serie)->timestamp)
- (*serie)->timestamp = get_ts();
+ if(!serie->timestamp)
+ serie->timestamp = get_ts();
return 0;
}