---
title: Get web transaction time data (v2)
source: https://docs.newrelic.com/docs/apis/rest-api-v2/application-examples-v2/get-web-transaction-time-data-v2
---

The [metric timeslice data](https://docs.newrelic.com/docs/data-analysis/metrics/analyze-your-metrics/data-collection-metric-timeslice-event-data#timeslice-data) presented on the **Web transaction time** chart on your application's [**Summary** page](https://docs.newrelic.com/docs/apm/applications-menu/monitoring/apm-overview-page) will depend on your web app's configuration. Possible components may include:

-   [Response time](https://docs.newrelic.com/docs/data-analysis/user-interface-functions/view-your-data/response-time)
-   Application total time for your agent language
-   Datastore, Database or (Ruby) Database
-   [Web external](https://docs.newrelic.com/docs/accounts-partnerships/education/getting-started-new-relic/glossary#web-external)
-   Memcache
-   Request queuing time

This describes how to use the REST API (v2) to obtain the data shown on the **Web transaction time** chart.

> #### ⚠️ IMPORTANT
>
> While the examples utilize New Relic's REST API v2, we recommend using [NRQL functions](https://docs.newrelic.com/docs/nrql/get-started/introduction-nrql-new-relics-query-language/) for executing metric timeslice queries. Each API value can be mapped to an equivalent NRQL function. To learn how to create NRQL queries based on these API examples, refer to our [documentation](https://docs.newrelic.com/docs/apis/rest-api-v2/migrate-to-nrql/).

## General API values [#general]

When making your own calculations, be aware of the following:

-   You can change the [default time range (30 minutes)](https://docs.newrelic.com/docs/apm/apis/requirements/specifying-time-range-api-v2#api-call) used in these examples.
-   The time range you specify must be consistent in **all** of these queries; otherwise the final calculations will be incorrect.
-   The `HttpDispatcher:call_count` is used in almost every calculation, but you only need to acquire it once for your specified time range.
-   You must replace the `${APP_ID}` and `${API_KEY}` variables in these examples with your specific [application ID](https://docs.newrelic.com/docs/apm/apis/requirements/identification-code) and [API key](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/rest-api-key#viewing).

## HttpDispatcher [#HttpDispatcher]

The overlaid `response time` line on the **Web transaction time** chart represents the `Request queuing` time combined with the `HttpDispatcher` time. The `HttpDispatcher:average_response_time` is the total response time for your web application without the request queuing time and is obtained directly. It is not used to calculate the application total time.

Use the following command to obtain this metric:

```bash
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
     -H "X-Api-Key:${API_KEY}" -i \
     -d 'names[]=HttpDispatcher&values[]=average_response_time'
```

## Application total time [#app-total-time]

The `Application total time` refers to your New Relic agent language (Java/JVM time, PHP, Python, etc.). This includes all the processing time that is **not** attributed to other values on the chart **except** for the `Request queuing` time and the `HttpDispatcher` time. This is why you must calculate the other components first.

Use this equation to determine the `Application total time`:

```
Application total time = <a href="#web-tx-total-time">WebTransactionTotalTime</a> - <a href="#datastore">Datastore time</a> - <a href="#database">Database time</a> - <a href="#ruby_database">(Ruby) Database</a> - <a href="#web_external">Web external</a> - <a href="#memcache">Memcache</a>
```

Each of the values in this equation are described in detail later in this document.

| **Application total time calculation**        | **Comments**                                                                                                                                                                                                                                                             |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Terms                                         | Not all the terms in the equation may apply. If the corresponding data does not appear for your application, the corresponding terms may be ignored.                                                                                                                     |
| Datastore and Database                        | The `Datastore time`, `Database time`, and `(Ruby) Database` values [are not the same](#datastore-v-database). As of February 2015, `Datastore` is being phased in to replace Database. Also, the [Ruby agent](#ruby_database) stores data in a slightly different form. |
| Memcache                                      | The [`Memcache`](#memcache) term may not exist for all applications.                                                                                                                                                                                                     |
| Request queuing time                          | The `Request queuing` time (if it exists) may appear in the chart in the UI, but it is not involved in the calculations. It is presented simply as a convenience.                                                                                                        |
| Response time                                 | The `Response time` may appear in the chart in the UI as an overlaid line. This time is not involved in the calculation for application total time.                                                                                                                      |
| Web transaction total time vs. HttpDispatcher | If your application does not report a [`WebTransactionTotalTime` metric](#web-tx-total-time), then use the `HttpDispatcher` metric. The `WebTransactionTotalTime` metric is only present in more recent agents which may exhibit asynchronous behavior.                  |

## Web transaction total time [#web-tx-total-time]

The `WebTransactionTotalTime` is the total execution time for your web application and is obtained directly. Use the following command:

```bash
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \ 
     -H "X-Api-Key:${API_KEY}" -i \ 
     -d 'names[]=WebTransactionTotalTime&values[]=average_response_time'
```

## Datastore vs. database [#datastore-v-database]

As of February 2015, the New Relic agents display the database time separated into specific database types. For specific agent version requirements, see [Databases and slow queries feature availability](https://docs.newrelic.com/docs/apm/applications-menu/monitoring/databases-slow-queries-page#availability).

These New Relic agents will replace the `Database` metric name with `Datastore/${DBTYPE}`, where `${DBTYPE}` identifies the appropriate database; for example, Postgres, MongoDB, Microsoft SQL Server, ODBC, Redis, SQLite, Memcached, Solr, Elasticsearch, etc.

## Datastore total time [#datastore]

If your **Web transaction time** chart shows the generic **Database** category, don't use these calculations. Instead, use the [Database](#database) calculations.

The `Datastore` total time is a derived value. To calculate it, use this equation:

```
Datastore time = ( Datastore/${DBTYPE}/allWeb:average_response_time * Datastore/${DBTYPE}/allWeb:call_count ) / HttpDispatcher:call_count
```

The `${DBTYPE}` represents the type of database reported; for example, Postgres, ODBC, Redis, MongoDB, MySQL, Microsoft SQL Server, SQLite, Cassandra, Memcached, etc. Substitute the database name as appropriate.

To obtain the data for this calculation, use the following commands.

-   HttpDispatcher:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=HttpDispatcher&values[]=call_count'
    ```
-   Datastore/${DBTYPE}/allWeb:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=Datastore/${DBTYPE}/allWeb&values[]=call_count'
    ```
-   Datastore/${DBTYPE}/allWeb:average_response_time

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=Datastore/${DBTYPE}/allWeb&values[]=average_response_time'
    ```

You can also perform this operation in a single command:

```bash
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
     -H "X-Api-Key:${API_KEY}" -i \
     -d 'names[]=Datastore/MongoDB/allWeb&names[]=HttpDispatcher&values[]=average_response_time&values[]=call_count'
```

## Database total time [#database]

If you are using a Ruby agent older than 3.11.0, do not use these calculations. Instead, use the [(Ruby) Database](#ruby_database) calculations.

The `Database` total time is a derived value. To calculate it, use this equation:

```
Database time = ( Database/allWeb:average_response_time * Database/allWeb:call_count ) / HttpDispatcher:call_count
```

To obtain the data for this calculation, use the following commands.

-   HttpDispatcher:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=HttpDispatcher&values[]=call_count'
    ```
-   Database/allWeb:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=Database/allWeb&values[]=call_count'
    ```
-   Database/allWeb:average_response_time

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=Database/allWeb&values[]=average_response_time'
    ```

## (Ruby) Database total time [#ruby_database]

If you are **not** using a Ruby agent, use the calculations to obtain the [Database](#database) value. These values are only provided by the Ruby agent versions 3.10.0.279 or lower. Ruby agent version 3.11.0 or higher uses [Datastore](#datastore) values instead.

The `(Ruby) Database` total time is a derived value. To calculate it, use this equation:

```
(Ruby) Database = ( ActiveRecord/all:average_response_time * ActiveRecord/all:call_count ) / HttpDispatcher:call_count
```

To obtain the data for this calculation, use the following commands.

-   HttpDispatcher:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=HttpDispatcher&values[]=call_count'
    ```
-   ActiveRecord/all:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=ActiveRecord/all&values[]=call_count'
    ```
-   ActiveRecord/all:average_response_time

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=ActiveRecord/all&values[]=average_response_time'
    ```

## Memcache total time [#memcache]

If available, the `Memcache` response time is a derived value. (Not all applications will have `Memcache` response time.) To calculate it, use this equation:

```
Memcache = ( Memcache/allWeb:average_response_time * Memcache/allWeb:call_count ) / HttpDispatcher:call_count
```

To obtain the data for this calculation, use the following commands.

-   HttpDispatcher:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=HttpDispatcher&values[]=call_count'
    ```
-   Memcache/allWeb:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=Memcache/allWeb&values[]=call_count'
    ```
-   Memcache/allWeb:average_response_time

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.xml" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=Memcache/allWeb&values[]=average_response_time'
    ```

## Web external total time [#web_external]

The `Web external` total time is a derived value. To calculate it, use this equation:

```
Web external = ( External/allWeb:average_response_time * External/allWeb:call_count ) / HttpDispatcher:call_count
```

To obtain the data for this calculation, use the following commands.

-   HttpDispatcher:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=HttpDispatcher&values[]=call_count'
    ```
-   External/allWeb:call_count

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=External/allWeb&values[]=call_count'
    ```
-   External/allWeb:average_response_time

    ```bash
    curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
         -H "X-Api-Key:${API_KEY}" -i \
         -d 'names[]=External/allWeb&values[]=average_response_time'
    ```
