Create Query‑Based SLA Alert Rules in Lescopr

Home Mini Podcast, laptop and monitor working office, vlogging, youtube, office, web design, mug with webflow logo
Learn which KPIs matter for SLA monitoring, how to query them in Lescopr, and turn the results into precise custom alerts for your dev teams.

Introduction

SLA compliance is a cornerstone of modern service contracts, yet many teams rely on static thresholds that generate noise or miss critical violations. In this guide we explore the key performance indicators (KPIs) that matter for SLA monitoring, how to query them in Lescopr, and how to translate query results into custom SLA alert rules that empower development and SRE teams to act on real incidents.


Understanding the Core SLA KPIs

Latency Percentiles

Latency percentiles—especially the 95th and 99th—are the most reliable indicators of user‑perceived performance. Measuring the p99 response time lets you verify whether the service meets the contractual latency bound.

Error Rate

A simple error‑rate metric (e.g., HTTP 5xx / total requests) is essential for availability clauses. Track both global error rate and error rate per endpoint to pinpoint problematic routes.

Availability Uptime

Uptime is often expressed as a percentage over a rolling window (e.g., 99.9% over a month). Use a sliding‑window calculation to smooth out short spikes while still catching prolonged outages.

Throughput

Throughput (requests per second) can affect latency guarantees. High traffic may push latency beyond SLA limits, so correlating throughput with latency is crucial.

Tip: Combine latency percentiles with error‑rate thresholds to avoid alert fatigue when a spike in traffic inflates latency without causing failures.

Building Query‑Based Metrics in Lescopr

Defining a Metric Query

Lescopr’s query engine accepts a SQL‑like syntax that pulls data from traces, logs, and metrics. A typical query for the 99th‑percentile latency looks like:

SELECT percentile(duration_ms, 99) AS p99_latency
FROM traces
WHERE service = 'order‑api'
AND timestamp >= now() - interval '5 minutes'

Adding Filters for Context

Refine the query with filters that match your SLA scope:

  • Region – region = 'eu-west-1'
  • Customer tier – customer_tier = 'premium'
  • Endpoint – endpoint = '/checkout'

Storing the Result as a Metric

Save the query as a custom metric named order_api_p99_latency. Lescopr will evaluate it every minute and store the result for alert evaluation.

Crafting Custom SLA Alert Rules

Setting Thresholds

After creating the metric, define an alert rule that triggers when the metric exceeds the SLA limit for a configurable period:

alert:
  name: "Order API SLA Breach"
  metric: order_api_p99_latency
  condition: "value > 250"
  for: "5m"
  severity: "high"
  • value > 250 – SLA specifies a maximum of 250 ms for the 99th percentile.
  • for: 5m – The condition must hold for five consecutive minutes to avoid transient spikes.

Adding a Composite Rule

Often an SLA clause combines latency and error rate. Lescopr lets you create a composite rule using logical operators:

alert:
  name: "Order API Composite SLA"
  condition: "order_api_p99_latency > 250 && order_api_error_rate > 0.01"
  for: "3m"
  severity: "critical"

Notification Channels

Configure the rule to send alerts to Slack, PagerDuty, or email. Use dynamic payloads to include the metric values that caused the breach, helping engineers triage faster.

Best Practices for Maintaining Alert Hygiene

  • Review thresholds quarterly – Service performance evolves; adjust limits accordingly.
  • Use progressive escalation – Start with a warning level before moving to critical severity.
  • Document the rationale – Store the SLA clause reference alongside each rule for auditability.

Checklist for a Healthy Alert System

  • Verify that each alert references a single KPI.
  • Ensure the evaluation window matches the SLA reporting period.
  • Confirm that notification payloads contain actionable data.
  • Schedule a monthly review of alert fire rates.

Interpreting Alert Data to Drive Improvements

When an alert fires, the associated metric values give immediate insight:

  1. Identify the bottleneck – If latency spikes while error rate stays low, investigate downstream services.
  2. Correlate with deployment – Cross‑reference the alert timestamp with recent releases to spot regressions.
  3. Prioritize remediation – Use the severity level to allocate engineering effort.

By consistently measuring the right KPIs and tying them to precise custom SLA alert rules, teams reduce mean time to acknowledge (MTTA) and mean time to resolve (MTTR), ultimately improving the contractual reliability promised to customers.


Conclusion

Creating query‑based SLA alert rules in Lescopr transforms vague thresholds into data‑driven safeguards. Track latency percentiles, error rates, and availability with tailored queries, then encode those metrics into alert rules that fire only on genuine breaches. This approach cuts noise, accelerates incident response, and aligns monitoring with business‑critical SLAs.

To go further, Lescopr's documentation covers step-by-step setup.