-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Move Lens attribute builder to a package #163422
Move Lens attribute builder to a package #163422
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
911a950
to
a6c664b
Compare
@elasticmachine merge upstream |
Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations) |
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a ton!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a quick look at the API described in the Readme.md
for both chart and attributes builder, and I was wondering whether it make sense to move the formulaAPI
to the main level, instead of the layer level:
const metricChart = new MetricChart({
layers: new MetricLayer({
data: {
label: 'Disk Read Throughput',
value: "counter_rate(max(system.diskio.read.count), kql='system.diskio.read.count: *')",
format: {
id: 'bytes',
params: {
decimals: 1,
},
},
},
}),
formulaAPI,
dataView,
});
or
const builder = new LensAttributesBuilder({
visualization: new MetricChart({
layers: new MetricLayer({
data: {
label: 'Disk Read Throughput',
value: "counter_rate(max(system.diskio.read.count), kql='system.diskio.read.count: *')",
format: {
id: 'bytes',
params: {
decimals: 1,
},
},
},
}),
dataView,
}),
formulaAPI,
});
const lensAttributes = builder.build();
<EmbeddableComponent
attributes={lensAttributes}
viewMode={ViewMode.VIEW}
...
/>
that would make the layer API a little bit less verbose and handles the "formula" complexity internally without have the consumer to think about what type of column it has passed and which dependency it might require.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💯 (Infra changes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose few changes here before proceed.
Not too many, and I've already a branch with all of them implemented as reference if helpful:
- Add a note at the beginning of the README to make it clear that it's still a work in progress and only XY and Metric charts are (partially) covered.
- for any
*Layer
configuration object I would add atype
prop, which contains the type of dimension operation. Currently it will only accept"formula"
. - Make the default
date_histogram
for XY become optional and add a newbuckets
property to theXYLayerOptions
type which will support all 4 bucketed column types in Lens.- the XY layer series
color
wasn't working for me, but it should - the Metric series
color
wasn't working for me, but I think it should andbackgroundColor
could be removed instead - the
FormulaConfig['format']
property should not be mandatory
- the XY layer series
--- end of required changes ---
Some nice to have (but not blocking changes):
- each layer can have a
dataView
prop to override the "chart" one - both
buckets
andbreakdown
configurations could accept (optional)params
as defined by its respective Lens column definition (useful to tweak some configuration) andgetHistogramColumn
andgetTopValuesColumn
should handle that. - not sure why
line
has been chosen as default XY series type (in Lens is thebar_stacked
) here. Is there a strong argument to change it? - why the
LensAttributesBuilder
accepts an object with only a singlevisualization
prop in it? Is it designed to support more arguments there?
I've implemented 90% of both lists in this branch already if you want to use as reference: https://github.com/crespocarlos/kibana/compare/move-attribute-builder-to-package...dej611:kibana:review/163422?expand=1
I've tested this PR against the Lens embeddable example
and with these changes it could replace most of custom code there.
Thanks for your review @dej611 and for the changes made in your branch - it will save a lot of time
OK!
Could you please elaborate? Can a layer be anything other than a
Will check the above.
Should we concern about number of available configuration options that
That's because it's what we're using in infra-ui. No strong reasons.
I had other ideas of parameters for the |
It can, but in the current implementation only To be clear I'm talking about this: new MetricLayer({
data: {
type: 'formula', // <= this tagged property here
label: 'Disk Read Throughput',
value: "counter_rate(max(system.diskio.read.count), kql='system.diskio.read.count: *')",
format: {
id: 'bytes',
params: {
decimals: 1,
},
},
},
}),
I'm not necessarily against that, instead quite open to ideas here.
I would say no as usually the |
@crespocarlos @dej611 My 2 cents: let's keep it opinionated. If Marco doesn't feel comfortable with this API we can also clearly mark it as an infra/Observability thing. I think we should specifically avoid making this generic, it defeats the purpose. |
As this is important to be merged today as it is blocking other PR to be merged before the FF let's do the following and merge:
We are going to work on our own generic api in a next minor |
Agree with it being somewhat opinionated. There are many different parameters that can be used and I would be ok with the API making some decisions. It does still leave the door open for customizations.
I have already implemented the changes. The only thing that needs to be reverted is the example app. I'll update the readme. |
@stratoula, qq:
Is it possible that when your solution is done, it can replace this one? In the end, I think it's beneficial that we all use a single solution to solve this problem. |
@crespocarlos this is the goal yes! We are just not sure at this point if the same api can be used, we might create a new one (at the same package), move the ownership to us, and change the consumers of the existing api to use the new one. |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
History
To update your PR or re-run it, just comment with: |
closes #163491
Summary
This PR creates a new package that contains a utility API that helps to generate the JSON with the attributes required to render a Lens chart with the
EmbeddableComponent
.