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

Add veneers for panel transformations #243

Open
K-Phoen opened this issue Feb 12, 2024 · 0 comments
Open

Add veneers for panel transformations #243

K-Phoen opened this issue Feb 12, 2024 · 0 comments

Comments

@K-Phoen
Copy link
Member

K-Phoen commented Feb 12, 2024

Transformations can be quite tedious to define. See:

cog/examples/_go/disk.go

Lines 61 to 136 in fa1fbdc

WithTransformation(dashboard.DataTransformerConfig{
Id: "groupBy",
Options: map[string]any{
"fields": map[string]any{
"Value #A": map[string]any{
"aggregations": []string{"lastNotNull"},
"operation": "aggregate",
},
"Value #B": map[string]any{
"aggregations": []string{"lastNotNull"},
"operation": "aggregate",
},
"mountpoint": map[string]any{
"aggregations": []string{},
"operation": "groupby",
},
},
},
}).
WithTransformation(dashboard.DataTransformerConfig{
Id: "merge",
Options: map[string]any{},
}).
WithTransformation(dashboard.DataTransformerConfig{
Id: "calculateField",
Options: map[string]any{
"alias": "Used",
"binary": map[string]any{
"left": "Value #A (lastNotNull)",
"operator": "-",
"reducer": "sum",
"right": "Value #B (lastNotNull)",
},
"mode": "binary",
"reduce": map[string]any{
"reducer": "sum",
},
},
}).
WithTransformation(dashboard.DataTransformerConfig{
Id: "calculateField",
Options: map[string]any{
"alias": "Used, %",
"binary": map[string]any{
"left": "Used",
"operator": "/",
"reducer": "sum",
"right": "Value #A (lastNotNull)",
},
"mode": "binary",
"reduce": map[string]any{
"reducer": "sum",
},
},
}).
WithTransformation(dashboard.DataTransformerConfig{
Id: "organize",
Options: map[string]any{
"excludeByName": map[string]any{},
"indexByName": map[string]any{},
"renameByName": map[string]any{
"Value #A (lastNotNull)": "Size",
"Value #B (lastNotNull)": "Available",
"mountpoint": "Mounted on",
},
},
}).
WithTransformation(dashboard.DataTransformerConfig{
Id: "sortBy",
Options: map[string]any{
"fields": map[string]any{},
"sort": []map[string]any{
{"field": "Mounted on"},
},
},
}).

They could use some veneers to make them easier to discover and use.

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

1 participant