Wojtas.Zet
Wojtas.Zet

Reputation: 816

influxdb - order of columns

I am writing measurement to influxdb with InfluxDBClient library

entry = [{
            "time": int((self.end)),
            "measurement": "measurement1",
            "fields": {
                "eventId": self.eventId,
                "start": self.start,
                "end": self.end,
                "lifetime": self.lifetime,
            },

I have noticed that the db is not respecting given order of columns, instead the time is first and then column names in alphabetical order

>SELECT * FROM "measurement1" 
time end eventId hostName lifetime start

How to enforce order given in entry?

Upvotes: 0

Views: 457

Answers (1)

robert
robert

Reputation: 8717

If your using InfluxQL there is no option to sort the results other than the time field

If you are using flux in then it possible to sort the query results.

from(bucket:"db/rp")
  |> range(start:-12h)
  |> filter(fn: (r) =>
    r._measurement == "system" and
    r._field == "uptime"
  )
  |> sort(columns:["region", "host", "_value"])

Upvotes: 1

Related Questions