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:
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.
In the CLI, for example:
oc new-project mydb-project
oc project mydb-project
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
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.
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.
oc create serviceaccount appd-db-agent-sa
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.
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.
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:
Collector Configuration:
Save the collector. Within a couple of minutes, the Database Agent should start collecting MySQL metrics.
Once the MySQL collector is set up:
Deploying the AppDynamics Database Agent alongside MySQL on OpenShift involves:
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.