Monitor multi-container applications in a single pod

Updated at:
Copy as MD

In a sidecar scenario, a single pod can run multiple containers with applications written in various programming languages. This topic explains how to use the ack-onepilot component to instrument these polyglot applications.

Prerequisites

The ack-onepilot version is 4.2.0 or later.

Procedure

  1. Install ack-onepilot and grant it the required resource access permissions as described in one of the following topics:

  2. Add the required labels to the workload.

    Example application YAML

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: multicontainer          
      name: multicontainer
    spec:
      progressDeadlineSeconds: 600
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          app: multicontainer
      strategy:
        rollingUpdate:
          maxSurge: 25%
          maxUnavailable: 25%
        type: RollingUpdate
      template:
        metadata:
          labels:
            app: multicontainer
            apsara.apm/container.test-java.app-language: java
            apsara.apm/container.test-java.armsPilotAutoEnable: 'on'
            apsara.apm/container.test-java.armsPilotCreateAppName: multilanguage-java
            apsara.apm/container.test-go.app-language: golang
            apsara.apm/container.test-go.armsPilotAutoEnable: 'on'
            apsara.apm/container.test-go.armsPilotCreateAppName: multilanguage-go
            apsara.apm/container.test-python.app-language: python
            apsara.apm/container.test-python.armsPilotAutoEnable: 'on'
            apsara.apm/container.test-python.armsPilotCreateAppName: multilanguage-python
        spec:
          containers:
            - command:
                - sleep
                - '360000'
              image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
                # Replace with your actual Java application image.
              imagePullPolicy: Always
              name: test-java
              resources:
                requests:
                  cpu: 250m
                  memory: 512Mi
            - command:
                - sleep
                - '3600000'
              image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
                # Replace with your actual Go application image.
              imagePullPolicy: Always
              name: test-go
              resources:
                requests:
                  cpu: 500m
                  memory: 512Mi
            - command:
                - sleep
                - '3600000'
              image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
                # Replace with your actual Python application image.
              imagePullPolicy: Always
              name: test-python
              resources:
                requests:
                  cpu: 500m
                  memory: 512Mi

    The preceding YAML defines an application that uses Java, Go, and Python in three separate containers: test-java, test-go, and test-python.

    To isolate monitoring data, instrument each container to report data to a separate ARMS application. Follow these steps:

    1. Log on to the ACK console. In the left navigation pane, click Clusters.

    2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Workloads > Deployments.

    3. On the Stateless page, find your target application, and then choose image > Edit YAML in the Actions column.

      To create a new application, click Create From YAML.

    4. In the YAML file, add the following labels under the spec.template.metadata section, and then click Update.

      labels:
        # Replace ${containerName} with the actual container name.
        apsara.apm/container.${containerName}.app-language: java # Replace with the container's actual programming language.
        apsara.apm/container.${containerName}.armsPilotAutoEnable: 'on'
        apsara.apm/container.${containerName}.armsPilotCreateAppName: "<your-deployment-name>"    # Replace <your-deployment-name> with your application name.
  3. The instrumentation is successful if your applications appear on the Application Monitoring > Application List page in the ARMS console and are reporting data.

    In the search box, enter multilanguage- to filter for the three applications: multilanguage-go, multilanguage-java, and multilanguage-python.