Elastic deployment version: v7.6.1
I'm trying to create a visualization which gives me the average number of queries per request. So basically what I want to see is:
- GET /users/ => 5 queries
- POST /users/ => 3 queries
- GET /users/:id/books => 555 queries (N+1 query problem)
Our Java backend application is using the Java apm agent and everything works as expected. An example transaction:
Option 1:
I found in the docs that there is a transaction.span_count.started
property which gives me what I need (no all spans are queries, but that's not really an issue). I can also see the property when I check out the doc of the request:
However, this seems to be an unmapped field, so I cannot use it in a visualization. I searched for "No cached mapping for this field" in this forum/Goolge/Github, but none of the solutions worked. This is what I tried:
- Refresh index in Kibana management
- Remove index (it is automatically added again when going to the apm tab)
The field is mentioned in the docs:
But it's missing here:
- https://www.elastic.co/guide/en/apm/server/7.6/exported-fields-apm-transaction.html
- https://github.com/elastic/apm-server/blob/07f35ab548b5338086db2a061a727826359c7166/model/transaction/_meta/fields.yml
Since the apm index is automatically created, I'm not sure if I should change it manually. I noticed that the field is not in the mapping:
"span_count": {
"properties": {
"dropped": {
"type": "long"
}
}
},
And that the transaction mapping is not dynamic:
"transaction": {
"dynamic": "false",
"properties": {
....
So, should I change this mapping manually or is there something missing in apm-server? And if I change it manually, will it be overwritten by apm-server?
Option 2:
Don't use the transaction.span_count.started
field.
In this case, I would need to do something like this:
- count # of spans of with
span.action: query
, group them bytransaction.id
- annotate every transaction with
url.path
(the property is not available on query spans, so I would need to get it somehow from the request span of that transaction) - take the average of the # of spans and group them by
url.path
I'm quite new to Kibana, so I'm not certain how I would achieve this. I was able to create a visualization to get the slowest requests based on the average transaction duration, but that's a single group by.