M_Chiorboli
(Massimiliano Chiorboli)
March 11, 2022, 11:33am
1
Hello,
I am trying to produce a bar chart in Kibana using Vega.
I use Vega because I have to use nested fields, and it seems there are not other options.
This is my script:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "Event counts from all indexes",
data: {
url: {
%context%: true
%timefield%: timestamp
index: search-sonarqube-telemetry-2021-merged
body: {
"aggs": {
"languages": {
"terms": { "field": "plugins.name.keyword"}
}
}
size: 0
}
}
format: {property: "aggregations.languages.buckets" }
}
mark: bar
encoding: {
x: {
field: buckets.key
type: nominal
axis: { title: null }
}
y: {
field: buckets.doc_count
type: quantitative
axis: { title: "Document count" }
}
}
}
I get the warnings:
Infinite extent for field "buckets.doc_count_start": [Infinity, -Infinity]
Infinite extent for field "buckets.doc_count_end": [Infinity, -Infinity]
and everything is empty.
If I try to debug, I see the source_0 but not the data_0.
What is wrong in my script?
Thanks
M_Chiorboli
(Massimiliano Chiorboli)
March 14, 2022, 11:04am
2
I found the problem.
I defined the property as aggregations.languages.buckets, but the I was defined the fields as buckets.key and buckets.doc_count in the encoding.
It was enough to replace key and doc_count to buckets.key and buckets.doc_count and it worked.
Actually it was not finding the fields because inside aggregations.languages.buckets we don't have a repetition of buckets.
2 Likes
EricPSU
(Eric)
March 18, 2022, 1:56pm
3
Could you post your final code? I don't understand the fix you described. Thanks!
M_Chiorboli
(Massimiliano Chiorboli)
March 18, 2022, 2:14pm
4
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
data: {
name: "aggregations"
url: {
%context%: true
%timefield%: timestamp
index: search-sonarqube-telemetry-*
body: {
"aggs": {
"languages": {
"terms": { "field": "plugins.name.keyword"}
}
}
size: 0
}
}
format: {property: "aggregations.languages.buckets" }
}
encoding: {
y: {
field: "key"
type: nominal
axis: {
title: null
}
sort: {
order: "descending"
}
}
x: {
field: "doc_count"
type: quantitative
axis: { title: "Document count" }
}
}
"config": {
"axisY": {
"labelFontSize": 30
}
"axisX": {
"labelFontSize": 15,
titleFontSize: 20
}
}
"layer": [
{
"mark": {
type: "bar"
},
encoding: {
y: {
field: "key"
type: nominal
axis: {
title: null,
}
sort: {
order: "descending"
}
}
x: {
field: "doc_count"
type: quantitative
axis: { title: "Document counts" }
}
}
},
{
"mark": {
"type": "text",
"align": "right",
"baseline": "middle",
"dx": -20,
fontSize:25,
color: white
},
"encoding": {
"text": {
"field": "doc_count", "type": "quantitative",
"format": ","
}
y: {
field: "key"
type: nominal
axis: {
title: null
}
sort: {
order: "descending"
}
}
x: {
field: "doc_count"
type: quantitative
axis: { title: "Document counts" }
}
}
}
]
}
1 Like
system
(system)
Closed
April 15, 2022, 2:25pm
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.