I'm not sure what I did wrong, but Kibana Lenses aren't showing me the nested field inventory.equipment. In terms of what I did, I set up an index and added a document with this script:
Thanks @Marco_Liberati , your other alternative to use vega instead of kibana lens also worked great. It was:
{
/*
Welcome to Vega visualizations. Here you can design your own dataviz from scratch using a declarative language called Vega, or its simpler form Vega-Lite. In Vega, you have the full control of what data is loaded, even from multiple sources, how that data is transformed, and what visual elements are used to show it. Use help icon to view Vega examples, tutorials, and other docs. Use the wrench icon to reformat this text, or to remove comments.
This example graph shows the document count in all indexes in the current time range. You might need to adjust the time filter in the upper right corner.
*/
$schema: https://vega.github.io/schema/vega-lite/v5.json
title: Average Price per instrument
// Define the data source
data: {
url: {
// Which index to search
index: warehouse
// Aggregate data by the time field into time buckets, counting the number of documents in each bucket.
body: {
"aggs": {
"inventory": {
"nested": {
"path": "inventory"
},
"aggs": {
"equip": {
"terms": {
"field": "inventory.equipment.keyword"
},
"aggs": {
"avg_price": {
"avg": {
"field": "inventory.price"
}
}
}
}
}
}
}
// Speed up the response by only including aggregation results
size: 0
}
}
/*
For our graph, we only need the list of bucket values. Use the format.property to discard everything else.
*/
format: {property: "aggregations.inventory.equip.buckets"}
}
// "mark" is the graphics element used to show our data. Other mark values are: area, bar, circle, line, point, rect, rule, square, text, and tick. See https://vega.github.io/vega-lite/docs/mark.html
mark: bar
// "encoding" tells the "mark" what data to use and in what way. See https://vega.github.io/vega-lite/docs/encoding.html
encoding: {
x: {
// The "key" value is the timestamp in milliseconds. Use it for X axis.
field: key
type: ordinal
axis: {title: "Instrument"} // Customize X axis format
}
y: {
// The "doc_count" is the count per bucket. Use it for Y axis.
field: avg_price.value
type: quantitative
axis: {title: "Average Price"}
}
}
}
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.