# Get the transaction.id

**URL:** <https://discuss.elastic.co/t/get-the-transaction-id/151629>\
**Category:** APM\
**Created:** [October 9, 2018, 12:18pm UTC](https://discuss.elastic.co/t/get-the-transaction-id/151629 "2018-10-09T12:18:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gp4004](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gp4004](https://discuss.elastic.co/u/gp4004)\
**Post date:** [October 9, 2018, 12:18pm UTC](https://discuss.elastic.co/t/get-the-transaction-id/151629/1 "2018-10-09T12:18:12Z")

</div>

Hi there,

Is there any way to get the transaction.id of the current transaction agent side ? (I specify a name for the transactions using apm.setTransactionName('myName))

The idea is to add the transaction.id to the logfiles so a specific transaction identified in the logfiles can be easily found in kibana.

---

<div class="post-metadata">

**Author:** ![gp4004](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gp4004](https://discuss.elastic.co/u/gp4004)\
**Post date:** [October 9, 2018, 2:33pm UTC](https://discuss.elastic.co/t/get-the-transaction-id/151629/2 "2018-10-09T14:33:51Z")

</div>

Ok, forget me 🙂

Searching a little bit more, I found apm.\_instrumentation.currentTransaction.id (nodejs agent)  
I can use this to log the transaction ID.

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [October 9, 2018, 2:39pm UTC](https://discuss.elastic.co/t/get-the-transaction-id/151629/3 "2018-10-09T14:39:43Z")

</div>

You should use [`apm.currentTransaction`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-current-transaction), so you don't go through the private `_instrumentation` property:

```auto
apm.currentTransaction.id

```

I just realized that we haven't documented the `id` property in the [transaction documentation](https://www.elastic.co/guide/en/apm/agent/nodejs/current/transaction-api.html) (we should do that), but you shouldn't expect the ID to be of a specific format, as we might change that soon. But it will remain a string.

---

<div class="post-metadata">

**Author:** ![gp4004](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@gp4004](https://discuss.elastic.co/u/gp4004)\
**Post date:** [October 10, 2018, 7:23am UTC](https://discuss.elastic.co/t/get-the-transaction-id/151629/4 "2018-10-10T07:23:54Z")

</div>

> [@wa7son](#):
>
> [`apm.currentTransaction`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-current-transaction)

Hi, thank you for the [`apm.currentTransaction`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-current-transaction), I will use that, whaterver is the format as long it's a string.

---

<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:** [October 31, 2018, 3:23am UTC](https://discuss.elastic.co/t/get-the-transaction-id/151629/5 "2018-10-31T03:23:56Z")

</div>

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