All Products
Search
Document Center

Simple Log Service:Collect monitoring data from JVM servers (old version)

Last Updated:Nov 03, 2023

Java Virtual Machine (JVM) servers support multiple metrics. You can collect metrics from JVM servers to the Full-stack Monitoring application. This way, you can view the metrics in the Simple Log Service console.

Prerequisites

  • A Full-stack Monitoring instance is created. For more information, see Create an instance.
  • Java 1.6 or later is installed on your server.

Step 1: Create a Logtail configuration

  1. Log on to the Log Service console.

  2. On the Intelligent O&M tab of the Log Application section, click Full-stack Monitoring.

  3. On the Full-stack Monitoring page, click the instance.

  4. On the Data Import page, turn on JVM Old in the Middleware Monitoring section.

    If this is your first time to create a Logtail configuration for host monitoring, turn on the switch to go to the configuration page. If you have created a Logtail configuration, click the Create icon to go to the configuration page.

  5. Create a machine group.
    • If a machine group is available, click Use Existing Machine Groups.
    • If no machine groups are available, perform the following steps to create a machine group. In this example, an Elastic Compute Service (ECS) instance is used.
      1. On the ECS Instances tab, select Manually Select Instances. Then, select the ECS instance that you want to use and click Create.
        For more information, see Install Logtail on an ECS instance.
        Important If your server is an ECS instance that belongs to another Alibaba Cloud account, a server provided by a third-party cloud service provider, or a server deployed in a self-managed data center, you must manually install Logtail V0.16.48 or later on the Linux server. For more information, see Install Logtail on a Linux server. After you install Logtail, you must manually configure a user identifier on the server. For more information, see Configure a user identifier.
      2. After Logtail is installed, click Complete Installation.
      3. In the Create Machine Group step, configure the Name parameter and click Next.

        Simple Log Service allows you to create IP address-based machine groups and custom identifier-based machine groups. For more information, see Create an IP address-based machine group and Create a custom identifier-based machine group.

    Important Make sure that the server on which you want to install Logtail can connect to the JVM server whose monitoring data you want to collect.
  6. Select the new machine group from Source Server Groups and move the machine group to Applied Server Groups. Then, click Next.
    Important If you apply a machine group immediately after you create the machine group, the heartbeat status of the machine group may be FAIL. This issue occurs because the machine group is not connected to Log Service. To resolve this issue, you can click Automatic Retry. If the issue persists, see What do I do if no heartbeat connections are detected on Logtail?
  7. In the Specify Data Source step, configure the parameters and click Complete. The following table describes the parameters.
    ParameterDescription
    Configuration NameThe name of the Logtail configuration. You can enter a custom name.
    Cluster NameThe name of the JVM cluster. You can enter a custom name.

    After you configure this parameter, Simple Log Service adds a cluster=Cluster name tag to the JVM monitoring data that is collected by using the Logtail configuration.

    Important Make sure that the cluster name is unique. Otherwise, data conflicts may occur.
    Application NameThe name of the Java application. You can enter a custom name.
    Server ListThe information about the JVM server. The information includes the following configuration items:
    • Address: the address of the JVM server.
    • Port: the port number of the JVM server. Default value: 7777.

    You can add information about multiple JVM servers based on your business requirements.

    Custom TagsThe custom tags that are added to the collected JVM monitoring data. The tags are key-value pairs.

    After you configure this parameter, Simple Log Service adds the custom tags to the JVM monitoring data that is collected by using the Logtail configuration.

    After you complete the configuration, Simple Log Service automatically creates assets such as Metricstores. For more information, see Assets.

Step 2: Configure JavaAgent

After you create the Logtail configuration, you must configure JavaAgent on the JVM server. Simple Log Service allows you to use Jolokia to configure JavaAgent. For more information, see Jolokia. You can download and use Jolokia based on the official documentation of Jolokia. You can also use Jolokia JavaAgent that is provided together with Logtail in Simple Log Service. Jolokia JavaAgent is stored in /etc/ilogtail/telegraf/javaagent/jolokia-jvm.jar.

  1. Add the script -javaagent:/etc/ilogtail/telegraf/javaagent/jolokia-jvm.jar=port=7777 to the Java startup parameters.
    7777 is the port number of the server. Make sure that the port number is the same as the port number that you specify in Step 1: Create a Logtail configuration.
    Note By default, Jolokia JavaAgent listens only on the IP address 127.0.0.1 and allows requests only from the local host. If Logtail and your Java application are installed on different servers, you can add the host= field to the added script. This way, Jolokia JavaAgent can listen on other IP addresses. If you add host=0.0.0.0, Jolokia JavaAgent listens on all IP addresses. Command example:
    -javaagent:/tmp/jolokia-jvm.jar=port=7777,host=0.0.0.0
    .
  2. Restart your Java application.
    If your Java application fails to restart, run the following command to connect Jolokia JavaAgent to a specified Java process. This way, the configuration immediately takes effect. Replace Java PID with the actual value.
    Important This operation is used only for testing. In actual scenarios, you must complete the configuration based on the preceding descriptions. Otherwise, the configuration becomes invalid after your application restarts.
    java -jar /etc/ilogtail/telegraf/javaagent/jolokia-jvm.jar --port 7777 start Java PID
    If information similar to the following code is returned, the connection is successful:
    Jolokia is already attached to PID 752
    http://127.0.0.1:7777/jolokia/
  3. Access the following URL to verify the connection:
    curl http://127.0.0.1:7777/jolokia/
    If information similar to the following code is returned, the connection is normal:
    {"request":{"type":"version"},"value":{"agent":"1.6.2","protocol":"7.2","config":{"listenForHttpService":"true","maxCollectionSize":"0","authIgnoreCerts":"false","agentId":"30.XX.XX.186-752-5b091b5d-jvm","debug":"false","agentType":"jvm","policyLocation":"classpath:\/jolokia-access.xml","agentContext":"\/jolokia","serializeException":"false","mimeType":"text\/plain","maxDepth":"15","authMode":"basic","authMatch":"any","discoveryEnabled":"true","streaming":"true","canonicalNaming":"true","historyMaxEntries":"10","allowErrorDetails":"true","allowDnsReverseLookup":"true","realm":"jolokia","includeStackTrace":"true","maxObjects":"0","useRestrictorService":"false","debugMaxEntries":"100"},"info":{"product":"tomcat","vendor":"Apache","version":"8.5.57"}},"timestamp":1602663330,"status":200}

What to do next

After JVM monitoring data is collected to the Full-stack Monitoring application, the application automatically creates dedicated dashboards for the monitoring data. You can use the dashboards to analyze the monitoring data. For more information, see View dashboards.