In this post, We will configure and integrate Apache Tomcat monitoring metrics with Telegraf on ubuntu 18.04 LTS
I believe you have already installed and configure prometheus ,Telegraf and MongoDB on your machine if not so then go through the given url to setup prometheus with telegraf on your machine.
https://www.techbeginner.in/2020/12/how-to-install-prometheus-on-ubuntu.html
https://www.techbeginner.in/2021/01/how-to-install-telegraf-on-ubuntu-1804.html
https://www.techbeginner.in/2019/12/how-to-install-apache-tomcat8-on-ubuntu.html
Apache Tomcat is an open-source usage of the Java Servlet, JavaServer Pages, Java Expression Language and WebSocket innovations. Tomcat gives a “unadulterated Java” HTTP web worker climate in which Java code can run.
By default telegraf we have got the telegraf.d directory on /etc/telegraf/telegraf.d in this path, You need to create a tomcat.conf configuration file and add the following nginx plugin syntax by following the given command.
©sudo vim /etc/telegraf/telegraf.d/tomcat.conf
Paste the given code to enable the tomcat plugin in telegraf.
# Gather metrics from the Tomcat server status page.
[[inputs.tomcat]]
## URL of the Tomcat server status
# url = "http://127.0.0.1:8080/manager/status/all?XML=true"
## HTTP Basic Auth Credentials
# username = "tomcat"
# password = "s3cret"
## Request timeout
# timeout = "5s"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
Here you can uncomments the other parameter to use the username and password for Tomcat monitoring user as per your requirement, Save and exit from the vim text editor.
You need to restart the Telegraf service to get new changes for Tomcat metric in prometheus, Use the following command for the same.
©©©sudo systemctl restart telegraf
Conclusion
We have successfully integrate tomcat with Telegraf in our Ubuntu 18.04 server.