Even if you want to try Application Performance Monitoring of Oracle Management Cloud for a while, it is quite troublesome because you have to prepare the environment where the WEB application actually operates. Here, we will introduce how to use Docker to build a JAVA WEB application and the necessary environment as easily as possible so that anyone can easily try APM.
A dummy WEB sample application that accesses MySQL via JDBC. There is a mechanism that slows down the response.
Here, Docker is installed on Always Free of Oracle Cloud, and Apache and MySQL containers are started. Then create a configuration that monitors the sample WEB application with OMC's APM. If it is a Linux VM instance of OCI, it can be executed by Copy & Paste according to the procedure.
--VM instance must have HTTPS access to the internet --Access is outband only (Cloud Agent-> OMC) Inbound does not occur
1. Docker&Install Docker Compose
$ sudo yum install docker-engine
$ sudo gpasswd -a $USER docker
$ docker -v
Docker version 19.03.1-ol, build ead9442
$ sudo curl -L https://github.com/docker/compose/releases/download/1.25.0-rc2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
* Exit the terminal you are currently connected to and reopen the terminal again.
$ sudo systemctl start docker.service
$ sudo systemctl enable docker.service
2.Download & unzip the web app source
$ pwd
/home/opc
$ wget https://github.com/westan24/omcapp/archive/master.zip
$ unzip master.zip
$ cd omcapp-master
$ unzip omcapp.zip
$ ls
apmdemo2.war Dockerfile my.cnf person_db_mysql.sql
docker-compose.yml initial.sql omcapp.zip README.md
3.Create folders required for Docker MySQL
$ sudo rm -rf ./db
$ sudo mkdir ./db
$ sudo mkdir ./db/mysql_data
$ sudo mkdir ./db/mysql_init/
$ sudo cp initial.sql db/mysql_init/
$ sudo cp person_db_mysql.sql db/mysql_init/
--Click the agent from the OMC console
--Click the agent download icon in the upper right
--Select APM Agent as the agent type and click APM JAVA Agent to download
--Click Manage Registration Keys on the top right icon
--Enter your favorite name and click Create New Key
--Download the generated key value
Downloaded 1.4x_APM_226.zip and registrationKey.Two files of txt/home/opc/omcapp-Copy to master
$ ls
1.46_APM_226.zip Dockerfile omcapp.zip registrationKey.txt
apmdemo2.war initial.sql person_db_mysql.sql
docker-compose.yml my.cnf README.md
* Rename the APM agent name(Since the APM agent name is incremented for each version)
$ mv 1.46_APM_226.zip 1.45_APM_226.zip
$ docker-compose up -d
-Various construction messages are played-
Creating mysql ... done
Creating tomcat ... done
$ docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------
mysql docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp, 33060/tcp
tomcat catalina.sh run Up 0.0.0.0:8080->8080/tcp
* OK if both containers are UP
--Access the following address with a browser --http: // compute Public IP: 8080 / apmdemo2 / menu --If inaccessible, check if 8080 is open in the OCI security list
--Sample web application This web app may also generate errors along the way. Don't worry about the details ... (Because it can be used for log analysis of Log Analytics)
--APM home screen
--Detailed diagram inside the server request
--If the database is a JDBC connection, you can see the execution status for each SQL query.
--Execution history for each instance (access taking 10 seconds is displayed)
--End user monitoring must be enabled to view user browser operation history information --For the setting method, refer to OMC APM Agent Installation --.NET Edition- - https://qiita.com/western24/items/855cee9d2c0a93b8cf79
--User's browser operation history when the response is delayed by 10 seconds --You can see that it took 10 seconds to access the route and display the page.
How was that? I think that it can be used as it is for operation verification such as Docker monitoring with Infrastructure Monitoring of OMC and analysis of Tomcat and MySQL logs with Log Analytics. I would like to introduce the Node.js version at another time.
Click here for information related to Oracle Management Cloud (https://qiita.com/western24/items/1e44bfcaa77f3251a263)
Recommended Posts