Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

influx command: parsable output #6896

Closed
phemmer opened this issue Jun 22, 2016 · 5 comments
Closed

influx command: parsable output #6896

phemmer opened this issue Jun 22, 2016 · 5 comments
Assignees
Milestone

Comments

@phemmer
Copy link
Contributor

phemmer commented Jun 22, 2016

Feature Request

Proposal:
The influx command should be able to produce output which can be parsed.
Currently it produces a lot of garbage at the beginning of the output, and prefixes output lines with >.

Current behavior:

# influx -format json <<< 'show databases' 2>/dev/null | cat
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 1.0.0-beta1
InfluxDB shell version: 1.0.0-beta1
> {"results":[{"series":[{"name":"databases","columns":["name"],"values":[["_internal"]]}]}]}
> 

Desired behavior:

# influx -format json <<< 'show databases' | cat
{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["_internal"]]}]}]}

This should either be controlled by a flag, such as -quiet, or by detecting whether STDOUT is a TTY.

Use case:
It is currently very difficult to use the influx command in a script and parse the output because of all the extra noise that it outputs.

@jsternberg
Copy link
Contributor

Have you tried using the -execute flag?

$ influx -execute 'show databases' -format json
{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["stress"],["_internal"],["mydb"]]}]}]}

@phemmer
Copy link
Contributor Author

phemmer commented Jun 22, 2016

Using the -execute flag has a few issues.

  1. it's insecure. If my command is to create a user, or set a user's password, that password is going to show up cleartext for anyone who has access to the box and can run ps.
  2. it's easier to not have to deal with argument quoting
  3. You can't stream the input/output (minor issue to group commands in batches & execute several times, but still rather inconvenient).

@jsternberg
Copy link
Contributor

jsternberg commented Jun 22, 2016

Seems reasonable enough to detect if the input is a TTY and allow something like -import to read from stdin if a file argument isn't provided. As a temporary workaround, you can try writing to a temporary file and executing that.

@phemmer
Copy link
Contributor Author

phemmer commented Jun 22, 2016

I don't see how -import can be used for this. It's easy enough to pass an argument of /dev/stdin, but attempting to do so it spits out errors such as:

2016/06/22 16:10:25 error writing batch:  {"error":"database is required"}

From what I can see, the import format is not meant to be used for running arbitrary statements.
And would import even show the output of statements which generate output?

@jsternberg
Copy link
Contributor

Looks like I'm wrong. -import is used for something else.

I'll mark this as a feature request and we'll add it to the list of things that needs to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants