Kibana visualization with two fields from prometheus data


I'm not sure whether this is possible or not but really hoping for some way to use sub-buckets on the Y-axis when doing a visualization. I've got a setup where metric beat collects prometheus metrics from various hosts and what I'd like to create is a visualization of memory used ie heap - nonheap for java processes on each host.

The query for what Im attempting to graph is something along these lines:

    ((prometheus.labels.area:heap) and (prometheus.metrics.jvm_memory_bytes_used: * )) -
    ((prometheus.labels.area:nonheap) and (prometheus.metrics.jvm_memory_bytes_used: * )) 

Trying to graph this however Im finding is challenging because I can't seem to be able to put the area:heap/nonheap anywhere in the visualisation

The grouping I've got on the x-axis sorted by the 'instance _name' label but I'd love to know how to select a double field when doing the graph or directly use the KQL query or if there is some other way to do this


It sounds like you want to fetch two different metrics from your data set and then calculate the difference between them, is that correct?

If yes, check out the TSVB visualization - you can create a match aggregation there and enter a formula operating on other metrics for the same bucket.

That sounds about right, Ive used the TVSB for all the other metrics I want - this one however I cant seem to work out - I didnt see the match aggregator there but I'll have a look again,

I've tried putting in multiple datasets and in each dataset I provide the filter for on/off heap but I cant refer to them in a third dataset to subtract the two

I'll try the match and report back

Just noticed I have a typo in there, sorry for that (typed that on mobile). I was referring to the math aggregation.

But that will only work if the values for the two metrics are in the same document - from your latest post it seems like they are not. If that's the case the math aggregation won't help.

If that's the case could you provide example documents?