APM Insight Report Functions - Via Custom Queries

APM Insight Report Functions - Via Custom Queries

Ready-made reports for APM Insight: HTTP errors, transaction health and SLA breaches.
For AppManager servers that use the PostgreSQL (pgsql) database.

Available reports

ReportWhat it showsFunction
Errors per application4xx and 5xx error counts for each applicationapm_app_error_split
Top error transactionsThe transactions causing the most errorsapm_txn_error_split
Transaction healthHow many transactions are Critical or Clearapm_txn_health
SLA breachesHow many transactions are slower than 2 s, 4 s or 10 sapm_txn_sla
SLA breached transactionsWhich transactions are slower than your limitapm_txn_sla_breaches

Install

  1. Download Attached Zip File, and extract to get InstallAPMInsightReportFunctions.bat  Script
  2. Copy InstallAPMInsightReportFunctions.bat into <APM home>\bin. Example: D:\tools\APM\AppManager\bin
  3. Open a command prompt as Administrator in that folder.
  4. Run the file:
InstallAPMInsightReportFunctions.bat
When it finishes you'll see a list of 11 installed functions. Notices about functions that "do not exist" on the first install are normal.

Install on every AppManager server whose data you want to report on. Running it again is safe.

Run a report

Run reports from the Query Tool, or save them as a Custom Query Report (see Save, schedule or monitor below). Each report is one line:

SELECT * FROM apm_txn_health('30m')

Choose the time period

The first value is how far back to look. Write a number followed by a unit, in single quotes.

UnitLetterExampleMeans
Secondss'90s'last 90 seconds
Minutesm'30m'last 30 minutes default
Hoursh'2h'last 2 hours
Daysd'7d'last 7 days
Weeksw'2w'last 2 weeks
  • If you leave the time period out, the last 30 minutes are used.
  • A number without a unit means minutes: '45' is the last 45 minutes.
  • Decimals work: '1.5h' is the last 90 minutes.
  • Longer periods only include data that's still stored.

Choose applications

Reports cover all applications by default. To report on specific ones, add their IDs at the end:

SELECT * FROM apm_app_error_split('1d', ARRAY[10000364])

To list your application IDs:

SELECT DISTINCT p.applicationid, mo.displayname FROM apm_partitioninfo p JOIN am_managedobject mo ON mo.resourceid = p.applicationid ORDER BY 2
applicationiddisplayname
10000364Ecommerce App

Example result.

Errors per application

The number of 4xx and 5xx errors for each application.

SELECT * FROM apm_app_error_split('30m')
ColumnMeaning
applicationidApplication ID
displaynameApplication name
count_4xx4xx Client errors, such as a bad request or page not found
count_5xx5xx Server errors
total_errorsBoth together

Result

applicationiddisplaynamecount_4xxcount_5xxtotal_errors
10000364Ecommerce App202

Example: Ecommerce App had two 4xx errors and no 5xx errors.

Top error transactions

The transactions with the most 4xx and 5xx errors, per application. The second value is how many to show.

SELECT * FROM apm_txn_error_split('30m', 10)
ColumnMeaning
applicationid, displaynameThe application
transactionidTransaction ID
transactionnameThe transaction, for example a URL
txn_typeTransaction type, such as HTTP
iskeytxn1 if it's a business transaction
count_4xx, count_5xxIts 4xx and 5xx errors
total_errorsBoth together

Result

applicationiddisplaynametransactionidtransactionnametxn_typeiskeytxncount_4xxcount_5xxtotal_errors
10000364Ecommerce App10000062/checkout/paymentHTTP0202

Example: one transaction, /checkout/payment, returned two 4xx errors.

Transaction health

Shows how many transactions are Critical and how many are Clear. A transaction is Critical when it's slow or has too many errors.

SELECT * FROM apm_txn_health('30m')
By default, slow means an average response time of 0.5 seconds or more, and too many errors means 1% or more.

Settings

Add settings in this order, separated by commas. You can stop after any of them; the rest keep their defaults.

#SettingDefaultExample
1Time period'30m''1d'
2Slow from this response time, in milliseconds5002000 = 2 seconds
3Too many errors from this error %15
4Critical when'or'see below
5Business transactions onlyfalsetrue
6ApplicationsallARRAY[10000364]

Setting 4 decides which checks count:

ValueMeaning
'or'Critical if slow or too many errors
'and'Critical only if slow and too many errors
'rt'Critical if slow; errors are ignored
'err'Critical if too many errors; response time is ignored

Examples

Slower than 2 seconds, or more than 5% errors

SELECT * FROM apm_txn_health('30m', 2000, 5)

Slower than 2 seconds, ignoring errors

SELECT * FROM apm_txn_health('30m', 2000, 1, 'rt')

With 'rt' the error value (1 here) is ignored, but it still has to be there.

Business transactions only, default limits

SELECT * FROM apm_txn_health('30m', 500, 1, 'or', true)

Result

applicationiddisplaynamecriticalcleartotal
10000364Ecommerce App9110119

Example: 119 transactions had traffic in the time period. 9 were Critical and 110 Clear.

SLA breaches

Shows how many transactions are slower than each limit you give.

SELECT * FROM apm_txn_sla('30m', ARRAY[2000,4000,10000])

Settings

#SettingDefault
1Time period'30m'
2Limits, in millisecondsARRAY[2000,4000,10000] (2 s, 4 s and 10 s)
3Business transactions onlyfalse
4Applicationsall

Result

applicationiddisplaynamethreshold_msbreachedtotalbreach_pct
10000364Ecommerce App200011190.84
10000364Ecommerce App400011190.84
10000364Ecommerce App1000011190.84

Example: one row per limit. 1 of 119 transactions was slower than 2 s, and the same one was slower than 10 s.

SLA breached transactions

Lists the transactions that are slower than a response-time limit, slowest first.

SELECT * FROM apm_txn_sla_breaches('30m', 2000)

Settings

#SettingDefault
1Time period'30m'
2Limit, in milliseconds2000 (2 seconds)
3Business transactions onlyfalse
4Applicationsall
ColumnMeaning
applicationid, displaynameThe application
transactionidTransaction ID
transactionnameThe transaction, for example a URL
txn_typeTransaction type, such as HTTP
iskeytxn1 if it's a business transaction
avg_response_msAverage response time in the time period, in milliseconds
requestsNumber of requests in the time period

Result

applicationiddisplaynametransactionidtransactionnametxn_typeiskeytxnavg_response_msrequests
10000364Ecommerce App10000087/orders/exportHTTP01248036

Example: one transaction averaged about 12.5 seconds over 36 requests.

Save, schedule or monitor

Save as a Custom Query Report

  1. Go to Settings > Reporting > Custom Query Report and click Create New Report.
  2. Fill in the fields:
FieldWhat to enter
Report NameA name, for example Transaction health, last 30 minutes
DescriptionWhat the report shows
QueryOne of the queries on this page
Execute query onOn an Admin Server only: Choose the Managed Servers to run it on
Note: APMInsight Raw data resides only in Managed Servers
  1. Save the report. To see the results, open it and click Process.
If you choose Managed Servers, install the functions on each of them.

Schedule it

  1. Go to Settings > Schedule Report.
  2. Choose Custom Query Report as the report type and select your report.
  3. Under Time Settings, choose Hourly, Daily, Weekly or Monthly, and pick PDF or Excel.

Scheduled reports are sent by email.

Monitor it

Add a Database Query Monitor for the AppManager PostgreSQL database and use the same query. The results are then collected on every poll.

More details: Custom Query Report help

Good to know

No results? There may have been no traffic in that period. Try '7d'.
Health and SLA use averages. One slow request in a busy transaction won't mark it Critical.

Remove

Open the database console from <APM home>\bin:

DBConfiguration.bat -u dbuser

Then paste:

DROP FUNCTION IF EXISTS apm_txn_health(integer, bigint, numeric, text, boolean, bigint[]);
DROP FUNCTION IF EXISTS apm_txn_error_split(integer, integer, bigint[]);
DROP FUNCTION IF EXISTS apm_app_error_split(integer, bigint[]);
DROP FUNCTION IF EXISTS apm_txn_sla_breaches(text, bigint, boolean, bigint[]);
DROP FUNCTION IF EXISTS apm_txn_sla(text, bigint[], boolean, bigint[]);
DROP FUNCTION IF EXISTS apm_txn_health(text, bigint, numeric, text, boolean, bigint[]);
DROP FUNCTION IF EXISTS apm_txn_error_split(text, integer, bigint[]);
DROP FUNCTION IF EXISTS apm_app_error_split(text, bigint[]);
DROP FUNCTION IF EXISTS apm_union_err(bigint, bigint[], boolean);
DROP FUNCTION IF EXISTS apm_union_txn(bigint, bigint[]);
DROP FUNCTION IF EXISTS apm_window_ms(text);