RousselTMLEARNING

TP · New Relic: from discovery to expertise

Lab: Investigate with NRQL and build a dashboard with correction

The correction is integrated into the TP (See the green boxes)

What you will learn in this TP
  • Choose the right NRQL function for each question
  • Compare two periods
  • Build a dashboard with a variable
  • Export a dashboard
Mode :

All steps and instructions are shown. Recommended for this lab: semi-guided

Introduction #

Context. The product manager wants a single dashboard to follow the shop, and figures to answer their questions: which orders are slow, how many fail, is it worse than yesterday?

Prerequisites: a free New Relic account (license key), a machine with Docker, curl and jq  ·  Estimated time: 45 min

Five NRQL analysis queries and a four-widget "Boutique" dashboard, exported as JSON.

Setup #

Guided steps, with their solution.

  1. 1. Measure perceived latency

    Why? The average hides slow orders; percentiles show them.

    Compare average, median, p95 and p99 of duration for boutique-tp, then show the distribution.
    See the correction
    SELECT average(duration), median(duration), percentile(duration, 95, 99) FROM Transaction WHERE appName = 'boutique-tp' SINCE 1 hour ago
    SELECT histogram(duration, 2, 20) FROM Transaction WHERE appName = 'boutique-tp' SINCE 1 hour ago
  2. 2. Compute an error rate

    Why? A percentage compares across periods, a raw count depends on traffic.

    Compute the error rate in a single query, as a chart, and compare it with the day before.
    See the correction
    SELECT percentage(count(*), WHERE error IS true) AS 'Erreurs %' FROM Transaction WHERE appName = 'boutique-tp' SINCE 3 hours ago COMPARE WITH 1 day ago TIMESERIES
  3. 3. Categorize orders

    Why? Readable categories speak to product better than milliseconds.

    Split transactions into fast (< 0.5 s), ok (< 2 s) and slow, then count 2xx and 5xx in the same query with filter().
    See the correction
    SELECT count(*) FROM Transaction WHERE appName = 'boutique-tp' FACET CASES(WHERE duration < 0.5 AS 'fast', WHERE duration < 2 AS 'ok', WHERE duration >= 2 AS 'slow') SINCE 1 hour ago
    SELECT filter(count(*), WHERE http.statusCode < 300) AS '2xx', filter(count(*), WHERE http.statusCode >= 500) AS '5xx' FROM Transaction WHERE appName = 'boutique-tp' TIMESERIES
  4. 4. Link traces and logs

    Why? Logs in context carry the trace ID: you find the lines of a failed request.

    Find the trace.id of a failed transaction, then the logs carrying that same ID.
    See the correction
    SELECT traceId, name, duration FROM Transaction WHERE appName = 'boutique-tp' AND error IS true SINCE 1 hour ago LIMIT 5
    SELECT timestamp, level, message FROM Log WHERE trace.id = '<traceId copié>' SINCE 1 hour ago
  5. 5. Build the dashboard

    Why? A shared board saves everyone from rewriting the same queries and gives a common view during an incident.

    Create the Boutique dashboard with an app variable (query on appName) and four widgets: Apdex (billboard with thresholds), throughput and errors (line), p95 per transaction (bar, facet linking on), distribution (histogram). Then export the JSON (Copy JSON to clipboard).
    See the correction
    -- Variable app : SELECT uniques(appName) FROM Transaction SINCE 1 day ago
    SELECT apdex(duration, t: 0.5) FROM Transaction WHERE appName IN ({{app}})
    SELECT rate(count(*), 1 minute) AS 'req/min', filter(count(*), WHERE error IS true) AS 'erreurs' FROM Transaction WHERE appName IN ({{app}}) TIMESERIES
    SELECT percentile(duration, 95) FROM Transaction WHERE appName IN ({{app}}) FACET name
    SELECT histogram(duration, 2, 20) FROM Transaction WHERE appName IN ({{app}})

Validate your work

Check that each goal above is reached and that you get the result described in the introduction.

Difficulty level : ●●●○○ (3/5)

My progress

  • ⏱ Estimated time : ≈ 45 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

NRQL: querying all your New Relic data

Mastering NRQL, New Relic's query language: SELECT … FROM structure, filters, aggregation functio...

New Relic dashboards: building, sharing and analysing

Building useful dashboards in New Relic: NRQL widgets, chart choice, template variables, facet li...

Alerts, service levels and incidents in New Relic

Setting up useful alerting in New Relic: policies and NRQL conditions, static and anomaly thresho...

Creating dashboards in Zabbix: dashboards, widgets and pages

Build useful Zabbix dashboards: pages, widgets (Graph, Problems, Top hosts, Honeycomb, Gauge...),...

Using Faro data: queries, dashboards, alerts and GDPR

Query Faro data in Loki (Web Vitals, errors, events), build dashboards and alerts, and comply wit...

Visualizing and automating Zabbix: dashboards, Grafana and API

Build dashboards and maps in Zabbix, use Grafana's Zabbix plugin, and automate configuration with...

Visualizing in Kibana: Lens, dashboards and saved objects

Build visualizations with Lens, assemble interactive dashboards (filters, controls, links), and m...

Grafana cross-dashboard variables: share variables across dashboards

Create your Grafana variables once and reuse them everywhere: global or folder scope, enabling, a...

Datadog dashboards and notebooks: widgets, template variables and best practices

Design useful Datadog dashboards: widget types, template variables, groups, Powerpacks, formulas,...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!