If the deployment of your Java-based microservices is based on IBM Microservice Builder, the Liberty data collector is automatically installed in the microservice so you can start monitoring quickly.

Before you begin

  • The following V8.1.4 Cloud APM server information is required during Liberty data collector configuration.
    • The URL of the target Cloud APM server.
    • The location of the key file, either a URL to download the key file or a local file directory (required only by a secure HTTPS connection).

      For example, http://127.0.0.1:8080/keyfile.p12, file:///etc/apm-keyfile/keyfile.p12, or /etc/apm-keyfile-volume/keyfile.p12.

    • The key file password that is paired with the key file (required only by a secure HTTPS connection).
  • The service account that you use to configure the data collector must have access to Kubernetes resources. Run the following command on the master node to decide whether the data collector can access Kubernetes resources with the service account, where kube_namespace is the target namespace and service_account is the account that you use to configure the data collector.
    kubectl auth can-i list nodes --as system:serviceaccount:kube_namespace:service_account
    kubectl auth can-i get pods --as system:serviceaccount:kube_namespace:service_account
    kubectl auth can-i list services --as system:serviceaccount:kube_namespace:service_account

    If the service account does not have access to Kubernetes resources, authorize it before you configure the data collector. For information, see Authorizing the data collector to access Kubernetes resources.

Procedure

Complete the following steps to use Microservice Builder to deploy a Java-based microservice when the Liberty data collector is automatically configured:

  1. Create the Cloud APM server secret yaml file named apm-server-config-secret.yaml by running either the create -f or the apply -f command.
  2. Add the following information to the apm-server-config-secret.yaml file:
    apiVersion: v1
    kind: Secret
    metadata:
      name: apm-server-config
    data:
      ibm_apm_ingress_url: apm_for_devops_server_url
      ibm_apm_keyfile: key_file_location
      ibm_apm_keyfile_password: key_file_pswd

    Remember: Use base64 encoding to encrypt the actual values for the following variables. For example, on a Linux system run the echo -n ‘original_value’ | base64 command to get the encoded value.

    where:

    • apm_server_url is the base64 encoded URL of the target Cloud APM server.
    • key_file_location is the base64 encoded location of the key file. This variable is required by a secure HTTPS connection only.
    • key_file_pswd is the base64 encoded key file password that is paired with the key file. This variable is required by a secure HTTPS connection only.
  3. On the IBM Cloud Private master node, create the server secret by running the following command:
    kubectl create -f apm-server-config-secret.yaml
  4. If the Microservice Builder pipeline, which is required to deploy microservices from GitHub or GitHub Enterprise to IBM Cloud Private was not previously set up, set it up now. For detailed instructions, see Setting up the Microservice Builder pipeline.
  5. Create the Java-based microservice by running the following command. For more information, see Create a simple microservice in IBM Knowledge Center.
    bx dev create

    Remember: After you run the bx dev create command and follow the prompts to create a microservice, select Java – MicroProfile / Java EE for the language when prompted. Other options are not supported by the data collector.

    When this step completes, a directory is created within the current directory with the project name that you specify.

  6. Modify the project files to customize your application.
  7. If a proxy is set for the JVM, add the JVM_ARGS variable to the container specification in the application deployment yaml file to define the proxy properties.
    • If authentication is not required, specify the JVM_ARGS variable value as follows:
            - name: JVM_ARGS
              value: "-Dhttp.proxyHost=http_proxy_host -Dhttp.proxyPort=http_proxy_port -Dhttps.proxyHost=https_proxy_host -Dhttps.proxyPort=https_proxy_port -Djava.net.useSystemProxies=true -Dhttp.nonProxyHosts=non_proxy_host"
    • If a user ID and password is required to access the proxy, specify the JVM_ARGS variable value as follows:
            - name: JVM_ARGS
              value: "-Dhttp.proxyHost=http_proxy_host -Dhttp.proxyPort=http_proxy_port -Dhttp.proxyUser=http_proxy_user -Dhttp.proxyPassword=http_proxy_pwd -Dhttps.proxyHost=https_proxy_host -Dhttps.proxyPort=https_proxy_port -Dhttps.proxyUser=https_proxy_user -Dhttps.proxyPassword=https_proxy_pwd -Djava.net.useSystemProxies=true -Dhttp.nonProxyHosts=non_proxy_host"
    Remember:

    • All proxy properties that are embraced by double quotation marks (” “) must be set on the same line as value: and separated by a space.
    • The -Djava.net.useSystemProxies value must be set to true.
    • Use the -Dhttp.nonProxyHosts variable to specify the IPs that are used for internal communication and the asterisk (*) can be used.

    Example:

          - name: JVM_ARGS
            value: "-Dhttp.proxyHost=9.42.23.52 -Dhttp.proxyPort=82 -Dhttp.proxyUser=myproxy -Dhttp.proxyPassword=mypwd -Dhttps.proxyHost=9.42.23.52 -Dhttps.proxyPort=82 -Dhttps.proxyUser=myproxy -Dhttps.proxyPassword=mypsw -Djava.net.useSystemProxies=true -Dhttp.nonProxyHosts=10.*"
  8. Deploy your application with the Microservice Builder pipeline by pushing the project to a new repository in the GitHub organization that the Microservice Builder pipeline is monitoring.
    Remember: During the Docker image build process, the Liberty data collector is downloaded from the WebSphere Liberty Repository as an extension pack. If the Microservice Builder pipeline is working properly, your environment already has access to this public and online repository.

What to do next

Log in to the Cloud APM console from your browser to review the health status of your services in the dashboards. For more information, see Starting the Cloud APM console.

Remember: When you want to add the Liberty data collector instance on the Application Dashboard, select Liberty Runtime from the component list.

Join The Discussion

Your email address will not be published. Required fields are marked *