# SQL Query Tracking

**URL:** <https://discuss.elastic.co/t/sql-query-tracking/179288>\
**Category:** APM\
**Tags:** java\
**Created:** [May 2, 2019, 6:37am UTC](https://discuss.elastic.co/t/sql-query-tracking/179288 "2019-05-02T06:37:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [May 2, 2019, 6:37am UTC](https://discuss.elastic.co/t/sql-query-tracking/179288/1 "2019-05-02T06:37:22Z")

</div>

I am using the apm agent with a wildfly application server.

The apm agent is only tracking the perpared statements of hibernate. But this one is not so useful for analysing the queries on the database for db performance issues.

Is there an option to chosse the query logging in the apm agent ? I see in the jdbc pluging that the agent tracking both. java.sql.Satement and PerparedSatement.

On the other hand I had the idea to use [p6spy](https://github.com/p6spy/p6spy) for tracking the real SQL statements. But I see the github issue from [felix](https://github.com/felixbarny).  
@felixbarny do you recommend to use p6spy in apm plugin ?

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [May 2, 2019, 7:38am UTC](https://discuss.elastic.co/t/sql-query-tracking/179288/2 "2019-05-02T07:38:57Z")

</div>

What are you missing in the statements captured by the Java agent? Is it that you want to see the query parameters? Our agents don't capture those because of security/privacy (to not log hashed passwords or otherwise sensitive information) and performance concerns.

If you want to also log the parameters, p4spy is a very good option to log the full statements into a separate log file.

---

<div class="post-metadata">

**Author:** ![suikast42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suikast42/32/29865_2.png) [@suikast42](https://discuss.elastic.co/u/suikast42)\
**Post date:** [May 2, 2019, 8:29am UTC](https://discuss.elastic.co/t/sql-query-tracking/179288/3 "2019-05-02T08:29:56Z")

</div>

> [@felixbarny](#):
>
> Our agents don't capture those because of security/privacy (to not log hashed passwords or otherwise sensitive information) and performance concerns.

I want exactly see that. But not for production only for development purpose.

How is the perfomance impact to use p6spy for that purpose ?

> [@felixbarny](#):
>
> If you want to also log the parameters, p4spy is a very good option to log the full statements into a separate log file.

That can be an idea to create a transaction id in the log document and show it in a seperate dashboard 😉

---

<div class="post-metadata">

**Author:** ![Lyle\_Simmons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lyle_simmons/32/46277_2.png) [@Lyle\_Simmons](https://discuss.elastic.co/u/Lyle_Simmons)\
**Post date:** [May 16, 2019, 8:05am UTC](https://discuss.elastic.co/t/sql-query-tracking/179288/4 "2019-05-16T08:05:13Z")

</div>

Do not mind referring to [customer database management](https://www.enteros.com/) from time to time. This company had been of a great help at proper time when working with database.

---

<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 6, 2019, 4:05am UTC](https://discuss.elastic.co/t/sql-query-tracking/179288/5 "2019-06-06T04:05:13Z")

</div>

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