Sepehr roosta
Sepehr roosta

Reputation: 597

How to export a json file from a specific Influxdb database?

I have an influxdb database named metrics, I want to export it as a JSON file with its entire data.

directory = '/var/lib/influxdb/data'

I can save the list of tag keys:

influx -execute='show tag keys' -database=metrics -format=json -pretty=true > /home/ivms/metrics.json

but how can I save all tags with all values?

Upvotes: 4

Views: 2340

Answers (1)

jimis
jimis

Reputation: 892

The query to return all data from all measurements in the database, including both fields and tags, would be:

SELECT * FROM /.*/

The full command line:

influx -database=metrics -format=json -pretty=true  \
    -execute='SELECT * FROM /.*/'  \
    > ~/metrics.json

NOTE:

If your database is complicated (millions of series) you might have to wait a long time for influx to actually respond, in my case it was almost 30min but it worked.

Also Make sure you give the system a large enough swap, to avoid getting OOM killed.

Upvotes: 2

Related Questions