Skip to content

Commit

Permalink
out_influxdb: Handle signed/unsigned integer as influx's integer of t…
Browse files Browse the repository at this point in the history
…hat representation

This is because in their line protocol, it needs to add "i" suffix for
handling a value as an integer:

| Datatype | Element(s)   | Description |
|:--------:|:------------:|:------------|
| Integger | Field values | Signed 64-bit integers (-9223372036854775808 to 9223372036854775807). Specify an integer with a trailing i on the number. Example: 1i |

So, we need to add "i" suffix for signed/unsigned integer values.

ref: https://docs.influxdata.com/influxdb/v1/write_protocols/line_protocol_reference/

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Aug 29, 2024
1 parent d873502 commit bfce9a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/out_influxdb/influxdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ static char *influxdb_format(const char *tag, int tag_len,
}
else if (v->type == MSGPACK_OBJECT_POSITIVE_INTEGER) {
val = tmp;
val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64, v->via.u64);
val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRIu64 "i", v->via.u64);
}
else if (v->type == MSGPACK_OBJECT_NEGATIVE_INTEGER) {
val = tmp;
val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRId64, v->via.i64);
val_len = snprintf(tmp, sizeof(tmp) - 1, "%" PRId64 "i", v->via.i64);
}
else if (v->type == MSGPACK_OBJECT_FLOAT || v->type == MSGPACK_OBJECT_FLOAT32) {
val = tmp;
Expand Down

0 comments on commit bfce9a7

Please sign in to comment.