6 – AppDynamics as a Custom APM

Updated 1 month ago by Michael Katz

As an alternative to Harness' standard AppDynamics integration, you can use this guide to add AppDynamics to Harness as a custom APM. This approach enables you to expand monitoring beyond Business Transactions, to cover specific metrics of interest (for example, JVM data).

Custom Verification Provider Setup

To add a Custom Metrics Provider using AppDynamics, do the following:

  1. In Harness Manager, click SetupConnectorsVerification Providers.
  2. Click Add Verification Provider. From the drop-down, select Custom Verification.

    This opens the Metrics Data Provider settings.
  3. In Type, select Metrics Data Provider, as shown above.
  4. In Display Name, give the Verification Provider an arbitrary name. (You will use this name to select this provider in a Workflow.)
  5. In Base URL, enter: https://<your-AppDynamics-account-name>.saas.appdynamics.com/controller
  6. In Headers, click Add Headers, and add the following row:

    Key

    Value

    Encrypted Value

    Authorization

    Enter a base 64–encoded version of this string, representing your AppDynamics credentials:

    <username>@<account-name>:<password>

    Checked

  7. In Validation Path, enter rest/applications?output=json.
    The settings will now look something like this:
  8. Click Test to verify your custom Connector.
  9. If the test succeeds, click Submit to save the Connector.

Workflow Verification

Now that you have the Verification Provider set up, you can use it as a verification step in a Workflow. The following sections outline how to select the AppDynamics metrics you need.

You can add verification steps to a Workflow after you have performed at least one successful deployment.

To begin the Workflow setup:

  1. In Harness, open the Workflow that deploys the Service you will monitor with AppDynamics.
  2. In the Workflow, in Verify Service, click Add Step.
  3. In the resulting Add Step settings, select Performance Monitoring > Custom Metrics.
  4. Click Next. The Configure Custom Metrics settings appear.
  5. In the Metrics Data Server drop-down, select the Custom Verification Provider you set up above.
  6. Set the Metric Type to either Infrastructure or Transaction.

    Your settings will now look something like this:

  7. Beside Metric Collections, click Add to display the New Metrics Collection settings.

    Most fields here define Harness settings for collecting and grouping metrics. The exceptions are settings where you will map JSON response keys to Harness fields.

Metrics Collection Settings

Fill out the New Metrics Collection settings using the following information.

  • Metrics Name – Enter an arbitrary name for this metric. (This is not an AppDynamics value; it will be internal to Harness.)
  • Metrics Type – Select the type of events you want to monitor. If you selected Infrastructure back in the Metrics Verification settings, your choices here are Infrastructure or Values. If you selected Transaction in the Metrics Verification settings, your choices here are Errors, Response Time, or Throughput.
  • Metrics Collection URL – This is the API query that will return a JSON response. See the next section for details on setting up the query.

 

Metrics Collection URL

The query for the Metrics Collection URL follows this syntax:

rest/applications/cv-app/metric-data?metric-path=Business Transaction Performance|Business Transactions|<tier-name>|/<Business-Transaction-name>/<Metric-name>&time-range-type=BETWEEN_TIMES&start-time=${start_time}&end-time=${end_time}&output=JSON&rollup=false

Above, the values in <...> brackets are placeholders for parameters that you will define. The values in ${...} braces are placeholders used for querying the data, which will be substituted at runtime with real values. To build your literal query:

  1. In the AppDynamics Metric Browser's Metric Tree, right-click the metric you want to monitor, and then select Copy REST URL.

    In the example below, we've selected the Throughput metric /todolist/exception/Calls per Minute. Its REST URL is now on the clipboard:
  2. Paste the resulting URL into the Metrics Collection URL field.
  3. Truncate the URL to the substring that follows .../controller/.
    Your literal query—as copied, pasted into the Metrics Collection URL field, and then truncated—will now look something like this:

    rest/applications/cv-app/metric-data?metric-path=Business%20Transaction%20Performance%7CBusiness%20Transactions%7Cdocker-tier%7C%2Ftodolist%2Fexception%7CCalls%20per%20Minute&time-range-type=BEFORE_NOW&duration-in-mins=60

  4. At the end of the query, replace this substring from AppDynamics' default REST URL:

    &time-range-type=BEFORE_NOW&duration-in-mins=60


    ...with this substring, whose ${...} placeholders are used to query for dynamic runtime data:

    &time-range-type=BETWEEN_TIMES&start-time=${start_time}&end-time=${end_time}&output=JSON&rollup=false


    Your literal query should now look something like this:

    rest/applications/cv-app/metric-data?metric-path=Business%20Transaction%20Performance%7CBusiness%20Transactions%7Cdocker-tier%7C%2Ftodolist%2Fexception%7CCalls%20per%20Minute&time-range-type=BETWEEN_TIMES&start-time=${start_time}&end-time=${end_time}&output=JSON&rollup=false


    Next, you will refine your query by specifying the REST method, and by mapping response keys to Harness fields.
     

Metrics Method Settings

In the Metrics Method drop-down, select either GET or POST, depending on the metric you're monitoring.

If you select POST here, the Metric Collection Body field appears. Enter the JSON body to send as a payload when making a REST call to AppDynamics. For details, see Verify Deployments with Custom APMs and Logs.

 

Response Mapping Settings

The remaining Metrics Collection settings map the keys in the JSON response to Harness fields.

  • Transaction Name – Select Fixed or Dynamic, depending on the transaction name. In our example, we will use Fixed.
    If you select Dynamic, you will see the Transaction Name Path and Regex to transform Transaction Name fields. The Transaction Name Path is filled out in the same way as Name field listed just below. You use Regex to transform Transaction Name to truncate the value of the Transaction Name Path, if needed.
  • Name – Enter the Business Transaction name, as it appears in the AppDynamics Metric Tree. In this example, you would enter: /todolist/exception.
  • Metrics Value – To map this value, run the query: Click Guide from Example, then click SEND from the resulting pop-up:
    In the JSON response, click the value key. This maps it into Harness' Metrics Value field:
  • Timestamp – As with the preceding field, click this field's Guide from Example link to query AppDynamics.
    In the JSON response, click the startTimeInMillis key, which includes the timestamp. This maps this key to Harness' Timestamp field.
  • Timestamp Format – Optionally, enter a timestamp format, following the Java SimpleDateFormat. An example timestamp syntax might be yyyy-MM-dd'T'HH:mm:ss.SSSX. If you leave this field empty, Harness will use the default range of 1 hour previous (now-1h) to now.

When you've filled in all the required Metrics Collection parameters, your query string in the Metrics Collection URL field will be modified to something like this:

rest/applications/cv-app/metric-data?metric-path=Business%20Transaction%20Performance%7CBusiness%20Transactions%7Cdocker-tier%7C%2Ftodolist%2Fexception%7CCalls%20per%20Minute&time-range-type=BETWEEN_TIMES&start-time=${start_time}&end-time=${end_time}&output=JSON&rollup=false

Your New Metrics Collection settings will now look something like this:

Click Test. If your configuration tests successfully, click Add to add this collection.

This returns you to the Custom APM Verification settings' initial Metrics Verification page, to fill in the remaining settings.

Remaining Metrics Verification Settings

Fill in the remaining Metrics Verification settings as follows:

  • Expression for Host/Container name – The expression entered here should resolve to a host/container name in your deployment environment. By default, the expression is ${host.hostName}.
  • Analysis Time Duration – Set the duration for the verification step. If a verification step exceeds this value, the Workflow's Failure Strategy is triggered. For example, if the Failure Strategy is Ignore, then the verification state is marked Failed, but the Workflow execution continues.
  • Data Collection Interval – Specify the frequency at which Harness will query AppDynamics. Harness recommends the value 2.
  • Initial Analysis Delay – By default, Harness waits 2-3 minutes before beginning analysis, to avoid initial deployment noise. This is a standard with monitoring tools.
    Here, you can override this default by entering a delay time value in the format 5s or 5m (etc.).
  • Baseline for Risk Analysis – See CV Strategies, Tuning, and Best Practices.
  • Algorithm Sensitivity – Harness recommends that you normally accept this drop-down's Very sensitive default. If your analysis needs differ, you can flag fewer deviations as anomalies by instead selecting Moderately sensitive or Least sensitive.
  • Include instances from previous phases – If you are using this verification step in a multi-phase deployment, select this checkbox to include instances used in previous phases when collecting data. Do not apply this setting to the first phase in a multi-phase deployment.
  • Execute with previous steps – Enable this check box to run this verification step in parallel with the previous steps in Verify Service.

When you've entered all your Custom APM Verification settings, they will look something like this:

Click Submit. The AppDynamics Custom verification step is now added to the Workflow. Run your Workflow to see the results.

Verification Results

Once you have deployed your Workflow (or Pipeline) using the Custom verification step, you can automatically verify cloud application and infrastructure performance across your deployment.

For examples of how to do so, see the Datadog as a Custom APM topic's Verification Results section.

Next Steps


How did we do?