0
← Exercises/
Business Analytics•1 of 14
Business AnalyticsAdvanced

Parsing Audit Telemetry with JSONB Operators

Scenario

CloudScale's engineering team emits high-throughput audit telemetry logs into a PostgreSQL table with a `jsonb` payload. Product analytics wants to inspect high-latency executions for a new beta feature flag.

Task
Query the `telemetry_logs` table to extract fields from the `payload` JSONB column. Extract: 1. `log_id` 2. `feature_name`: Extracted as text using `payload->>'feature'` 3. `duration_ms`: Extracted as integer using `(payload->>'duration_ms')::int` 4. `status`: Extracted as text using `payload->>'status'` Filter to only include records where: - `payload->>'feature'` equals `'vector_search_v2'` - `payload->>'status'` equals `'success'` Order results by `duration_ms` descending to see slowest runs first.
Expected Output Format

Extracted telemetry metrics with log_id, feature_name, duration_ms, and status for vector_search_v2 successes.

Input Tables & Sample Data0 tables
Loading database schema...
Need a hint?
query.sql|Local Sandbox
Loading SQL editor...
Click "Run" or press ⌘ + Enter to execute your query

About the “Parsing Audit Telemetry with JSONB Operators” SQL Problem

Business Scenario

CloudScale's engineering team emits high-throughput audit telemetry logs into a PostgreSQL table with a `jsonb` payload. Product analytics wants to inspect high-latency executions for a new beta feature flag.

Expected Output & Criteria

Extracted telemetry metrics with log_id, feature_name, duration_ms, and status for vector_search_v2 successes.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM

This challenge executes directly against the following relational schema in your browser:

CREATE TABLE telemetry_logs (
        log_id INT PRIMARY KEY,
        user_id INT NOT NULL,
        logged_at TIMESTAMP NOT NULL,
        payload JSONB NOT NULL
      );

Target SQL Clauses & Operators

->>WHEREORDER BY

Want more Business Analytics practice?

Explore the full syllabus of 14 exercises, syntax guides, and interview pitfalls.

View Business Analytics Track→