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}.

QueryDescription
ApplicationsReturns all application names.
AppName.TiersReturns all tiers for the specified application.
AppName.TierName.BusinessTransactionsReturns all business transactions for a specific tier within an application.
AppName.TierName.NodesReturns all nodes for a specific tier within an application.
AppName.Path.segment1.segment2...Returns metric names at a specific point in the metric hierarchy. Use . to separate path segments. For example, MyApp.Path.Overall Application Performance returns metric names under that path.
SELECT column FROM tableReturns the first column of results from an Analytics (ADQL) query. For example, SELECT distinct(transactionName) FROM transactions.

Query variable examples

Chain variables for cascading drop-downs:

Create a set of dependent variables so that selecting an application automatically populates tier and business transaction options:

  1. Create a variable named application with the query Applications.
  2. Create a variable named tier with the query ${application}.Tiers.
  3. Create a variable named bt with the query ${application}.${tier}.BusinessTransactions.

Populate a variable from the metric hierarchy:

To create a variable that lists available metric names under a specific path:

  • Query: ${application}.Path.Overall Application Performance

Populate a variable from an ADQL query:

To create a variable listing distinct transaction names:

  • Query: SELECT distinct(transactionName) 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 dynamically select which application to query. For example, 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.

Analytics queries

Use variables in ADQL queries with the appropriate variable format. For example, use the doublequote formatter for string comparisons in WHERE clauses:

SQL
SELECT transactionName, avg(responseTime) FROM transactions WHERE transactionName IN (${transactionName:doublequote})

API queries

Template variables are also supported in input fields for the Health, Events, Tiers, and Metric Names query types. For example, use ${application} in the application_id field of an Events query to dynamically filter events.

Limitations

The following limitations apply to template variables with the AppDynamics data source:

  • Multi-value variables in 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 the IN operator instead.

For more information about variables, refer to Templates and variables.