# How to trace non web transactions

**URL:** <https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052>\
**Category:** APM\
**Tags:** java, python\
**Created:** [November 8, 2019, 6:07am UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052 "2019-11-08T06:07:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SheetalRIL](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@SheetalRIL](https://discuss.elastic.co/u/SheetalRIL)\
**Post date:** [November 8, 2019, 6:07am UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052/1 "2019-11-08T06:07:06Z")

</div>

Hi  
We are using ELK 6.8.4 and APM 6.8.1.  
We are able to monitor API based applications using APM but we have a requirement of monitoring Non-API applications (batch jobs) using APM. We couldnt find any way to do it.  
Can you please guide us on monitoring Non-API applications.

Thanks,  
Sheetal

---

<div class="post-metadata">

**Author:** ![Shaoranlaos](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Shaoranlaos](https://discuss.elastic.co/u/Shaoranlaos)\
**Post date:** [November 8, 2019, 11:07am UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052/2 "2019-11-08T11:07:16Z")

</div>

The simplest way would be to use the Public APi Annotations  
[https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html) ([https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-annotation](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-annotation))

Simply annotated your entry method with @Transaction and don't forget to set the [`application_packages`](https://www.elastic.co/guide/en/apm/agent/java/current/config-stacktrace.html#config-application-packages) config option.

---

<div class="post-metadata">

**Author:** ![SheetalRIL](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@SheetalRIL](https://discuss.elastic.co/u/SheetalRIL)\
**Post date:** [November 11, 2019, 6:47am UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052/3 "2019-11-11T06:47:57Z")

</div>

Thanks for the reply.  
Even if i add annotations or write code to begin and end transcation, I still have to send logs to APM server. I have simple "hello\_world" program which in python script. Can you suggest me how can i send the logs of this script (without Flask server) to APM because I do not have any option on send logs to APM Server.

Regards,  
Sheetal

---

<div class="post-metadata">

**Author:** ![Shaoranlaos](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Shaoranlaos](https://discuss.elastic.co/u/Shaoranlaos)\
**Post date:** [November 11, 2019, 7:01am UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052/4 "2019-11-11T07:01:59Z")

</div>

APM does not collect logs of an application, it only collects performance data (to my knowledge).  
For logging you would use a standard logging into a file and read this file with filebeat or do direct insertation of the logs into elasticsearch with the api and the provided client in your programming language.

---

<div class="post-metadata">

**Author:** ![beniwohli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/beniwohli/32/21256_2.png) [@beniwohli](https://discuss.elastic.co/u/beniwohli)\
**Post date:** [November 11, 2019, 1:01pm UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052/5 "2019-11-11T13:01:04Z")

</div>

@SheetalRIL for Python, you need to do 4 steps manually in your Python script

- Activate instrumentation

```auto
import elasticapm
elasticapm.instrument()

```

- instantiate the client

```auto
client = elasticapm.Client(service_name="foo", server_url="https://example.com:8200")

```

- begin a transaction before executing your main logic

```auto
client.begin_transaction(transaction_type="script")

```

- end the transaction, giving it a name and a result (using ` __name__ ` here as name will give it the name of the python module)

```auto
client.end_transaction(name= __name__ , result="success")

```

You don't need to manually send the data, as the agent will do that automatically when the Python interpreter exits.

---

<div class="post-metadata">

**Author:** ![SheetalRIL](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@SheetalRIL](https://discuss.elastic.co/u/SheetalRIL)\
**Post date:** [November 12, 2019, 11:25am UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052/6 "2019-11-12T11:25:08Z")

</div>

Thanks a lot 🙂 It worked.

---

<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:** [December 3, 2019, 7:25am UTC](https://discuss.elastic.co/t/how-to-trace-non-web-transactions/207052/7 "2019-12-03T07:25:09Z")

</div>

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