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

support multiple values per point #44

Open
go-oleg opened this issue Feb 4, 2016 · 5 comments
Open

support multiple values per point #44

go-oleg opened this issue Feb 4, 2016 · 5 comments

Comments

@go-oleg
Copy link
Contributor

go-oleg commented Feb 4, 2016

All views in JuttleViz that have an understanding of a valueField allow only one of them per point.

When working with data in juttle, it is pretty common to end up with points that have multiple values each.

For example,

emit -limit 100 -from :0:
| put value = count()
| reduce -every :10m: sum=sum(value), min=min(value), max=max(value)

┌────────────────────────────────────┬──────────┬──────────┬──────────┐
│ time                               │ max      │ min      │ sum      │
├────────────────────────────────────┼──────────┼──────────┼──────────┤
│ 1970-01-01T00:10:00.000Z           │ 100      │ 1        │ 5050     │
└────────────────────────────────────┴──────────┴──────────┴──────────┘

In this case each point ends up with three values. The current expected way of sending this data into a timechart is to first call split:

emit -limit 100 -from :0:
| put value = count()
| reduce sum=sum(value), min=min(value), max=max(value)
| split
// | view timechart

┌────────────────────────────────────┬──────────┬──────────┐
│ time                               │ name     │ value    │
├────────────────────────────────────┼──────────┼──────────┤
│ 1970-01-01T00:10:00.000Z           │ sum      │ 5050     │
├────────────────────────────────────┼──────────┼──────────┤
│ 1970-01-01T00:10:00.000Z           │ min      │ 1        │
├────────────────────────────────────┼──────────┼──────────┤
│ 1970-01-01T00:10:00.000Z           │ max      │ 100      │
└────────────────────────────────────┴──────────┴──────────┘

This breaks each point into one point containing one of the values in the value field and original field name in the name field. It now has one value per point just like timechart expects.

The downside of having to call split before sending the points to view timechart is you end up sending a lot more points/data from the juttle-engine to your browser.

The proposal is to add multi-valueField support to timechart and the rest of the applicable views.

Default Behavior

Right now, if no -valueField is specified, the views look for the first numeric field they can find in the first point, and use that. The new behavior here would be that if theres more than one numeric field, it'll do the equivalent of calling split internally, creating a separate point for each value, assigning the value into value and the original value's field name into name. If there already existed a field called name in the point, it would get clobbered, but I think thats somewhat of an edge case. If points already contain a field called name, then it prolly is the name of the metric/value and there is only one value in the point to begin with.

Customizing the Behavior

If by chance a points have more numeric fields than a user wants to plot, they can still explicitly specify -valueField 'sum' or multiple -valueFields ['sum', 'min']. It would be good to just standardize on -valueFields, but that would be a pretty major breaking change so to begin, we should introduce -valueFields alongside -valueField.

@go-oleg
Copy link
Contributor Author

go-oleg commented Feb 9, 2016

cc @demmer @dmehra @jadbox

@dmehra
Copy link

dmehra commented Feb 10, 2016

Let's specify expected behavior if the user does

reduce max(v), min(v), avg(v) by type | view timechart

Perhaps nothing sensible can possibly happen, but we should have definition for this case.
Otherwise +1 to the proposal

@go-oleg
Copy link
Contributor Author

go-oleg commented Feb 10, 2016

@dmehra, the generated series would be

name: max, type: type1
name: min, type: type1
name: avg, type: type1
name: max, type: type2
name: min, type: type2
name: avg, type: type2
...

(assuming its reduce -every)

@dmehra
Copy link

dmehra commented Feb 10, 2016

What's the name of an individual series in the resulting timechart? Is "name: max, type: type1" the name?

@go-oleg
Copy link
Contributor Author

go-oleg commented Feb 10, 2016

@dmehra, yes.

Another option would be something like

type: type1 (max)

or just

type1 (max)

But these are introducing new concepts.

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