AppDynamics Knowledge Base

Deploying AppDynamics Database Agent for MySQL on OpenShift: A Step-by-Step Guide

Deploying AppDynamics Database Agent for MySQL on OpenShift: A Step-by-Step Guide

How to Deploy AppDynamics Database Agent for MySQL on OpenShift

Introduction:

Monitoring database performance is crucial for ensuring application stability and efficiency. This guide walks you through deploying the AppDynamics Database Agent on OpenShift to monitor a MySQL database. You'll learn how to:

  • Set up a MySQL instance on OpenShift
  • Deploy the AppDynamics Database Agent with proper permissions
  • Configure MySQL monitoring in the AppDynamics Controller UI
  • Verify metrics and troubleshoot potential issues

By the end of this guide, you’ll have full visibility into your MySQL performance, including query analysis, resource utilization, and overall health monitoring in AppDynamics.

 

1. Prerequisites

  1. OpenShift Cluster: Access via the oc CLI or the OpenShift Web Console.
  2. AppDynamics Controller: You have the host, port, account name, access key.
  3. AppDynamics License: Ensure Database Monitoring (MySQL) is licensed.
  4. Database Agent Image: Typically docker.io/appdynamics/db-agent or a registry provided by AppDynamics.
  5. Basic MySQL Docker image: For this example, we’ll use mysql:8.0 from Docker Hub.

2. Create/Open a New Project

In the CLI, for example:

oc new-project mydb-project
oc project mydb-project

3. Deploy a MySQL Instance on OpenShift

Below is a simple YAML for a Deployment and Service. In a real environment, you’d likely set up persistent storage, handle secrets for credentials, etc.

# mysql.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:8.0
env:
- name: MYSQL_ROOT_PASSWORD
value: rootpassword
- name: MYSQL_DATABASE
value: sampledb
- name: MYSQL_USER
value: appduser
- name: MYSQL_PASSWORD
value: appdpass
ports:
- containerPort: 3306
---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
selector:
app: mysql
ports:
- protocol: TCP
port: 3306
targetPort: 3306

Apply it:

oc apply -f mysql.yaml

Check that the pod and service are running:

oc get pods
oc get svc

You should see mysql-deployment-... running and a mysql-service on port 3306

4. Create a Secret for AppDynamics Credentials

Store your AppDynamics account access key securely.
For example:

oc create secret generic appd-secret \
--from-literal=APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY=<YOUR-ACCESS-KEY>

This secret will be referenced by the Database Agent deployment.

5. Grant the “anyuid” SCC

The AppDynamics Database Agent container often tries to run a startup script (start-appdynamics-database-monitoring). In OpenShift’s default restricted SCC, containers run as a random non-root UID. If the script in the image doesn’t have proper permissions for non-root, you get a permission denied error.

5.1 Create a Service Account (Recommended)

oc create serviceaccount appd-db-agent-sa

5.2 Give anyuid SCC to That Service Account

oc adm policy add-scc-to-user anyuid -z appd-db-agent-sa -n mydb-project

Now, the service account appd-db-agent-sa is allowed to run images that require root or any specific UID.

Note: This is a quick fix and less secure. A better approach is to build a custom image or ensure the official image has proper file permissions (so it can run under restricted SCC). But for simplicity, we’ll use anyuid in this guide.

6. Deploy the AppDynamics Database Agent

Here’s a minimal YAML that uses environment variables (rather than a config file) to configure the agent. It references the secret for the access key and uses the appd-db-agent-sa service account we just created.

# appd-db-agent.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: appd-database-agent
spec:
replicas: 1
selector:
matchLabels:
app: appd-database-agent
template:
metadata:
labels:
app: appd-database-agent
spec:
serviceAccountName: appd-db-agent-sa # <-- Important!

containers:
- name: db-agent
image: docker.io/appdynamics/db-agent:latest
env:
- name: APPDYNAMICS_CONTROLLER_HOST_NAME
value: "my-controller.example.com"
- name: APPDYNAMICS_CONTROLLER_PORT
value: "443"
- name: APPDYNAMICS_CONTROLLER_SSL_ENABLED
value: "true"
- name: APPDYNAMICS_AGENT_ACCOUNT_NAME
value: "myAccount"
- name: APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY
valueFrom:
secretKeyRef:
name: appd-secret
key: APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY

# Name this agent as it appears in the Controller
- name: APPDYNAMICS_DB_AGENT_NAME
value: "MyOpenShiftDBAgent"
- name: APPDYNAMICS_DB_AGENT_TIER_NAME
value: "MyDBTier"
- name: APPDYNAMICS_DB_AGENT_NODE_NAME
value: "MyDBNode"

# For memory management or other Java opts
- name: JAVA_OPTS
value: "-Xms128m -Xmx512m"

Apply it:

oc apply -f appd-db-agent.yaml

Check pod logs:

oc get pods
oc logs deployment/appd-database-agent

If all goes well, you should see logs indicating it connected to the Controller. If you get a permission denied error, confirm you’re using the serviceAccountName: appd-db-agent-sa and that the SA has the anyuid SCC.

7. Configure MySQL Monitoring in the Controller UI

By default, if you only used environment variables, the agent knows how to contact the Controller but doesn’t yet know which MySQL host to monitor. We create a MySQL collector in the AppDynamics UI:

  1. Open the AppDynamics Controller in your browser.
  2. Navigate to DatabasesAgents.
  3. Find your agent (e.g., MyOpenShiftDBAgent) and click on it.
  4. In the Databases tab, click AddAdd MySQL Collector.

Collector Configuration:

  • Display Name: e.g. MyOpenShiftDBAgent
  • Host: mysql-service (assuming your Database Agent is in the same namespace as mysql-service), If in a different namespace, you might need the FQDN: mysql-service.mydb-project.svc.cluster.local
  • Port: 3306
  • Username: appduser
  • Password: appdpass
  • (Optionally) Tweak advanced fields like Collection Interval, Lock Level, Query Analysis, etc.

Abhi_Bajaj1_0-1741807164615.png

 

Save the collector. Within a couple of minutes, the Database Agent should start collecting MySQL metrics.

8. Verify and View Metrics

Once the MySQL collector is set up:

  1. In the AppDynamics Controller, go to DatabasesDatabases.
  2. You’ll see a row for your new MySQL collector (e.g., MyOpenShiftDBAgent).
  3. Click it to see:
  • Overview: CPU, memory, throughput.
  • Queries: Slow queries, wait stats, top queries, etc.
  • Resources: For deeper performance insights.

Abhi_Bajaj1_1-1741807164806.png

 

Conclusion

Deploying the AppDynamics Database Agent alongside MySQL on OpenShift involves:

  1. Creating a project, a MySQL deployment, and a service.
  2. Setting up the Database Agent container, ensuring it can run the startup script (via SCC or a custom image).
  3. Creating a MySQL collector in AppDynamics to specify connection details.

Once configured, you’ll see full visibility into your MySQL instance — top queries, performance metrics, and more — in the AppDynamics Controller. Feel free to add screenshots to illustrate each step in both the OpenShift Web Console and the AppDynamics UI.

Version history
Last update:
‎03-12-2025 01:21 PM
Updated by:
Contributors