# Configure Elastic APM for Tomcat

**URL:** <https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608>\
**Category:** APM\
**Created:** [August 30, 2018, 4:05am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608 "2018-08-30T04:05:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [August 30, 2018, 4:05am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/1 "2018-08-30T04:05:22Z")

</div>

Hello  
I want to configure APM for Spring Web MVC with Tomcat and Jetty. The build generates a .WAR file. The current approach needs APM agent to be attached with standalone application with .JAR.

Please suggest.

Thanks

---

<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:** [August 30, 2018, 5:21am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/2 "2018-08-30T05:21:25Z")

</div>

The [documentation](https://www.elastic.co/guide/en/apm/agent/java/current/intro.html) has an example how to get started with tomcat.

I hope that helps!

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [August 30, 2018, 8:30am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/3 "2018-08-30T08:30:29Z")

</div>

I am trying to create the setenv.bat as I am working on windows. The below command is giving error.

export CATALINA\_OPTS="$CATALINA\_OPTS -javaagent:/path/to/elastic-apm-agent-\<version\>.jar"

Please suggest the change in case of .bat file.

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [August 30, 2018, 10:48am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/4 "2018-08-30T10:48:46Z")

</div>

I have configured the tomcat as suggested in the documentation, tomcat is successfully started, but still Kibana is not showing the service. I have deployed an Spring Boot application which is working as per expectation.

Below is the content of the setenv.bat file

set CATALINA\_OPTS=%CATALINA\_OPTS% -javaagent:"C:/apache-tomcat-7.0.82/bin/elastic-apm-agent-0.6.2.jar"

Kibana shows : No services were found

Apache startup log shows :

**C:\apache-tomcat-7.0.82\bin\>rem Get standard environment variables**

**C:\apache-tomcat-7.0.82\bin\>if not exist "C:\apache-tomcat-7.0.82\bin\setenv.bat" goto checkSetenvHome**

**C:\apache-tomcat-7.0.82\bin\>call "C:\apache-tomcat-7.0.82\bin\setenv.bat"**

**C:\apache-tomcat-7.0.82\bin\>set CATALINA\_OPTS= -javaagent:"C:/apache-tomcat-7.0.82/bin/elastic-apm-agent-0.6.2.jar"**

**C:\apache-tomcat-7.0.82\bin\>goto setenvDone**

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [August 30, 2018, 2:08pm UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/5 "2018-08-30T14:08:08Z")

</div>

Please help, i am stuck at this point.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/2/e2af2dedf681f7b8a7a50bd5c23a013087b5a5c2.png)  
I checked the tomcat, APM is attached to the process. Also I tried deploying both Spring Boot and Spring MVC Web framework application, but none is getting identified.

Apm Server log

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/4/644225c3096129d3c810a6518dfa8344f1f5bc15.png)

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [August 31, 2018, 1:22am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/6 "2018-08-31T01:22:14Z")

</div>

Hi,

I'm not a Java agent expert, but it might be because of the quotes in the "set" command? With the Windows/batch set command, double quotes get stored unless they surround the whole `k=v`, like `"k=v"`.

Try changing

`set CATALINA_OPTS=%CATALINA_OPTS% -javaagent:"C:/apache-tomcat-7.0.82/bin/elastic-apm-agent-0.6.2.jar"`

to

`set "CATALINA_OPTS=%CATALINA_OPTS% -javaagent:C:\apache-tomcat-7.0.82\bin\elastic-apm-agent-0.6.2.jar"`

---

<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:** [August 31, 2018, 6:40am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/7 "2018-08-31T06:40:45Z")

</div>

Sorry for the late reply.

Seems like the agent is already running in your application but it can't connect to the apm server. Are you running both locally?

Which version of the APM server are you using? If it's 6.4, you can go to [http://localhost:8200/healthcheck](http://localhost:8200/healthcheck) to see if the server is up and running.

And sorry for the poor documentation on how to get started on windows.

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [August 31, 2018, 12:03pm UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/8 "2018-08-31T12:03:29Z")

</div>

Thanks a lot for replying. I checked the URL but I am getting a blank screen. Still Kibana status is No service found.  
I am using Version 6.4 and I am running server and agent locally.

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [August 31, 2018, 12:06pm UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/9 "2018-08-31T12:06:03Z")

</div>

Hello Andrew  
There is no change in behavior.

---

<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:** [August 31, 2018, 2:41pm UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/10 "2018-08-31T14:41:09Z")

</div>

I'm a bit puzzled to be honest. Could you add the full agent and server logs, please?

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [September 2, 2018, 3:46am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/11 "2018-09-02T03:46:55Z")

</div>

True, even I am. I tried to make changes in the apm-server.yaml for the logging but the changes are not reflecting. In case of Agent how do i change the logging method and provide log file path.

Thanks a lot for your support.

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [September 3, 2018, 6:09am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/12 "2018-09-03T06:09:30Z")

</div>

How will the agent understand that it is tagged to a specific apm-server, as I do not see any facility configure the host IP in the agent.

---

<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:** [September 3, 2018, 6:20am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/13 "2018-09-03T06:20:22Z")

</div>

Hi,

here are links to the [logging configuration](https://www.elastic.co/guide/en/apm/agent/java/current/config-logging.html) and [server\_url](https://www.elastic.co/guide/en/apm/agent/java/current/config-reporter.html#config-server-url) configuration options.

I hope that helps 🙂

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [September 3, 2018, 6:25am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/14 "2018-09-03T06:25:23Z")

</div>

Logging I have done, but the same is not creating any log files.  
Question: Where I have to configure server\_url as i do not see any parameter in apm-server.yaml?

#================================ Logging ======================================

# 

# There are three options for the log output: syslog, file, stderr.

# Under Windows systems, the log files are per default sent to the file output,

# under all other system per default to syslog.

# Sets log level. The default log level is info.

# Available log levels are: error, warning, info, debug

logging.level: debug

# Enable debug output for selected components. To enable all selectors use ["\*"]

# Other available selectors are "beat", "publish", "service"

# Multiple selectors can be chained.

#logging.selectors: []

# Send all logging output to syslog. The default is false.

#logging.to\_syslog: true

# If enabled, apm-server periodically logs its internal metrics that have changed

# in the last period. For each metric that changed, the delta from the value at

# the beginning of the period is logged. Also, the total values for

# all non-zero internal metrics are logged on shutdown. The default is true.

logging.metrics.enabled: true

# The period after which to log the internal metrics. The default is 30s.

#logging.metrics.period: 30s

# Logging to rotating files. Set logging.to\_files to false to disable logging to

# files.

logging.to\_files: true  
#logging.files:

# Configure the path where the logs are written. The default is the logs directory

# under the home path (the binary location).

path: ["C://Program Files//APM-Server//logs"]

# The name of the files where the logs are written to.

name: apm-server

# Configure log file size limit. If limit is reached, log file will be

# automatically rotated

#rotateeverybytes: 10485760 # = 10MB

# Number of rotated log files to keep. Oldest files will be deleted first.

#keepfiles: 20

# The permissions mask to apply when rotating log files. The default value is 0600.

# Must be a valid Unix-style file permissions mask expressed in octal notation.

#permissions: 0600

# Set to true to log messages in json format.

#logging.json: false

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [September 3, 2018, 6:37am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/15 "2018-09-03T06:37:49Z")

</div>

@Senz79 you can configure the host and port the APM Server is listening on with the setting `apm-server.host` at the very beginning of [`apm-server.yml`](https://github.com/elastic/apm-server/blob/6.4/apm-server.yml#L7).

Could you please run this query from Kibana DevTools and check what `hits.total` returns:

```auto
GET apm-*/_search
{
  "size": 0, 
  "query": {
    "match_all": {}
  }
}

```

In case `hits.total` is not `0`, data are ingested but it looks like you have to update the APM Server or Kibana config file, please see our [Release Notes](https://www.elastic.co/guide/en/apm/get-started/current/apm-release-notes.html#_breaking_changes).

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [September 3, 2018, 6:43am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/16 "2018-09-03T06:43:50Z")

</div>

This is what is configured in apm host  
apm-server:  
host: "localhost:8300"

Below is the output of the query. The hits showing the number while is configured the agent to monitor a .JAR file around 2 week back. Currently I configure the agent in TOMCAT and that has 0 hits. Let me know how I can add date in the query or get the hits for today.

**{**  
\*\* "took": 7,\*\*  
\*\* "timed\_out": false,\*\*  
\*\* "\_shards": {\*\*  
\*\* "total": 7,\*\*  
\*\* "successful": 7,\*\*  
\*\* "skipped": 0,\*\*  
\*\* "failed": 0\*\*  
\*\* },\*\*  
\*\* "hits": {\*\*  
\*\* "total": 26580,\*\*  
\*\* "max\_score": 0,\*\*  
\*\* "hits": []\*\*  
\*\* }\*\*  
**}**

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [September 3, 2018, 7:39am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/17 "2018-09-03T07:39:31Z")

</div>

Documents are indexed in a daily index by default. You can change the query from `apm-*/_search` to .e.g `apm-*2018.09.03/_search` for today's data.

@Senz79 you mentioned that the APM Server is listenting on port `8300`, but your first post showed that the agent is trying to connect at port `8200`. Please ensure to either have the agent configured to send data to your APM Server on port `8300` or change the APM Server config to listen on port `8200`.

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [September 3, 2018, 7:43am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/18 "2018-09-03T07:43:57Z")

</div>

Yes I have configured it to 8200.

logtail apache  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/3/c3a5b2d1a6a38d3834c51592f26472558558419b.png)

Log tail - apm-server

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/1/a14c6d4ba72eccf6621c170974c28b8080bb63b8.png)

Kibana Snapshot

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/0/4067dcfad0a7dabd828f6673c72937760e5de987.png)

---

<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:** [September 3, 2018, 7:48am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/19 "2018-09-03T07:48:51Z")

</div>

Could you attach the full apm-server logs as text, beginning from when you have started it?

---

<div class="post-metadata">

**Author:** ![Senz79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senz79/32/42874_2.png) [@Senz79](https://discuss.elastic.co/u/Senz79)\
**Post date:** [September 3, 2018, 8:00am UTC](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608/20 "2018-09-03T08:00:40Z")

</div>

C:\Program Files\APM-Server\>apm-server.exe -e  
2018-09-03T13:09:05.809+0530 INFO instance/beat.go:544 Home path: [C:\Program Files\APM-Server] Config path: [C:\Program Files\APM-Server] Data path: [C:\Program Files\APM-Server\data] Logs path: [C:\Program Files\APM-Server\logs]  
2018-09-03T13:09:05.810+0530 INFO instance/beat.go:551 Beat UUID: 7c25ee4d-972b-4e0c-8312-5611157dec43  
2018-09-03T13:09:05.810+0530 INFO [beat] instance/beat.go:768 Beat info {"system\_info": {"beat": {"path": {"config": "C:\Program Files\APM-Server", "data": "C:\Program Files\APM-Server\data", "home": "C:\Program Files\APM-Server", "logs": "C:\Program Files\APM-Server\logs"}  
, "type": "apm-server", "uuid": "7c25ee4d-972b-4e0c-8312-5611157dec43"}}}  
2018-09-03T13:09:05.811+0530 INFO [beat] instance/beat.go:777 Build info {"system\_info": {"build": {"commit": "59fbf0b6146ca5c50a94d1c435d0cf704e5b2a3f", "libbeat": "6.4.0", "time": "2018-08-17T22:12:40.000Z", "version": "6.4.0"}}}  
2018-09-03T13:09:05.811+0530 INFO [beat] instance/beat.go:780 Go runtime info {"system\_info": {"go": {"os":"windows","arch":"amd64","max\_procs":4,"version":"go1.10.3"}}}  
2018-09-03T13:09:05.972+0530 INFO [beat] instance/beat.go:784 Host info {"system\_info": {"host": {"architecture":"x86\_64","boot\_time":"2018-09-03T09:27:43.16+05:30","hostname":"XXXXXXXX","ips":["xxxxxxxxxx:435f/64","xxxxxxxxxx/16","fe80::xxxxxxxx/64","xxxxxxxxx/16","fe80::xxxxxxxx/64","xxxxxxxx/16",  
"fe80::xxxxxxxxxx/64","xxxxxxxxx/16","fe80::xxxxxxxx/64","xxxxxxxx/21","fe80::xxxxxxxxx/64","xxxxxxxx/16",  
"fe80::a074:xxxxxx/64","xxxxxxxxx/24","::1/128","127.0.0.1/8","fe80::5e  
fe:cxxxxxx/128","fe80::e0:0:0:0/64","fe80xxxxxxx/128"],"kernel\_version":"6.1.7601.24214 (win7sp1\_ldr\_escrow.180801-1700)",  
"mac\_addresses":["00:xxxxxxxxx","xxxxxxxx","xxxxxx","4a:45:20:bf:41:f5","xxxxxx","xxxxxxx","0a:00:27:00:00:2a","00:00:00:0  
0:00:00:00:e0","00:00:00:00:00:00:00:e0","00:00:00:00:00:00:00:e0","00:00:00:00:00:00:00:e0","00:00:00:00:00:00:00:e0"],  
"os":{"family":"windows","platform":"windows","name":"Windows 7 Enterprise","version":"6.1","major":1,"minor":0,"patch":0,"build":"7601.24214"}  
,"timezone":"IST","timezone\_offset\_se  
c":19800,"id":"426f3f3e-fbc0-41b1-8f1f-299e3eeaceb0"}}}  
2018-09-03T13:09:05.973+0530 INFO instance/beat.go:273 Setup Beat: apm-server; Version: 6.4.0  
2018-09-03T13:09:05.973+0530 INFO elasticsearch/client.go:163 Elasticsearch url: [http://localhost:9200](http://localhost:9200)  
2018-09-03T13:09:05.974+0530 INFO pipeline/module.go:98 Beat name: XXXXXXXX  
2018-09-03T13:09:05.974+0530 INFO instance/beat.go:367 apm-server start running.  
2018-09-03T13:09:05.974+0530 INFO [monitoring] log/log.go:114 Starting metrics logging every 30s  
2018-09-03T13:09:05.974+0530 INFO [beater] beater/beater.go:172 self instrumentation is disabled  
2018-09-03T13:09:05.980+0530 INFO [beater] beater/beater.go:113 host resolved from localhost:8200 to 127.0.0.1:8200

[Next page](https://discuss.elastic.co/t/configure-elastic-apm-for-tomcat/146608.md?page=2)
