diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2019-07-05 09:32:26 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2019-08-01 17:45:11 +0200 |
commit | 132d8131ae287bb0ab148aef545b9337e9703db6 (patch) | |
tree | 557c41a338b210eae081843e7d9d1dd9e7ee54ec /src/plugins/influxdb.c | |
parent | 4bcea9804e13134d2e0f45ae158c17825cff1b76 (diff) |
Add comments and re-ident code
Change-Id: Ibb4636bd968d6e4fd564ab40d5cf59e5a6ec6210
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'src/plugins/influxdb.c')
-rw-r--r-- | src/plugins/influxdb.c | 9 |
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); } |