Table of Contents
- Overview
- Pre-Requisites
- Configure Postgresql in Openshift
- Build the BWCE Application Monitor
- Deploy BWCE Application Monitor to OpenShift
- Expose a Route to the BWCE Application Monitor
- Deploy a BWCE Service and Bind it to the Application Monitor
- Creating a Route for our application
Overview
This tutorial assumes you have a working knowledge of BusinessWorks Container Edition (BWCE) and RedHat OpenShift.
The BWCE Application Monitor allows administrators to get detailed process-level monitoring and metrics of each BWCE application that has been deployed in your container management environment. Whilst the documentation at https://docs.tibco.com provide detailed setup and usage instructions they only cover Pivotal Cloud Foundry and Docker.
This tutorial expands on that documentation to show how the BWCE Application Monitor can be deployed on RedHat OpenShift.
Pre-Requisites
Docker installed and configured on your machine
Access to RedHat OpenShift (Origin or MiniShift). For this tutorial, I am using Minishift on my local MacBook, so if you have a full OpenShift environment you may have to make changes as required.
BusinessWorks Container Edition Application. I already have a very basic BWCE Service - a greeting service that provides a REST based interface to return a greeting to the user. The source can be found on my GitHub: https://github.com/davewins/bwce_greeting.git
Docker Image of your application. I?ve built my docker image, and pushed it to my Docker Hub, which you can find at https://hub.docker.com/r/davewins/bwce_monitoring if you want to use this as an example. If you want to use your application, make sure you host the docker image in a registry that is accessible to OpenShift.
BusinessWorks Container Edition Application Monitor. Download bwce_mon-<version>.zip from https://edelivery.tibco.com. You can follow the instructions in the BWCE Application Monitoring and Troubleshooting Guide at https://docs.tibco.com/pub/bwce/2.4.1/doc/pdf/TIB_bwce_2.4.1_application... to download and build the BWCE Application Monitoring container, but I will take you through this in the next section for completeness.
Finally, I?m going to create a new empty project in OpenShift for this tutorial:
Configure Postgresql in Openshift
For this tutorial, I?m going to configure Postgresql for use as the database behind BWCE Application Monitor. From the initial project screen, I?m going to ?Browse Catalog? and then choose Postgresql.
I?ll follow the wizard to import the Postgresql image, but make sure you remember the settings you configure the database with. The important ones are the database Service Name, Username, Password and of course the database name. You will need these when configuring the BWCE Application Monitor. For now, I?ve chosen postgresql, admin/admin and the database name is bwcemon.
When the wizard is completed it shows you the complete configuration details as below:
It?s important to remember these - pay attention to the Connection URL too.
Build the BWCE Application Monitor
As per the instructions in the Application Monitoring and Troubleshooting Guide, download the bwce_mon-<version>.zip file from https://edelivery.tibco.com.
Unzip this file in a directory of your choosing, and then from a command line within that directory execute the following Docker command:
docker build -t bwce/monitoring:latest .
After this step has completed, you need to push your image to an image registry that OpenShift can access. I pushed mine to docker hub by tagging it first, then pushing it as follows:
Tagging:
docker tag bwce/monitoring:latest davewins/bwce_monitoring:latest
Pushing to docker hub:
Deploy BWCE Application Monitor to OpenShift
The next stage is to deploy the BWCE Application Monitor on OpenShift - this is where we will need our Postgresql settings we wrote down earlier ;-)
In our OpenShift Project, under Application -> Deployments we will see our postgresql database deployed. If we click on ?Add to Project?, followed by ?Deploy Image? we can then fill out the details required to deploy the application monitor.
Click on the Image Name radio button and fill out the name of the image you want to deploy. In my case it?s davewins/bwce_monitoring. Remember to press Enter or the magnifying glass to get OpenShift to go and read the details from the registry.
Scroll down the wizard page as there are going to be a couple of Environment Variables that we need to configure: PERSISTENCE_TYPE and DB_URL
In our case, because we are using postgresql, then our PERSISTENCE_TYPE will be postgres (NOT postgresql), and our DB_URL will be: postgresql://admin:admin@postgresql:5432/bwcemon. The DB_URL is made up of the username/password and the Service Name:Port/database name, so make sure you get this correct, otherwise the BWCE Application Monitor will not start.
Note: You may need to change the Name of the image as underscores etc. are not allowed.
When ready, click Deploy.
To check that the BWCE Application Monitor has started correctly, we can go and check its logs. Click on Applications, choose Deployments, Click on our BWCEMonitoring application and then choose Logs, and you?ll see something like the screenshot below - any errors will be on the logs for you to sort out (most likely the DB_URL is incorrect)
Expose a Route to the BWCE Application Monitor
At this stage, the monitor application is running - but it is not yet available to the ?outside world?. To do this, you need to create a Route to the container port (which is 8080).
To create the Route, click on Applications, Choose Service, then our BWCE monitor to get to this screen:
Click on Create Route and you?ll see the following screen. All of the defaults will be correct for this application, unless you want to enable TLS etc. The wizard will automatically create a hostname etc.
When the Route is created, it will take you back to the previous screen where you will see the URL that you can use to access the monitor application:
When you click on the link - you?ll see the application monitor - but it?s empty as we haven?t told the applications how to send their data to it. You must make a note of the Service HostName (in my case: bwcemonitoring.bwce-monitoring-tutorial.svc), as this will be used as part of the environment variables in the next step.
Deploy a BWCE Service and Bind it to the Application Monitor
So, we?re nearly done - this final step allows us to deploy a service that can be monitored, or you could take an existing service and adjust the environment variables required as needed. We?ll deploy my simple greeting service for now.
Go back to ?Deploy Image?
Fill out the image name, in my case I?m using davewins/greeting:latest, press enter to make OpenShift read the image so we can go and fill out the environment variables.
We need to create an Environment Variable called BW_APP_MONITORING_CONFIG.
The value is a JSON string that has URL and a Value, with the value being made up of the Service Name and the port. So in our example, the value is: {"url": "http://bwcemonitoring.bwce-monitoring-tutorial.svc:8080"}
When the application has started - it registers itself with the Application Monitor and so we can refresh the Application Monitor screen to see something like this:
We can then drill into the application itself and see further details such as the process, timings and so on. We can also turn on Process Instrumentation for much more detailed statistics etc.
Note that the REST URL in this case is an internal URL and cannot be accessed externally. To do this, you?ll have to expose the BW Service through a Route and use that URL instead.
Creating a Route for our application
To create the Route so that we can access the Swagger spec. And test our application, go to the Applications and click on Services. Click on our application (greeting in this case), and click on Create Route. Most things can be left as default - but we do want to change the Target Port from 7777 to 8081. This is because in my Docker image, I exposed both ports - but actually only 8081 is used. Once created, the service is created with a URL that you can now open, and put /swagger after the hostname to get the swagger UI.
If you push a few requests through - we can go and take a look at the BWCE Application Monitor and see the stats that get collected.
By default, you can see the number of jobs completed/faulted, etc. and by turning on Instrumentation - you can get much more detailed data.
See the Application Monitoring and Troubleshooting guide for more details on how the Application Monitor should be used.
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now