On-demand workshop

From KQL Query to Dashboard and Alert

You write KQL queries in monoscope's Explorer, chart the 5xx rate of one service, save it to a dashboard and attach a monitor that alerts your team.

Before you start

  • A monoscope project that receives HTTP traffic from at least one service. The Node.js workshop sets one up.
  • A notification channel such as email or Slack in Settings → Integrations, so the alert reaches someone

By the end you'll have

  • Wrote filter, free-text and summarize queries in Explorer
  • Charted request failures per service over time without losing the denominator
  • Saved the query and built a dashboard widget from it
  • Created a monitor with alert and warning thresholds on the failure percentage

The query you write to answer “is checkout failing?” during an incident is the same query you want on a dashboard the next morning and in an alert after that. monoscope uses one KQL dialect for Explorer, dashboard widgets, monitors, the CLI and the MCP server, so you write it once. In this workshop you take one question from a first filter to a monitor that pages your team.

1. Set the Scope and Run a Filter

Open Explorer in the sidebar. Use the All services picker and the time range picker at the top right to set the scope. Pick the last hour. Every query, chart and facet on the page uses this scope.

Type a filter in the query bar and press Enter. Replace checkout-api with one of your services:

resource.service.name == "checkout-api" and attributes.http.response.status_code >= 500

Use == for equality, not Lucene’s :. and binds tighter than or, so group with () when you mix them. A quoted string on its own searches the message fields:

"timeout" and resource.service.name == "checkout-api"

Details: Filter operators and free-text search.

2. Discover the Fields You Have

Do not guess field names. The facet panel on the left lists the most common values of useful fields, with a count for each. Select a value to add it to the query. To see which routes and methods a service has, run a summarize:

resource.service.name == "checkout-api"
| summarize events = count() by kind, attributes.http.route, attributes.http.request.method
| sort by events desc
| take 30

Open any event and select Raw data or Attributes to see a field’s exact path and type. If you do not know the field names at all, type what you want in the Ask AI box, for example errors from checkout in the last hour, and monoscope writes the query.

Details: Discover your data.

3. Measure Failures Without Losing the Denominator

A failure rate needs every request in the input. If you filter to 5xx responses before summarize, the percentage is always 100%. Count all inbound server spans, then count the failures among them:

resource.service.name == "checkout-api"
and kind == "server"
and isnotnull(attributes.http.request.method)
| summarize requests = count(), failures = countif(attributes.http.response.status_code >= 500) by bin(timestamp, 5m)
| extend failure_pct = 100.0 * failures / requests

Two traps to know: duration is in nanoseconds, so write duration > 1s, not duration > 1000. And attributes.http.response.status_code is the HTTP status, while status_code is the OpenTelemetry span status.

Details: Measure HTTP failures and units and error fields.

4. Chart It

Select the Bar or Line tab under the query bar to chart the results over time. To draw one series per service, group by the time bin and the service. bin_auto picks the bin width from the time range:

level == "ERROR" | summarize count() by bin_auto(timestamp), resource.service.name

Every column after the time bin in by is a grouping key, so by bin_auto(timestamp), a, b draws one series for each combination of a and b.

When the chart answers your question, click the save button next to the query bar and give the query a name. Saved queries are visible to your team in the Query library under Saved.

Details: Choose a visualization and time functions.

5. Build a Dashboard

  1. Open Dashboards in the sidebar and click New Dashboard.
  2. Select Blank dashboard.
  3. Click Add widget. Paste the query from step 4, select a time series widget, and name it Errors by service.
  4. Add a second widget with a stat of the failure percentage for one service:
resource.service.name == "checkout-api"
and kind == "server"
and isnotnull(attributes.http.request.method)
| summarize 100.0 * countif(attributes.http.response.status_code >= 500) / count()

Custom dashboards are also YAML. Click Edit YAML to see the file, which you can keep in Git or apply with monoscope dashboards apply:

title: Checkout
refresh_interval: 60s
widgets:
  - type: timeseries
    title: Requests by status code
    query: resource.service.name == "checkout" | summarize count(*) by bin_auto(timestamp), attributes.http.response.status_code
    unit: reqs
    layout: { w: 6, h: 4 }

Details: Create a dashboard and dashboards as code.

6. Alert on the Failure Percentage

A monitor compares its aggregate values with the thresholds and alerts on the largest one. So the monitor query must return only the percentage. Otherwise the request count can cross a percentage threshold:

resource.service.name == "checkout-api"
and kind == "server"
and isnotnull(attributes.http.request.method)
| summarize 100.0 * countif(attributes.http.response.status_code >= 500) / count() by bin_auto(timestamp)
  1. Run the query in Explorer and select Create monitor under the query bar.
  2. Under Monitor Schedule, set how often to Execute the query and the time window in Include rows from.
  3. Under Alert when, select A chart threshold is crossed.
  4. Under Thresholds, set the Alert threshold to 5 and the Warning threshold to 2. Set Trigger condition to Above threshold.
  5. Under Notification Settings, select the Teams to notify.
  6. Click Create monitor.

To alert from the dashboard instead, open the widget menu and click Set up a monitor. Select Show threshold lines to draw the thresholds on the chart.

On the free plan, a monitor runs at most once an hour.

Details: Create a monitor and alert from a widget.

7. Tune the Alert

Open Advanced notification settings on the monitor to set the Severity, the Subject and Message of the alert, and Renotify every while it stays over the threshold. Alerts go to the channels of the selected teams, and each alert also opens or updates an issue.

During an incident, Mute the monitor to silence it for a period. Resolve it once the failure rate is back under the threshold.

Details: Notification settings and manage monitors.

What You Built

You have a saved query that measures 5xx failures with the right denominator, a dashboard that charts errors per service, and a monitor that alerts your team when the failure percentage passes 5%. All three use the same KQL, so the query you debug in Explorer is the query that fires the alert.

Next Steps

Know what happened. Prove it.