Open source Enterprise Grafana Cloud

JSONata parser

The JSONata parser allows you to transform and manipulate data using JSONata syntax.

Note

In previous versions of the data source, this was referred to as the backend parser. In the current version, backend is a parser category that includes both the JSONata and JQ parsers.

To use JSONata, select Backend → JSONata as the parser type in the query editor.

Supported data formats

The JSONata parser is available for the following data formats:

Data formatParser label
JSONJSONata
GraphQLJSONata
XMLJSONata
HTMLJSONata
CSVBackend
TSVBackend

Note

For CSV and TSV formats, the backend parser provides the same computed columns, filter, and summarize features, but the root selector uses a different syntax since the data is already tabular.

Benefits of using the JSONata parser

Using the JSONata parser enables the following Grafana features:

Root selector

The root selector allows you to manipulate the data received from the server. Use JSONata syntax in the root selector to transform your data before it’s processed further.

You can use JSONata functions directly in the root selector. For example:

  • $.orders — Select the orders array from the response
  • $.orders.price — Extract all price values from the orders array
  • $sum($.orders.price) — Calculate the sum of all prices
  • $avg($.orders.quantity) — Calculate the average quantity

Refer to the JSONata functions documentation for a complete list of available functions.

Computed columns, filter, and summarize

The following features are available in all backend parsers (JSONata and JQ).

Computed columns

Computed columns let you create new fields that calculate values based on existing data. This is similar to the Add field from calculation → Binary Operation transformation but enhanced with a powerful expression language.

For example, price * qty multiplies the values of the price and qty columns to create a new computed field.

Referencing field names

You can reference field names in two ways:

  • Directly: Use the field name as-is, matching is case-insensitive. For example, horsepower matches a field named Horsepower.
  • Brackets: Use square brackets for exact matching or when field names contain special characters. For example, [Cylinders] + [Horsepower].

Available operators

Computed columns support a wide range of operators and functions for creating expressions.

CategoryOperatorsDescription
Arithmetic+, -, *, /, **, %Addition, subtraction, multiplication, division, exponentiation, modulo
Comparison==, !=, >, >=, <, <=Equal, not equal, greater than, greater than or equal, less than, less than or equal
Logical&&, ||, !AND, OR, NOT
String+Concatenation
MembershipINCheck if value is in a list
Regex=~, !~Match, not match
Ternary? :Conditional expression

Supported types

  • Numeric types (integer, float)
  • Boolean types
  • String types
  • Arrays/lists (for use with IN operator)

For more details on expression syntax and advanced usage, refer to the govaluate documentation.

Filter

Filter expressions let you include or exclude rows based on conditions. The expression must evaluate to true or false.

Example filter expressions:

  • price > 500 — Include rows where price exceeds 500
  • name != 'MacBook' && price != null — Exclude MacBook and rows with null prices
  • name IN ('MacBook','MacBook Air') — Include only MacBook or MacBook Air
  • !(name IN ('MacBook','MacBook Air')) — Exclude MacBook and MacBook Air

Summarize

Backend parsers support summarizing fields into aggregated metrics. You can calculate values like count(something), max(some-other-thing), or mean([some other thing]) from your data.

Available aggregation functions

FunctionDescription
sumSum of all values
minMinimum value
maxMaximum value
meanAverage value
countNumber of items
firstFirst value
lastLast value

You can also combine functions in expressions, such as sum(price) / count(id).

Field name syntax

When specifying field names in summarize expressions:

  • Standard format: Replace special characters with - and use lowercase. For example, Something Else! becomes something-else-. Field names are matched case-insensitively in this format.
  • Bracket format: Enclose the original field name in square brackets to preserve exact casing and special characters. For example, min([Something Else!]).

Summarize by (group by)

Use the Summarize By option to group your aggregation by a specific field, similar to SQL’s GROUP BY clause.

Example:

For data containing employee records with department and salary fields:

  • Summarize expression: sum(salary)
  • Summarize by: department
  • Result: Total salary grouped by each department

This produces one row per unique value in the grouping field, with the aggregated result for each group.

Summarize alias

Use the Summarize alias option to specify a custom name for the aggregated result. If not specified, summary is used as the default alias. Custom aliases are useful when merging results from different queries using transformations.