How to beautify javascript key that become untidy after passing telegraf?

Hello all, currently i am doing experiment with telegraf and chronograf, i am try publishing message to telegraf in json form that has array of values, after pushing to telegraf and telegraf pushing to chronograf, my values become untidy like “values_10_test.v” in the chronograf field, is there anybody know how to handle this one? thank you

You will probably need to modify the input data format to contain no more than one top level array. If you post your input data and how you want the fields to be formatted I might be able to give some exact advice.

Hi @daniel, thank you for your answer, my input data example like this in json:
{
“values”: [

{“v”: 1} ,

{“t”: 2}

]

and i want the field keep same with input, like v keep v not become value_0_v, vice versa with other, do you know how to solve this one?

Thank you

The easiest option is to add json_query = "values" to the plugin, this will produce each item as a separate metric:

> foo v=1 1566532594000000000
> foo t=2 1566532594000000000

Hi @daniel, i have been try your solution and it works very well! thank you, beside of that i would like to ask when i am would like to create dashboard and use tag, in the diagram of line chart, it still showing like this “mqtt_consumer.v”, how to remove the mqtt_consumer? thank you

I’m a little less familiar with everything Chronograf can do, but I don’t think it is possible. You could change the measurement name in Telegraf though to make it a bit less verbose by using the name_override option with the plugin.

Alright, thank you so much for your help @daniel

Hi @daniel, i would like to ask how to insert custom timestamp to influxdb via telegraf? thank you

You can add the timestamp to each object in the list

{
    "values": [
        {"timestamp": 1567548011, "v": 1},
        {"timestamp": 1567548011, "t": 2}
    ]
}

Add this to the plugin config:

json_time_key = "timestamp"
json_time_format = "unix"

BTW, if you wanted to share the timestamp and only specify it once the input data would need to look like this:

{
    "values": [
        {"timestamp": 1567548011, "v": 1, "t": 2}
    ]
}

Alright, thanks @daniel