AppDynamics template variables
Instead of hard-coding application names, tier names, or metric paths in your queries, you can use variables. Grafana displays these variables in drop-down select boxes at the top of the dashboard to help you change the data displayed in your dashboard. Grafana refers to such variables as template variables.
For an introduction to templates and variables, refer to the following topics:
Create AppDynamics query variables
To add a new AppDynamics query variable, refer to Add a query variable. Select your AppDynamics data source and use one of the supported query patterns.
The following table lists the supported query patterns for AppDynamics variables. Replace AppName and TierName with the actual application and tier names, or use previously defined variables such as ${application}.
Keywords after the application name (Tiers, Nodes, BusinessTransactions, Path) are case-sensitive. A query with no . lists applications, so Applications is the usual query for that variable.
Query variable examples
Chain variables for cascading drop-downs:
Create dependent variables so that selecting an application populates tiers and business transactions:
- Create a variable named
applicationwith the queryApplications. - Create a variable named
tierwith the query${application}.Tiers. - Create a variable named
btwith the query${application}.${tier}.BusinessTransactions.
To list every business transaction or node in the application, skip the tier and use ${application}.BusinessTransactions or ${application}.Nodes.
Populate a variable from the metric hierarchy:
To list metric names under a folder, use Path and separate folders with .:
- Top-level performance metrics:
${application}.Path.Overall Application Performance - Business transaction folders:
${application}.Path.Business Transaction Performance.Business Transactions
Populate a variable from an ADQL query:
To list distinct transaction names (requires Analytics authentication):
- Query:
SELECT distinct(transactionName) FROM transactions
To list user-experience values:
- Query:
SELECT distinct(userExperience) FROM transactions
Only the first column of the result is used as the variable values.
Use variables in queries
After you create a variable, you can use it in your AppDynamics queries using variable syntax.
Metrics queries
Use ${variableName} in the Application field to choose which application to query. If you create a variable named application, select ${application} from the Application drop-down.
When a multi-value variable is used in the Application field and multiple values are selected, the plugin generates a separate query for each application and displays them as individual series.
You can also put variables in the Metric path. For example, after you create tier and bt variables:
- Select Metrics from the query type radio buttons.
- Select
${application}from the Application drop-down. - In raw edit mode, enter
Business Transaction Performance|Business Transactions|${tier}|${bt}|Calls per Minute.
If tier or bt is multi-value, those path segments are replaced with *. Refer to Limitations.
Analytics queries
Use variables in ADQL queries with the appropriate
variable format. Multi-value variables aren’t rewritten to * in Analytics queries. Use the doublequote formatter for string lists in WHERE clauses:
SELECT transactionName, avg(responseTime) FROM transactions WHERE transactionName IN (${transactionName:doublequote})API queries
Template variables work in input fields for the Health, Events, Tiers, and Metric Names query types.
- Health or Events: set application_id to
${application}. - Events: set tier to
${tier}to limit events to the selected tier. - Metric Names: set application_id to
${application}and metric-path to a path such asOverall Application Performance.
Limitations
The following limitations apply to template variables with the AppDynamics data source:
- Multi-value variables in Metrics metric paths are replaced with wildcards. When a multi-value variable is used in a metric path (not the Application field), all selected values are replaced with
*. To filter by multiple specific values, use an Analytics (ADQL) query with theINoperator instead. - ADQL variable queries must start with
SELECTand includeFROM. Queries that don’t match that pattern are treated as Controller templating queries. If the query has no., the plugin lists applications. - Path queries use
.as the segment separator. Don’t use the metric-path pipe character inAppName.Path...variable queries.
For more information about variables, refer to Templates and variables.


