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

Cosmetic CLI output fixes #1908

Merged
merged 13 commits into from
Mar 12, 2015
Merged

Cosmetic CLI output fixes #1908

merged 13 commits into from
Mar 12, 2015

Conversation

corylanou
Copy link
Contributor

This fixes the following types of queries:

FROM:

> select * from cpu
name    tags    time                            value
----    ----    ----                            -----
cpu             2015-01-26T22:01:11.703Z        100
cpu             2015-01-27T22:01:11.703Z        100
cpu             2015-01-28T22:01:11.703Z        100

TO:

> select * from cpu
name    time                            value
----    ----                            -----
cpu     2015-01-26T22:01:11.703Z        100
cpu     2015-01-27T22:01:11.703Z        100
cpu     2015-01-28T22:01:11.703Z        100

FROM:

> show series
name    tags    id      host
----    ----    --      ----
cpu             1       server01
----    ----    --      ----
mem             2       server01

TO:

> show series
name    id      host
----    --      ----
cpu     1       server01
name    id      host
----    --      ----
mem     2       server01

FROM:

> show databases
name    tags    name
----    ----    ----
                foo

TO:

> show databases
name
----
foo

@otoolep
Copy link
Contributor

otoolep commented Mar 10, 2015

In the first example, there are no more tags? And how does it look if there is more than 1 value? Can you show that?

@corylanou
Copy link
Contributor Author

with tags:

> select * from temp group by *
name    tags                            time                            value
----    ----                            ----                            -----
temp    host=server01,region=useast     2015-02-27T22:01:11.703Z        101.1
name    tags                            time                            value
----    ----                            ----                            -----
temp    region=uswest,host=server01     2015-02-26T22:01:11.703Z        98.6
name    tags                            time                            value
----    ----                            ----                            -----
temp    host=server02,region=useast     2015-02-28T22:01:11.703Z        105.4

with multiple values:

> select * from network
name    time                            tx      rx
----    ----                            --      --
network 2015-02-26T22:01:11.703Z        9804    2342
network 2015-02-27T22:01:11.703Z        7930    4324
network 2015-02-28T22:01:11.703Z        8234    2342

}
// Output a line seperator if we have more than one set or results
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 'separator' is misspelled. And should it be "...of results"?

@otoolep
Copy link
Contributor

otoolep commented Mar 10, 2015

I like the output changes, though I have some minor feedback on the code. Once that is addressed, +1 from me.

@corylanou
Copy link
Contributor Author

Ok, so based on feedback, I have made quite a few changes to the column format output. I left the csv format in tact if we need it for future (which I think makes sense as you would be able to use this in a non-interactive mode to get results).

Here are the new examples:

> show databases
name
foo

> show series
cpu
---
id
1

mem
---
id      host
2       server01
3       server02

network
-------
id      host            region
7       server01        uswest
8       server01        useast
9       server02        useast

temp
----
id      host            region
4       server01        uswest
5       server01        useast
6       server02        useast

> show measurements
measurements
------------
name
cpu
mem
network
temp
> select * from cpu
cpu
---
time                            value
2015-02-26T22:01:11.703Z        8.9
2015-02-27T22:01:11.703Z        1.3
2015-02-28T22:01:11.703Z        50.4

> select * from temp group by *
temp
----------------------------------
tags: host=server01, region=useast
----------------------------------
time                            value
----                            -----
2015-02-27T22:01:11.703Z        101.1

temp
----------------------------------
tags: host=server01, region=uswest
----------------------------------
time                            value
----                            -----
2015-02-26T22:01:11.703Z        98.6

temp
----------------------------------
tags: host=server02, region=useast
----------------------------------
time                            value
----                            -----
2015-02-28T22:01:11.703Z        105.4

cc @otoolep @pauldix

@corylanou corylanou self-assigned this Mar 11, 2015
@otoolep
Copy link
Contributor

otoolep commented Mar 11, 2015

Is this still open to feedback? Because I think the output from select * from temp group by * is still too hard to read. There are too much use of '-----', which means it's hard to quickly see what is grouped with what. My eyes keep being drawn to what is surrounded by --- so it looks like tags is the section title, not the measurement name. How about the simplified version below?

> select * from temp group by *
temp
tags: host=server01, region=useast
time                            value
----                            -----
2015-02-27T22:01:11.703Z        101.1

temp
tags: host=server01, region=uswest
time                            value
----                            -----
2015-02-26T22:01:11.703Z        98.6

temp
tags: host=server02, region=useast
time                            value
----                            -----
2015-02-28T22:01:11.703Z        105.4

@otoolep
Copy link
Contributor

otoolep commented Mar 11, 2015

Or:

> select * from temp group by *
measurement: temp
tags: host=server01, region=useast
time                            value
----                            -----
2015-02-27T22:01:11.703Z        101.1

measurement: temp
tags: host=server01, region=uswest
time                            value
----                            -----
2015-02-26T22:01:11.703Z        98.6

measurement: temp
tags: host=server02, region=useast
time                            value
----                            -----
2015-02-28T22:01:11.703Z        105.4

This form has the advantage of helping our users understand the term 'measurement', as used within our system.

@corylanou
Copy link
Contributor Author

That format was proposed by @pauldix . I'll let you guys come to consensus. FWIW, I think I like less lines per what @otoolep proposes.

As for

measurement: temp

I don't always now that row.Name is a measurement name, as sometimes it isn't.

@otoolep
Copy link
Contributor

otoolep commented Mar 11, 2015

OK, if row.Name is not always a measurement, then scrap that idea.

@corylanou
Copy link
Contributor Author

What if we did:

> select * from temp group by *
name: temp
tags: host=server01, region=useast
time                            value
----                            -----
2015-02-27T22:01:11.703Z        101.1


name: temp
tags: host=server01, region=uswest
time                            value
----                            -----
2015-02-26T22:01:11.703Z        98.6


name: temp
tags: host=server02, region=useast
time                            value
----                            -----
2015-02-28T22:01:11.703Z        105.4

And if we clean up some inconsistencies in responses for things that don't need names, like show databases or show measurements it will actually work out quite nicely.

@otoolep
Copy link
Contributor

otoolep commented Mar 11, 2015

Can you show a couple more examples? How does stuff like count look?

@corylanou
Copy link
Contributor Author

@otoolep latest outputs:

> show databases
name
foo

> show series
name: cpu
---------
id
1


name: mem
---------
id      host
2       server01
3       server02


name: network
-------------
id      host            region
7       server01        uswest
8       server01        useast
9       server02        useast


name: temp
----------
id      host            region
4       server01        uswest
5       server01        useast
6       server02        useast

> show measurements
name: measurements
------------------
name
cpu
mem
network
temp

> select * from temp group by *
name: temp
tags: host=server01, region=useast
time                            value
----                            -----
2015-02-27T22:01:11.703Z        101.1


name: temp
tags: host=server01, region=uswest
time                            value
----                            -----
2015-02-26T22:01:11.703Z        98.6


name: temp
tags: host=server02, region=useast
time                            value
----                            -----
2015-02-28T22:01:11.703Z        105.4

> select count(value) from cpu
name: cpu
---------
time                    count
1970-01-01T00:00:00Z    3

@corylanou
Copy link
Contributor Author

I think we are as far as we are going to get on this for now. It fixes several output format bugs, and has improved greatly from what it was. We can come back later to tweak further at a future date.

@toddboom
Copy link
Contributor

@corylanou rad, can you rebase and push? i'll merge it in.

@toddboom
Copy link
Contributor

@corylanou nevermind. ;)

@pauldix
Copy link
Member

pauldix commented Mar 12, 2015

@corylanou latest looks rad, 🚢 while it's hot!

@toddboom toddboom merged commit b0be24b into master Mar 12, 2015
@toddboom toddboom removed the review label Mar 12, 2015
@toddboom toddboom deleted the cli-output-fixes branch March 12, 2015 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants