To return the result of a query in Influxdb with the "time" column as number

Asked

Viewed 80 times

0

I am doing tests in Influxdb (inside a Docker container) and for that I ran the code below:

# criando a imagem do influxdb
docker run -d --name influxdb -p 8086:8086 influxdb

# acessando o terminal dentro da imagem
docker exec -it influxdb sh

# dentro do terminal no container, eu acesso o CLI do influx
influx

# crio o banco de dados de testes
> create database test

# defino o banco de testes como padrão
> use test

# crio a tabela "foo" e insiro uma coluna "bar" com valor "123"
> insert foo bar=123

# seleciono tudo na tabela "foo" para verificar se foi inserido
> select * from foo

# resultado da seleção
name: foo
time                bar
----                ---
1583928133832191101 123

From this example and, as the influxdb documentation i can return the query result from the browser by accessing the url http://localhost:8086/query?db=test&q=select%20*%20from%20foo but in doing so, the returned result brings the time column with a different formatting:

{
    "results": [
        {
            "statement_id":0,
            "series": [
                {
                    "name": "foo",
                    "columns": [
                        "time",
                        "bar"
                    ],
                    "values":[
                        [
                            "2020-03-11T12:02:13.832191101Z",
                            123
                        ]
                    ]
                }
            ]
        }
    ]
}

If I need the time property in the original format so that it is possible to update the record, what I need to do so that, when accessing this data through the HTTP protocol, the "time" column is returned without formatting?

1 answer

1

Soon after posting the question I found the solution in the documentation. According to her, I can pass the parameter "epoch=ns" so that the column "time" is not formatted, like this:

http://localhost:8086/query?epoch=ns&db=test&q=select%20*%20from%20foo

Browser other questions tagged

You are not signed in. Login or sign up in order to post.