# Transaction table breakdown granularity

**URL:** <https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [April 15, 2021, 5:03am UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178 "2021-04-15T05:03:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Aracil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javier_aracil/32/87086_2.png) [@Javier\_Aracil](https://discuss.elastic.co/u/Javier_Aracil)\
**Post date:** [April 15, 2021, 5:03am UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/1 "2021-04-15T05:03:33Z")

</div>

Hello everyone,

I am a newbie to Elastic APM, I am currently trying to instrument a great banking application (javascript).

In the [transaction table](https://www.elastic.co/guide/en/kibana/7.12/transactions.html#transactions-table) I get many URLs of the type `POST http: //<server IP>/method` summarized in a single line POST /? .

What can I do to get better granularity in the breakdown of the transaction table?

Thank you very much,

Javier

---

<div class="post-metadata">

**Author:** ![Felix\_Roessel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_roessel/32/41623_2.png) [@Felix\_Roessel](https://discuss.elastic.co/u/Felix_Roessel)\
**Post date:** [April 15, 2021, 6:02am UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/2 "2021-04-15T06:02:25Z")

</div>

Hey @Javier_Aracil  
Welcome to the Community.

Can you check what you see in the Metadata tab? Is there a more useful request name available for you?  
I guess you are using the RUM agent right?  
The data you see highly depends on the JS Framework you are using. Thatswhy we need to check that first.

---

<div class="post-metadata">

**Author:** ![Javier\_Aracil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javier_aracil/32/87086_2.png) [@Javier\_Aracil](https://discuss.elastic.co/u/Javier_Aracil)\
**Post date:** [April 15, 2021, 3:02pm UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/3 "2021-04-15T15:02:55Z")

</div>

Hi Felix,

Thanks, we actually see the transactions in the Metadata tab

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/6/265e8b7a442b5077fee86b321a3f752a44660381.png)

No, not RUM, actually the [nodejs agent](https://www.elastic.co/guide/en/apm/agent/nodejs/current/index.html)

Framework is hapi.

Thanks a lot for your help,

Javier

---

<div class="post-metadata">

**Author:** ![Javier\_Aracil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javier_aracil/32/87086_2.png) [@Javier\_Aracil](https://discuss.elastic.co/u/Javier_Aracil)\
**Post date:** [April 15, 2021, 3:07pm UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/4 "2021-04-15T15:07:31Z")

</div>

Perhaps [this](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#use-path-as-transaction-name) can do the trick?  
Thanks

---

<div class="post-metadata">

**Author:** ![Felix\_Roessel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_roessel/32/41623_2.png) [@Felix\_Roessel](https://discuss.elastic.co/u/Felix_Roessel)\
**Post date:** [April 15, 2021, 5:36pm UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/5 "2021-04-15T17:36:57Z")

</div>

Yes thats the why I was asking

---

<div class="post-metadata">

**Author:** ![Javier\_Aracil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javier_aracil/32/87086_2.png) [@Javier\_Aracil](https://discuss.elastic.co/u/Javier_Aracil)\
**Post date:** [April 21, 2021, 1:58pm UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/6 "2021-04-21T13:58:45Z")

</div>

Hi Felix, it didn´t work, any idea? Thanks

Javier

---

<div class="post-metadata">

**Author:** ![alanstorm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alanstorm/32/77134_2.png) [@alanstorm](https://discuss.elastic.co/u/alanstorm)\
**Post date:** [April 22, 2021, 7:30am UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/7 "2021-04-22T07:30:30Z")

</div>

Hello @Javier_Aracil, it's nice to meet you.

Two things.

First -- you mentioned you're using hapi. When you use hapi with the Node.js agent we'll automatically name the transaction based on the route naming pattern/path. If you can share that, and share the version of hapi that you're using, we'll be better able to diagnose why all your transactions end up with the same `POST /?` name.

Second -- we know that sometimes the default naming of a transaction doesn't meet everyone's needs. Because of that, the agent has an API method that allows you [to name a transaction](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-set-transaction-name). The `apm.setTransactionName(...)` method should allow you to name your own transactions with whatever names you like -- just call this method at the start of your hapi route handling method.

If that gets you fixed up, great. If not, then just share some code (either real or fake) with an example of how you're using hapi to define your routes and what let us know what version of hapi you're using. With that information in hand we'll be better able to diagnose your issue.

---

<div class="post-metadata">

**Author:** ![Javier\_Aracil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javier_aracil/32/87086_2.png) [@Javier\_Aracil](https://discuss.elastic.co/u/Javier_Aracil)\
**Post date:** [May 11, 2021, 10:45am UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/8 "2021-05-11T10:45:50Z")

</div>

Hi @alanstorm ,

I examined the js code and it turns out that routes are declared as follows:

```
server.route({
    method: 'GET',
    path: '/{identifier}',
    handler: (request, h) => {
        const the_identifier = request.params.identifier
        return `Path ${the_identifier}`;
    }
});

```

Then, transactions end up with GET /?, namely:

 ![Captura de pantalla 2021-05-11 a las 12.37.40](https://us1.discourse-cdn.com/elastic/original/3X/8/f/8fd292c8017e48a8a0a3b2dc23c84fce05ae7bae.png)

hapi version is 20.1.2

Any workaround that we can apply for this? Thanks so much,

Javier

---

<div class="post-metadata">

**Author:** ![alanstorm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alanstorm/32/77134_2.png) [@alanstorm](https://discuss.elastic.co/u/alanstorm)\
**Post date:** [May 11, 2021, 5:52pm UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/9 "2021-05-11T17:52:57Z")

</div>

@Javier_Aracil Ah ha! That's just the information we needed. Here's what's going on.

When the agent encounters the following route name

```auto
    path: '/{identifier}',

```

it uses HAPI's `fingerprint` property [to identify the route](https://hapi.dev/api/?v=20.1.2#-requestroute). With fingerprinting, route paramaters are replaced with `?`. That means `path: '/{identifier}',` is represented as `/?`. A route named `path: '/{identifier1}/foo/{identifier1}',` would be represented as `path: '/?/foo/?',`, etc. It's how HAPI wants these routes to be identified -- if HAPI changes how fingerprinting works, the agent will pickup that new behavior automatically.

Based on what you've said so far, it sounds like you want your routes named based on the `identifier` parameter. This [is where `setTransactionName`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-set-transaction-name) can help. If you try something like this

```auto
    server.route({
      method: 'GET',
      path: '/{identifier}',
      handler: (request, h) => {
          const identifier = request.params.identifier
          apm.setTransactionName('GET /{identifier}')
          return `Hello ${identifier}`;
      }
    });

```

you'll have every request grouped under a single transaction (same behavior as now), but named in a way that makes it more explicit which route they're coming from.

Or, if you want to break things out _by_ the identifier, you could try something like this.

```auto
    server.route({
      method: 'GET',
      path: '/{identifier}',
      handler: (request, h) => {
          const identifier = request.params.identifier
          apm.setTransactionName(`GET ${identifier}`)
          return `Hello ${identifier}`;
      }
    });

```

Here we're using the value of `identifier` to name the transaction. You'll want to be careful with this -- if you have many hundreds or thousands of different identifiers you might overwhelm the user interface and cause a naming explosion -- but if you have a limited number of identifiers it sounds like this will get you where you need to go.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 1, 2021, 1:52pm UTC](https://discuss.elastic.co/t/transaction-table-breakdown-granularity/270178/10 "2021-06-01T13:52:58Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
