After you install the Application Real-Time Monitoring Service (ARMS) agent for a PHP application that is deployed in a Container Service for Kubernetes (ACK) cluster, ARMS starts to monitor the PHP application. You can view the monitoring data of the application, such as the application topology, traces, abnormal transactions, slow transactions, and SQL analysis. This topic describes how to install the ARMS agent for a PHP application that is deployed in an ACK cluster.

Notice The PHP application monitoring feature is under maintenance. You cannot obtain the ARMS agent for PHP from the ARMS console. If you want to use ARMS to monitor PHP applications, you can join the DingTalk Q&A group for PHP application monitoring (group ID: 23328286) to learn how to add PHP applications for monitoring.

Step 1: Obtain the license key

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Application Monitoring > Applications. In the top navigation bar, select a region.
  3. On the Applications page, click Add Application in the upper-right corner.
  4. Copy the license key in the upper part of the Add Application page.
    License key

Step 2: Install the ARMS agent

Install the ARMS agent named ack-arms-pilot for the PHP application.

  1. Log on to the ACK console.
  2. In the left-side navigation pane, choose Marketplace > App Catalog. On the Alibaba Cloud Apps tab, click ack-arms-pilot.
  3. In the Deploy section of the View Details page of ack-arms-pilot, select the cluster in which the application to be monitored is deployed and click Create.

Step 3: Install the Hercules Deploy component to report the data of the PHP application

  1. Create a local YAML file, name it hercules.yaml, and then copy the following content to the YAML file:
    apiVersion: v1
    kind: Namespace
    metadata:
      name: arms-pilot
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: arms-hercules
      namespace: arms-pilot
      labels:
        app: arms-hercules
    spec:
      replicas: 2
      strategy:
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 1
      selector:
        matchLabels:
          app: arms-hercules
      template:
        metadata:
          labels:
            app: arms-hercules
        spec:
          containers:
            - name: arms-hercules
              image: registry.cn-hangzhou.aliyuncs.com/arms-docker-repo/arms-hercules:v1.0
              imagePullPolicy: Always
              command: [ "/root/hercules" ]
              args:
                - '-d'
              resources:
                requests:
                  cpu: 2
                  memory: 2048Mi
                limits:
                  cpu: 2
                  memory: 2048Mi
              ports:
                - name: arms-hercules
                  containerPort: 11234
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: arms-hercules-service
      namespace: arms-pilot
    spec:
      type: ClusterIP
      ports:
        - port: 11234
          protocol: TCP
          targetPort: 11234
      selector:
        app: arms-hercules
          

    Replace the value of the image parameter in the YAML file with one of the following download links based on your region.

    Region Download link
    China (Hangzhou)
    registry.cn-hangzhou.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
    China (Shanghai)
    registry.cn-shanghai.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
    China (Qingdao)
    registry.cn-qingdao.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
    China (Beijing)
    registry.cn-beijing.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
    China (Zhangjiakou)
    registry.cn-zhangjiakou.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
    China (Shenzhen)
    registry.cn-shenzhen.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
    China (Hong Kong)
    registry.cn-hongkong.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
    Singapore
    registry.ap-southeast-1.aliyuncs.com/arms-docker-repo/arms-hercules:v1.1
  2. Run the following command to install the Hercules Deploy component:
    kubectl create -f hercules.yaml
    Note If a message appears in the command output indicating that the namespace already exists, ignore the message.

Step 4: Enable application monitoring for the PHP application

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters. On the Clusters page, click Applications in the Actions column of the cluster in which your application is deployed.
  2. On the Deployments page, click Create from YAML in the upper-right corner.
  3. On the page that appears, select a template from the Sample Template drop-down list, and add the following annotations to the spec > template > metadata section in the Template code editor.
    annotations:
      armsPilotAutoEnable: "on"
      armsPilotCreateAppName: "<your-deployment-name>"
      armsAppType: PHP                                
    Note Replace <your-deployment-name> with the name of your application.
  4. In the namespace of your application, create a ConfigMap named arms-<yourAppName>.ini and copy the following content to the YAML file of the ConfigMap. This step is required only when you install the ARMS agent for the first time.
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: arms-<yourAppName>.ini
      namespace: <yourAppNamespace>
    data:
      arms.ini: |
        extension=/usr/local/arms/arms-php-agent/arms-[x.y].so
        [ARMS]
        arms.enable=1
        arms.app_name=<yourAppName>
        arms.license_key=<yourLicenseKey>
        arms.agent_env=PHPK8S
        arms.network_type=tcp
        arms.tcp_host=arms-hercules-service.arms-pilot
        arms.tcp_port=11234
    Note
    • Replace <yourAppName> with the name of your application.
    • Replace <yourAppNamespace> with the namespace of your application.
    • Replace <yourLicenseKey> with the license key that you obtained on the Add Application page in the ARMS console.
    • In the extension=/usr/local/arms/arms-php-agent/arms-[x.y].so configuration, [x.y] in arms-[x.y].so indicates the version of the PHP application. The supported versions are 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, and 7.3.
    • If the operating system of your container image is Alpine Linux, change arms-[x.y].so to arms-[x.y]-alpine.so. [x.y] can be 5.5, 5.6, 7.0, 7.1, 7.2, or 7.3.
    • A ConfigMap maps only one application. To enable application monitoring for another application, create another ConfigMap. Delete the ConfigMap if it is no longer needed.
  5. Add the arms-<yourAppName>.ini ConfigMap to the spec > template > spec > containers section in the configuration of the Deployment application. Set the mountPath parameter to the path of the PHP configuration file.
    volumeMounts:
    - mountPath: /etc/php/7.2/fpm/conf.d/arms.ini
      name: arms-ini
      subPath: arms.ini

    /etc/php/7.2/fpm/conf.d/ is the configuration loading directory of the PHP application. Add the following content to the spec > template > spec > volumes section:

    volumes:
    - name: arms-ini
      configMap:
        name: arms-<yourAppName>.ini
    Note If the PHP application does not have a configuration file path, add the arms-<yourAppName>.ini ConfigMap to the php.ini configuration file of the application.
    Log on to the ACK console. On the Deployments or StatefulSets page, if ARMS console appears in the Actions column of the application, the ARMS agent is installed. ARMS Console Button
    Note If ARMS console does not appear in the Actions column, check whether ACK is authorized to access ARMS.

Uninstall the ARMS agent

  1. Optional:If you need to pause the ARMS agent, remove the ConfigMap that you added in Step 5 and deploy the application again.
  2. If you need to uninstall the ARMS agent, uninstall the Hercules Deploy component that you installed in Step 2 and remove the ConfigMap that you added in Step 5.

FAQ

What can I do if the ARMS agent fails to be installed?

Possible cause: The version of ack-arms-pilot is earlier than V1.30.

Solution: Grant ACK the permissions to access ARMS. For more information, see the "What can I do if the ARMS agent cannot be installed?" section of the FAQ about application monitoring topic.

References

If you have other questions, join the DingTalk Q&A group for PHP application monitoring (group ID: 23328286) for assistance.