AppDynamics Application Analytics provides built-in support for collecting analytics data from various types of sources, such as agent-instrumented Java applications, .NET applications, browser applications, and more. The Analytics Events API lets you supplement the built-in analytics data sources with your own custom data sources and event types. 

The custom events collected by the Analytics Events API are metered and are in addition to the transaction events published by the app agents. Publishing custom events requires Transaction Analytics licensing. Transaction Analytics license units determine the limit on the volume of custom events that you can publish. 

About the Analytics Events API

In Application Analytics, an event encapsulates a unit of analytics data. In APM, for example, each event corresponds to a method or service invocation, whether an entry point service or downstream service.

With the Analytics API, you define the structure of your own custom event in the data store, capture the event records as they occur in your custom source, and send them to the Events Service, the data store for Analytics. Once your data is in the Events Store, users can query your data through the Controller UI or the Analytics Events API.

Analytics Events API uses a shared key to authenticate clients to the Events Service. As a Controller or Analytics Administrator, you can generate API keys from the Controller UI, see Managing API Keys for information.

A transaction analytics license is required for using the Events Service API. The same licensing model that applies to business transactions for custom events (based on the number of events per unit/day) applies to the API. 

Addressing the Events Service Data Store

Unlike most AppDynamics REST APIs, which are presented at the Controller, you access the Analytics Events API by addressing the Events Service instance in the AppDynamics platform.

You address the Events Service at one of the following URLs:

RegionURL
North America
https://analytics.api.appdynamics.com 
Europe
https://fra-ana-api.saas.appdynamics.com
APAC
https://syd-ana-api.saas.appdynamics.com
"https://<events_service_endpoint>:9080/events/"
XML

For an on-premises Events Service, address the Events Service instance host (or more likely, the virtual IP presented by a load balancer for the Events Service cluster). Use the primary listening port for the Events Service, 9080, by default. 

Calls to the Analytics Events API need to specify the <global_account_name> for the Controller account being address, and the <api_key> generated by the administrator for this client. The API expects the values as headers, property-value pairs that are separated by a colon. As cURL arguments, for example, the values would be passed with curl through the `-H` or `--header option` as follows:

-H"X-Events-API-AccountName:<global_account_name>" -H"X-Events-API-Key:<api_key>"

You can get the global account name to use from the License page in the Controller UI. The API keys are described in Managing API Keys

The content type, also as a cURL argument, is:

-H"Content-type: application/vnd.appd.events+json;v=2" 

AppDynamics strongly recommends the use of SSL/HTTPS to access the API. Otherwise, the API key is sent in plain text.

For security reasons, the Analytics Events API, by default, does not accept cross-origin HTTP requests, such as from links embedded directly in web pages.

Data Format

The Analytics Events API takes events as JSON-formatted name-value pair data.

Before sending data that conforms to a custom events schema, you need to define the data structure for the custom schema. The Events Service matches incoming events data to the appropriate schema.

Supported Data Types

  • string
  • integer
  • float
  • boolean
  • date - Supported time formats include:
    • ISO 8601 format: yyyy-MM-dd'T'HH:mm:ss.SSSZZ
    • UNIX epoch date format: A 13-digit number representing the number of seconds/milliseconds since UNIX epoch time (Jan 1 1970). For example, (GMT): Mon, 17 Apr 2017 23:46:22 GMT would be 1492472782000.

Naming Restrictions

Custom event names and field names must conform to the following:

  • Contain only a-z, A-Z, _ (underscore), 0-9 
  • Names can not start with a number.

Timestamp Fields

Two implicit timestamp fields are automatically added to custom schemas:

  • eventTimestamp
  • pickupTimestamp

The eventTimestamp field represents the time an event occurred. An API client can specify a value for the timestamp field when it creates an event. If it does not, the Analytics Events API uses the same value for eventTimestamp as it uses for another implicit field, pickupTimestamp. The pickupTimestamp field, which is always populated by the Event Service, represents the time the event was received by the Event Service. 

You can express the timestamp fields using ISO 8601 or UNIX epoch time (64-bit milliseconds) format. 

Example API Call Flow

The following steps take you through an on-premises API call workflow for using the Analytics Events API. The steps show cURL examples for creating a schema, publishing an event to that schema, and then querying the event. 

For SaaS deployments, replace the value for the URL and port in the examples (<events_service_endpoint>:9080) to your SaaS URL.


  1. Define the schema by associating field names with data types. For example, the following defines a Purchase event type: 

    curl -X POST "<events_service_endpoint>:9080/events/schema/myProducts" -H"X-Events-API-AccountName:customer1_1234-567a-bccc-123" -H"X-Events-API-Key:a123b456-c789-1d23-e456-nnn" -H"Content-type: application/vnd.appd.events+json;v=2" -d '{"schema" : { "id": "string", "productBrand": "string", "userRating": "integer", "price": "float", "productName": "string", "description": "string" } }'
  2. Publish an event based on the schema you created:  

    curl -X POST "<events_service_endpoint>:9080/events/publish/myProducts" -H"X-Events-API-AccountName:customer1_1234-567a-bccc-123" -H"X-Events-API-Key:a123b456-c789-1d23-e456-nnn" -H"Content-type: application/vnd.appd.events+json;v=2" -d '[{"id": "5653b879ab33a","productBrand": "ACME","userRating": 3,"price": 2006.41,"productName": "Watch","description": "new watch"},{"id": "5653b879700","productBrand": "Widget","userRating": 1,"price": 3800.13,"productName": "Watch","description": "2015 watch"}]'
  3. Query the event data:

    curl -X POST "http://<events_service_endpoint>:9080/events/query" -H"X-Events-API-AccountName:customer1_7xxx-467a-bccc-xxx" -H"X-Events-API-Key:a123b456-c789-1d23-e456-nnn" -H"Content-type: application/vnd.appd.events+text;v=2" -d 'SELECT * FROM myProducts'

If including fields with ADQL keywords, enclose the keywords in single quotes. These keywords include, for example, betweeninselect, and others. 

For a single query request, use this content type:

-H"Content-type: application/vnd.appd.events+text;v=2" 

In a multi-query request, the queries are passed as JSON body text. In this case, use the following content type header:

-H"Content-type: application/vnd.appd.events+json;v=2"

Custom Event Ingestion Limits

Controller ingestion of custom events has the following limits:

  • Fields: 255 maximum per event type
  • String attributes: 4 kb maximum length
  • Batch total count: 1000 events per call
  • Batch total size: 5 Mb maximum per call
  • Max custom events for an account: 20
    • Business journey schemas are counted towards the limit of 20.

Publish Events

The Publish Events API call takes an array of events and stores them in the Event Service storage. The data must comply with an existing schema. A single request cannot publish to multiple event types. 

If the event data doesn't match an event schema, the Events Service makes a best-effort attempt to match the data to the schema and returns a 400 bad request if unsuccessful. 

Format

POST https://analytics.api.example.com/events/publish/{schemaName}
CODE
POST http://<events_service_endpoint>:9080/events/publish/{schemaName}

Query Params

N/A

Path Parameters

NameDescription

accountId

Account ID
schemaName

Event schema name

Headers

NameDescription
X-Events-API-AccountNameThe global account name, as shown in the Controller UI License page.
X-Events-API-KeyThe Analytics API key. See Managing API Keys for more information.
Content-TypeThe Content-Type of the request body. The default is "application/vnd.appd.events+json;v=2" which also versions the resource representation (v=2).

Example SaaS Publish Request

POST https://analytics.api.example.com/events/publish/{schemaName}
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Content-Type: application/vnd.appd.events+json;v=2
Accept: application/vnd.appd.events+json;v=2
{
   "schema" : {
      "account": "integer",
      "amount": "float",
      "product": "string"
   }
}
CODE

Example response

HTTP/1.1 202 ACCEPTED
CODE

Error Codes

Error CodeDescription
400The given request was invalid.
401The given authentication information provided in the authorization header was invalid.
404No event type could be found for this account.
406The "Accept" header was not "application/vnd.appd.events+json;v=2".
413The request body is larger than the max allowed size.
415The "Content-Type" header was not "application/vnd.appd.events+json;v=2".
429Too many requests. Returned when account or event reaches limits.

Create Event Schema

You use this API method to create your own event schema. The schema defines the overall structure of an event type by field and type. 

You only need to use this method if the event you are uploading does not match an existing schema for first class event types (such as logs or transactions). Events that conform to an existing schema automatically match that schema. Be sure to review the supported data types and naming restrictions described earlier in this topic.

Format

POST https://analytics.api.example.com/events/schema/{schemaName}
CODE
POST http://<events_service_endpoint>:9080/events/schema/{schemaName}

Path Params

NameDescription
accountIdAccount ID
schemaName

Event schema name

Query Params

N/A

Headers

Name
Description
X-Events-API-AccountNameThe global account name, as shown in the Controller UI License page.
X-Events-API-KeyThe Analytics API key. See Managing API Keys for more information.
AcceptThe Content-Type of the response body. The supported value is "application/vnd.appd.events+json;v=2".
Content-typeThe Content-Type of the request body. The default is "application/vnd.appd.events+json;v=2" which also versions the resource representation (v=2).


Example SaaS Create Request

POST http://analytics.api.example.com/events/schema/{schemaName} HTTP/1.1
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Content-Type: application/vnd.appd.events+json;v=2
Accept: application/vnd.appd.events+json;v=2
{
   "schema" : {
      "account": "integer",
      "amount": "float",
      "product": "string"
   }
}

Example response

HTTP/1.1 201 CREATED

Retrieve Event Schema

Use this API to retrieve an existing event schema.

Format

GET http://analytics.api.example.com/events/schema/{schemaName}
CODE
GET http://<events_service_endpoint>:9080/events/schema/{schemaName}


Path Params 

Name
Description
accountIdAccount ID
schemaNameEvent schema name

Query Params

N/A

Headers

Name
Description
X-Events-API-AccountNameThe global account name, as shown in the Controller UI License page.
X-Events-API-KeyThe Analytics API key. See Managing API Keys for more information.
AcceptThe Content-Type of the response body. The supported value is "aapplication/vnd.appd.events+json;v=2".

Example SaaS Retrieve Request

GET http://analytics.api.example.com/events/schema/{schemaName} HTTP/1.1
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Accept: application/vnd.appd.events+json;v=2

Example Response

HTTP/1.1 200 OK
{
   "schema" : {
      "account": "integer",
      "amount": "float",
      "product": "string"
   }
}

Update Event Schema

Use this API to update an existing event schema by field. The request body defines the updates to be applied to the event schema.

As shown in the example below, you specify each field update action as a named section in the request body. The actions are represented by these fields:

  • add field
  • rename field

For the add field definition, you need to specify the data format for the new field, as you would when creating the event schema.

The response to this call should be the complete event schema as modified.

Format

PATCH http://analytics.api.example.com/events/schema/{schemaName}
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
PATCH http://<events_service_endpoint>:9080/events/schema/{schemaName}
XML

Path Parameters

NameDescription
accountIdAccount id
schemaNameEvent schema name

Query Params

N/A

Headers

NameDescription
X-Events-API-AccountNameThe global account name, as shown in the Controller UI License page.
X-Events-API-KeyThe Analytics API key. See Managing API Keys for more information.
AcceptThe Content-Type of the response body. The supported value is "application/vnd.appd.events+json;v=2".
Content-typeThe Content-Type of the request body. The default is "application/vnd.appd.events+json;v=2" which also versions the resource representation (v=2).

Example SaaS Update Event Request

PATCH http://analytics.api.example.com/events/schema/{schemaName} HTTP/1.1
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Content-type: application/vnd.appd.events+json;v=2
Accept: application/vnd.appd.events+json;v=2
  
[
  {
    "add": {
      "newfield": "integer"
    },
    "rename": {
      "oldname": "newname",
      "oldname2": "newname2"
    }
  }
]

Example Response

HTTP/1.1 200 OK

Delete Event Schema

Use this API to delete an existing event schema.

Format

DELETE http://<events_service_endpoint>:9080/events/schema/{schemaName}
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
DELETE http://<events_service_endpoint>:9080/events/schema/{schemaName}
XML

Path Params

NameDescription
accountIdAccount id
eventTypeEvent schema name

Query Params

N/A

Headers

NameDescription
X-Events-API-AccountNameThe global account name, as shown in the Controller UI License page.
X-Events-API-KeyThe Analytics API key. See Managing API Keys for more information.
AcceptThe Content-Type of the response body. The following is the supported value: application/vnd.appd.events+json;v=2

Example SaaS Delete Request

DELETE http://analytics.api.example.com/events/schema/{schemaName} HTTP/1.1
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Accept: application/vnd.appd.events+json;v=2

Querying Events

When querying analytics events data, the following apply:

  • Every Events Service API has a limit of 200 searches per minute by each account on each event type.

  • The Multi-Query Events API is limited to twenty queries per HTTP request.
  • The Analytics Query API can return a maximum of 10,000 results.
  • Limits work differently for aggregation and non-aggregation queries. Because we use the limits specified in the ADQL query as the bucket count limit, it isn’t possible to use it as the overall result count limit as well. Therefore, the URL parametric limit is used for the overall limit. In the case of non-aggregation queries, there is no bucket limit, so the limit specified in the ADQL query is taken as the row count limit and URL parametric limit becomes the second place to look for it if ADQL query doesn't specify a limit.
    • For aggregation queries: the total returned row count is limited by the limit in the URL query parameter, and is not directly related to the limits specified in the ADQL query statement itself. The limits in the ADQL query apply only to bucket counts in aggregations.
    • For non-aggregation queries: If LIMIT is not specified in the SELECT statement, the value specified in the URL query parameter is used. If the limit query parameter is also absent the default is 100.

Query Events (Single Query)

There are two ways to use the query events APIs, either as a simple text format query or as a JSON-formatted query. The JSON-formatted query can accommodate multiple queries per call and is described in Query Events (Multiple Queries)

An event type might search against multiple event types. Therefore, the event type is not provided in the URL path or as a query parameter, but as part of the ADQL query provided in the request body itself. Your ADQL queries must adhere to the syntax described in the ADQL Reference.

This section describes the single query form for querying events. 

Format

POST http://analytics.api.example.com/events/query?limit=20
XML
POST http://<events_service_endpoint>:9080/events/query
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Content-type: application/vnd.appd.events+text;v=2

Query Params

Name
Description
start

Filter results based on the minimum event time stamp, specified in ISO 8601 time (https://en.wikipedia.org/wiki/ISO_8601) or Unix time (http://en.wikipedia.org/wiki/Unix_time). If not specified, then the default is no minimum time stamp filtering. Note that data returned will always be limited by the data retention.

Specify the time in combined UTC date and time format or epoch milliseconds.

Start time is inclusive of limiting timestamps.

end

Filter results based on the maximum event time stamp, specified in ISO 8601 time (https://en.wikipedia.org/wiki/ISO_8601) or Unix time (http://en.wikipedia.org/wiki/Unix_time). If not specified, then the default is no maximum time stamp filtering. Note that data returned will always be limited by the data retention.

Specify the time in combined UTC date and time format or epoch milliseconds.

End time is inclusive of limiting timestamps.

limit

Limits the number of results returned. The default value is 100. The upper limit on the results that can be fetched is 10,000.

Headers

Name
Description
X-Events-API-AccountNameThe global account name, as shown in the Controller UI License page.
X-Events-API-KeyThe Analytics API key. See Manage API Keys for more information.
AcceptThe Content-Type of the response body. The supported value is "application/vnd.appd.events+json;v=2".
Content-typeThe Content-Type of the request body. The default is "application/vnd.appd.events+text;v=2" which also versions the resource representation (v=2).

Example SaaS Query Request

POST http://analytics.api.example.com/events/query?start=1422823420000&end=1423687476000&limit=20000 HTTP/1.1
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Content-Type: application/vnd.appd.events+text;v=2
Accept: application/vnd.appd.events+json;v=2
 
SELECT * FROM county WHERE size>=30 AND population>20000


Query Events (Multiple Queries)

Use this API to execute multiple queries against a particular account and event type in parallel. A query event that specifies multiple queries does so by including multiple ADQL queries in the body of the request. Your ADQL queries must adhere to the syntax described in the ADQL Reference.

The advantage of using queries in this form is that it takes advantage of certain backend optimizations in query performance. Query filter criteria, such as time range and limit, can be overridden by each inner query.

The Multi-Query Events API is limited to twenty queries per HTTP request.

Format

POST http://analytics.api.example.com/events/query?limit=20
XML
POST http://<events_service_endpoint>:9080/events/query
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key> 

Path Params

None

Query Params

Name
Description
start

Filter results based on the minimum event time stamp, specified in ISO 8601 time (https://en.wikipedia.org/wiki/ISO_8601) or Unix time (http://en.wikipedia.org/wiki/Unix_time). If not specified, then the default is no minimum time stamp filtering.

Specify the time in combined UTC date and time format or epoch milliseconds.

Start time is inclusive of limiting timestamps.

end

Filter results based on the maximum event time stamp, specified in ISO 8601 time (https://en.wikipedia.org/wiki/ISO_8601) or Unix time (http://en.wikipedia.org/wiki/Unix_time). If not specified, then the default is no maximum time stamp filtering.

Specify the time in combined UTC date and time format or epoch milliseconds.

End time is inclusive of limiting timestamps.

limit

Limits the number of results returned. The default value is 100. The upper limit on the results that can be fetched is 10,000.

Headers

Name
Description
X-Events-API-AccountNameThe global account name, as shown in the Controller UI License page.
X-Events-API-KeyThe Analytics API key. See Managing API Keys for more information.
AcceptThe Content-Type of the response body. The supported value is "application/vnd.appd.events+json;v=2".
Content-typeThe Content-Type of the request body. The default is "application/vnd.appd.events+json;v=2" which also versions the resource representation (v=2).

Payload

Field
Description
label(Optional) Friendly name to identify the query.
queryADQL query to execute.
start(Optional) Overrides the start parameter value provided as a query parameter.
end(Optional) Overrides the end parameter value provided as a query parameter.
limit(Optional) Overrides the limit provided as a query parameter.

Example SaaS Multiple Query Request

POST http://analytics.api.example.com/events/query?limit=100 HTTP/1.1
X-Events-API-AccountName:<global_account_name>
X-Events-API-Key:<api_key>
Content-Type: application/vnd.appd.events+json;v=2
Accept: application/vnd.appd.events+json;v=2
[
    {
      "label": "high_population",
      "query": "SELECT * FROM county WHERE population>50000",
      "limit": 10,
      "start": "2017-02-23T0:0:0Z",
      "end": "2017-03-1T0:0:0Z"
    },
    {
      "label": "small_area",
      "query": "SELECT * FROM county WHERE size<25",
      "start": "2017-02-23T0:0:0Z",
      "end": "2017-03-1T0:0:0Z"
    },
    {
      "label": "high_population_density",
      "query": "SELECT * FROM county WHERE population>50000 AND size<25",
      "limit": 100,
      "start": "2017-02-23T0:0:0Z",
      "end": "2017-03-1T0:0:0Z"
    }
]

Example Response

HTTP/1.1 200 OK
[
  {
    "label": "high_population",
    "total": 30,
    "fields": [ ... ],
    "results": [ ... ]
  },
  {
    "label": "small_area",
    "total": 50,
    "fields": [ ... ],
    "results": [ ... ]
  },
  {
    "label": "high_population_density",
    "total": 10,
    "fields": [ ... ],
    "results": [ ... ]
  }
]