This page describes examples for common auto-instrumentation configuration scenarios.

  • Example 1: Instrument all the deployments in the ecom namespace. The Java Agents running in each pod will register to the Controller with the Ecommerce application, and the tier names will default to the Kubernetes deployment names.
  • Example 2: Instrument only those deployments with names starting with Payment and with the label module=payment in any namespace.
  • Example 3: Instrument all deployments in namespaces ecom and books. For applications in the books namespace, use the BookStore application name in the Controller and a specific version of the Java Agent.
  • Example 4: Override the configuration in Example 3 for the groceries namespace to use a different Controller application name, and the JAVA_OPTS environment variable to inject the -javaagent Java argument.
  • Example 5: Instrument a Node.js application in namespace books and a .NET Core Linux application in namespace groceries. Also, the Node.js application must send the transaction data to the Analytics Agent.
  • Example 6: Instrument the containers with the names that start with str for the Java application in namespace ecom. Also, use the custom agent configurations in controller-info.xml and app-agent-config.xml configuration files that are in the controllerConf ConfigMap along with the log4j2.xml file for logging settings of the agent in the logConf ConfigMap . These ConfigMaps are in the Cluster Agent's namespace.
  • Example 7: Instrument all the deployments in the groceries namespace and instrument only those deployments with names starting with Payment in the books and ecom namespace.

All Deployments within a Namespace

apiVersion: cluster.appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "<protocol>://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  serviceAccountName: appdynamics-cluster-agent
  nsToMonitor:
    - "default"
  # auto-instrumentation config	
  instrumentationMethod: Env
  nsToInstrumentRegex: ecom
  defaultAppName: Ecommerce
  instrumentationRules:
  - language: java
    imageInfo:
        image: docker.io/appdynamics/java-agent:latest
        agentMountPath: /opt/appdynamics
        imagePullPolicy: Always
YML

Specify Names and Labels in a Deployment

apiVersion: cluster.appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "<protocol>://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  serviceAccountName: appdynamics-cluster-agent
  nsToMonitor:
    - "default"
  # auto-instrumentation config
  instrumentationMethod: Env
  nsToInstrumentRegex: .*
  defaultAppName: Ecommerce
  instrumentationRules:
  - matchString: ^Payment
    labelMatch:
    - module: payment
YML

Instrument Deployments in Namespaces and Specify Agent Versions

apiVersion: cluster.appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "<protocol>://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  serviceAccountName: appdynamics-cluster-agent
  nsToMonitor:
    - "default"
  # auto-instrumentation config
  instrumentationMethod: Env
  nsToInstrumentRegex: ecom|books
  defaultAppName: Ecommerce
  instrumentationRules:
    - namespaceRegex: books
      appName: BookStore
      imageInfo:
        image: "docker.io/appdynamics/java-agent:21.7.0"
        agentMountPath: /opt/appdynamics
        imagePullPolicy: Always
    - namespaceRegex: ecom
YML

Override Configuration Using Environment Variables

apiVersion: cluster.appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "<protocol>://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  serviceAccountName: appdynamics-cluster-agent
  nsToMonitor:
    - "default"
  # auto-instrumentation config
  instrumentationMethod: Env
  nsToInstrumentRegex: ecom|books|groceries
  defaultAppName: Ecommerce
  imageInfo:
    java:
      image: "docker.io/appdynamics/java-agent:latest"
      agentMountPath: /opt/appdynamics
      imagePullPolicy: Always
  instrumentationRules:
    - namespaceRegex: books
      appName: BookStore
      imageInfo:
        image: "docker.io/appdynamics/java-agent:21.7.0"
        agentMountPath: /opt/appdynamics
        imagePullPolicy: Always
    - namespaceRegex: groceries
      appName: Groceries
      env: JAVA_OPTS
    - namespaceRegex: ecom
      #no appName and matchstring for this rule so it will take default appName and default matchstring which is .*
YML

Instrument a Node.js Application with Analytics Agent

apiVersion: cluster.appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "<protocol>://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  serviceAccountName: appdynamics-cluster-agent
  nsToMonitor:
    - "default"
  # auto-instrumentation config
  instrumentationMethod: Env
  nsToInstrumentRegex: ecom|books|groceries
  defaultAppName: Ecommerce
  appNameStrategy: namespace
  imageInfo:
    java:
      image: "docker.io/appdynamics/java-agent:latest"
      agentMountPath: /opt/appdynamics
      imagePullPolicy: Always
  instrumentationRules:
    - namespaceRegex: groceries
      language: dotnetcore
      imageInfo:
        image: "docker.io/appdynamics/dotnet-core-agent:latest"
        agentMountPath: /opt/appdynamics
        imagePullPolicy: Always
    - namespaceRegex: books
      matchString: openmct
      language: nodejs
      imageInfo:
        image: "docker.io/appdynamics/nodejs-agent:20.5.0-alpinev10"
        agentMountPath: /opt/appdynamics
        imagePullPolicy: Always
      analyticsHost: <hostname of the Analytics Agent>
      analyticsPort: 443
      analyticsSslEnabled: true
YML

Instrument Containers with Custom Agent Configuration

apiVersion: cluster.appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "<protocol>://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  serviceAccountName: appdynamics-cluster-agent
  nsToMonitor:
    - "default"
  # auto-instrumentation config
  instrumentationMethod: Env
  nsToInstrumentRegex: ecom
  defaultAppName: Ecommerce
  instrumentationRules:
    - namespaceRegex: ecom
      matchString: ^Payment
      appName: <application-name>
      language: <language>
      customAgentConfigSource:
       - configMapName: controllerConf
         subDir: /ver20.8.0.3686/conf/
       - configMapName: logConf
         subDir: /ver20.8.0.3686/conf/logging
      instrumentContainer: select
      containerMatchString: ^str
      imageInfo:
        image: <image-repo>
        imagePullPolicy: IfNotPresent
YML

Instrument Namespaces and Specify Unique Names

apiVersion: cluster.appdynamics.com/v1alpha1
kind: Clusteragent
metadata:
  name: k8s-cluster-agent
  namespace: appdynamics
spec:
  appName: "<app-name>"
  controllerUrl: "<protocol>://<appdynamics-controller-host>:8080"
  account: "<account-name>"
  # docker image info
  image: "<your-docker-registry>/appdynamics/cluster-agent:tag"
  serviceAccountName: appdynamics-cluster-agent
  nsToMonitor:
    - "default"
  # auto-instrumentation config
  instrumentationMethod: Env
  nsToInstrumentRegex: ecom|books|groceries
  defaultAppName: Ecommerce
  appNameStrategy: namespace
  defaultMatchString: ^payment
  imageInfo:
    java:
      image: "docker.io/appdynamics/java-agent:latest"
      agentMountPath: /opt/appdynamics
      imagePullPolicy: Always
  instrumentationRules:
    - namespaceRegex: groceries
      matchString: .*
    - namespaceRegex: ecom|books
      #no matchstring so it will take default matchstring which is ^payment
YML