Here's a simplified example. I run a business with 2 locations. I have a daily document in an index that stores the number of employees in that location.
Now, I'd like to have a dashboard that shows a legacy metric for the number of employees, which would be the "Last Value". That works great, until...
I'd like to add a Control to the dashboard so I can select which location I'm viewing. If I select one location, it still works fine. However, if I select two locations (you know, to see my entire business), it still picks a single "Last Value" (i.e. whichever location was added last).
Is there a way to allow the control to properly affect the metric - to create a sum(Last Value)?
I think you want to use the Collapse option in Lens where you define a criteria to break your metric and then put the values all together again, but for this you need to use the new metric.
Sample data for my test:
# Create the index
PUT discuss-352807
{
"mappings": {
"properties": {
"timestamp": { "type": "date"},
"location": { "type": "keyword"},
"employees": { "type": "integer"}
}
}
}
# Add three days of data for two locations
POST discuss-352807/_bulk
{ "index": {}}
{"timestamp": "2024-02-05", "location": "A", "employees": 10}
{ "index": {}}
{"timestamp": "2024-02-05", "location": "B", "employees": 5}
{ "index": {}}
{"timestamp": "2024-02-06", "location": "A", "employees": 12}
{ "index": {}}
{"timestamp": "2024-02-06", "location": "B", "employees": 8}
{ "index": {}}
{"timestamp": "2024-02-08", "location": "A", "employees": 14}
{ "index": {}}
{"timestamp": "2024-02-08", "location": "B", "employees": 11}
# Create a data view
POST kbn:/api/data_views/data_view
{
"data_view": {
"title": "discuss-352807",
"timeFieldName": "timestamp"
}}
That worked for the non-legacy metric. Thanks. Hopefully the users won't complain about the UI.
Now that I might be able to use the control on my dashboard, I have other visualizations that also aren't working (area stacked, for one). It seems that best practice is to open another topic?
Yeah, please; the best practice is to do some research here for related questions, then open a new topic with as much detail as possible. Also, providing a reproducible example (as I did with the console commands) helps a lot in assisting you.
Mind also that at Elastic, engineers rotate to review the forums so it is very likely I won't be the person reading the new topics over the following days
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.