Can multidimensional hash values ​​be added to InfluxDB?

In InfluxDB, can you send multidimensional hash values ​​to the database?

For example, this hash:

{
    "field1": "value1",
    "field2": {
        "field2a": "value2a",
        "field3a": "value3a"
    }
}

      

If you can, how do you do it? When I try through the http admin interface, it makes no error or returns success.

+3


source to share


1 answer


Multidimensional values ​​are not supported by InfluxDB. Points have fields that are a collection of key-value pairs. Currently, values ​​can only be float, integer, boolean, or string. InfluxDB has no concept of nested key values. The relevant source is here .

A workaround would be to store the JSON as a string literal by escaping all double quote characters (for example \"

). Then perform whatever functionality is required in the client.



curl -h -XPOST 'http://localhost:8086/write' -d '
{
    "database": "test",
        "retentionPolicy": "default",
        "points": [
            {
                "name": "json_blob",
                "tags": {
                    "tag1": "tag-value-a",
                    "tag2": "tag-value-b"
                },
                "fields": {
                    "value": "{\"field1\":\"value1\",\"field2\":{\"field2a\":\"value2a\",\"field3a\":"value3a\"}}"
            }
        }
    ]
}'

      

0


source







All Articles