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

$columns support multiple columns #33

Closed
wych42 opened this issue Jan 25, 2018 · 2 comments
Closed

$columns support multiple columns #33

wych42 opened this issue Jan 25, 2018 · 2 comments
Assignees

Comments

@wych42
Copy link
Contributor

wych42 commented Jan 25, 2018

The doc has shown an example of $columns:

$columns(OSName, count(*) c) FROM requests

Sometimes, I need to group multi columns to find out differences, such as OS platform and version, I 'm wondering if this usage could be supported:

$columns(key_1, key_2, value) or $columns((key_1, key_2), value)

which query values as array of [key, value], where key will be used as label, and key is a combination of key_1 key_2.

@hagen1778
Copy link
Collaborator

hagen1778 commented Jan 26, 2018

Hi @marlowew
Currently, plugin doesn't support multiple labels or any mechanism to choose between them like it's done in Prometheus datasource.
But you can do it in different way:

$columns(
    concat(toString(Environment), '-', OSName) l,
    count(*) c)
FROM $table
ANY INNER JOIN oses USING  OS

here OSName is querying from separate table oses

So, in the query above you asking ClickHouse to combine your labels and you can choose any combination form you want.

@hagen1778 hagen1778 self-assigned this Jan 26, 2018
@wych42
Copy link
Contributor Author

wych42 commented Jan 26, 2018

The concat way do solve the problem. Thanks.

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

No branches or pull requests

2 participants