• Get started
  • Documentation

Write JQL queries for SLAs

JQL queries have an order of elements that need to be followed when creating SLAs (service level agreements). There are also functions that are frequently used when creating SLA queries, commonly used operators and certain characters and words that have been reserved in Jira to perform specific functions in the query. Read more about advanced search reference - JQL fields.

Elements in a query

In JQL, a query has four basic elements:

Field

Fields are different types of information in the system. For example, a Jira Service Management field may be priority, issue type, date created and project.

Operator

Operators are the heart of the query. They relate the field to the value. Common operators include equals (=), not equals (!=) and less than (<).

Value

Values are the actual data in the query. For example, paused() and remaining(“2h”).

Functions

Functions are special calculations within Jira to access specific data. For example, issues that have breached SLAs.

You can optionally link a query together using a few select keywords. Keywords are specific words in the language that have special meaning. For example, this may be AND and OR.

A simple query in JQL consists of a field, followed by an operator, followed by one or more values or functions.

For example: project = Test

This query finds all issues in the Test project. It uses the project (field), the equals = (operator), and the Test (value).

Commonly used functions when writing SLA queries

The following are functions that are commonly used when writing JQL queries for an SLA:

breached()

This filters out issues where the last SLA cycle has failed to meet its target goal.

everBreached()

This filters out issues that have failed to meet their target goal.

paused()

This filters issues where the current SLA cycle is paused due to a particular condition. For example, you may pause an issue's SLA clock when the issue's status is set to waiting for customer.

completed()

This filters issues where the SLA cycle is complete, meaning the issue has reached one of their stop events.

running()

This filters issues where the current SLA clock is running, meaning the issue haven't yet reached one of the stop events.

withincalendarhours()

This filters issues whose SLA clock is running or not running according to the SLA calendar, not conditions.

elapsed()

This filters issues where the SLA cycle's clock meets a specified time condition since the ongoing SLA cycle's start event.

remaining()

This filters issues whose SLA cycle's clock meets a specified time condition before the issue will breach an SLA goal.

Commonly used operators

Here are some common character and word operators that you can use in your SLA JQL query:

Characters

=, >, >,=, ~, != < <= !~

Words

not, in, is not, was, not, was not, in, not in, is, was, was in, changed

Reserved characters and words

Here are some reserved characters and words in Jira that need to be used in a specific manner when using them in a query.

Characters

space (" "), +, ., ;, ?, |, *, /, %, ^, $, #, @, [ ], ,

Words

a, and, are, as, at, be, but, by, for, if, in, into, is, it, no, not, of, on, or, s, such, t, that, the, their, then, there, these, they, this, to, was, will, with

When using reserved characters or words in your queries, you need to:

  • surround them with quote marks. You can use either single or double quote marks. For example, ‘Time to first response’.

  • if you are searching a text field and the character is on the list of reserved characters or words, precede them with two backslashes. For example, \\'Time to first response'.

JQL example: find issues breaching your SLA goals

For example, if you wanted to find all the issues in your project that have successfully completed your first-response goals, use the following query:

“Time to first response“ != everBreached ()

JQL example: find issues based on their SLA clock

For example, if you want to find requests that have been waiting for a first response for less than 10 minutes, use the following query:

"Time to first response" < elapsed("10m")

Or, if you want to find issues that will breach their resolution target within the next two hours, use this query:

"Time to resolution" < remaining ("2h")

 

Still need help?

The Atlassian Community is here for you.