Reports Yaml Documentation with Examples
Each Report can be defined as code. There are three main sections in each report: the Report properties, Widgets, and optional Filters.
Report Properties
A report starts with the report definition section having the following properties:
title: The report title displayed in the main heading and in the list of reports.
shortDescription: a brief description of the report displayed in the report as a subtitle
longDescription: a Markdown-formatted string that fits a long document displayed in the Tips for using this report popup.
logo: specify one of the built-in images to be used on the report cards in various places of the CloudQuery Platform.
tags: an array of labels that make it easier to find or filter reports in the main Reports view.
widgets: an array of visualizations displayed in the report. See below for details.
Widgets
A widget has the following properties:
title: The title of the widget
display: The display options based on the type of the widget. See Widget Display Types below.
query: SQL query that will be executed to populate the widget.
Label
Label is the simplest visualization to show a text or a single number.
Table
Table widget visualizes the query result as is.
Pie chart
Pie chart visualizes the first two columns of the query result table.
The first column must be a string (text), the second column must be a number.
Optionally, you can display a "total" representing the sum of all values in the center of the pie chart and set a label for it.
Bar chart
Bar chart visualizes the first two columns of the query result table.
The first column must be a string (text), the second column must be a number.
Use the entryLabel property to customize the tooltip over the bar.
Bar chart with multiple series
Use the map column type to show a bar chart with multiple series.
X-Y Chart
X-Y chart is a line chart designed to display multiple data series over the same X axis. It can combine multiple queries into a single visualization. Unlike the other widgets, this widget accepts an array of queries instead of just a single query.
Each query is specified with its title (series name) and the actual SQL query.
Filters
You can add top level filters to each report and decide what widgets will be affected by the filters.
A filter is defined by its type, label, expression, and optionally the definition of the available values.
The type defines the value type of the filter and how it is used. The available types are:
generic: a filter with a pre-defined set of options. The options are defined either statically in the code, or loaded via a SQL query
date: a filter with a date selector
search: a free-form user input with an optional default value
The label defines the label displayed to the user.
The filter expression (named filterExpression
in the report code) is the placeholder expression used in the SQL queries of widgets. CloudQuery will automatically replace the expression when the filter is used by the user. By using the filterExpression
in the SQL query of a widget, you tell CloudQuery to apply the filter to the specific widget.
Each filter expression needs to be unique within the report. There cannot be two filters with the same filter expression, such as account_id = '?'
. If you need to have two filters filtering on the same column name, consider using the as
keyword in the SQL queries to rename the columns to match the specific filter expression.
For example, you can define the filter expression as account = '?'
. Then in the SQL query, define the where clause using this exact expression:
Following are examples of the different filter types with widgets using them.
Generic filter with statically defined options
This filter is a dropdown with a static list of options defined in the code. Each option has a label displayed to the user and value used in the SQL query.
An example of a table widget using this filter:
Generic filter with options from a SQL query
This filter will look the same as the one above, but the options will be dynamic based on the SQL query definition. You can use any table in CloudQuery to get the values from.
Date selector
The default date selector provides a calendar day dropdown with buttons pointing to intervals in the past (7 days ago, 14 days ago, ...)
An example widget using the filter above:
Date selector with a date in the future
Add mode:future
to the date filter to change the buttons to point to a future date:
Free-form search filter
This free-form search input lets users type in any value.
An example widget using this filter:
Free-form search filter with a default value
Add a defaultValue
property to the above to always load a fresh report with this filter set automatically.
An example widget using this filter:
Advanced Options
Setting widget width
You can use the width
property on the display properties to set the desired widget width in the percentage of the view port. This property is available on all widgets.
Adding search to a table widget
To add a search box in a table widget, add a search_string
column in the SQL query. The column will not be visualized. Instead, a search box will be displayed in the table header and you'll be able to use it to find a value from the search_string column. You can use concat()
function, for example, to make more columns searchable or to include columns in the search even if they are not visualized.
Groups
You can wrap widgets in collapsible groups to make the reports more concise. A group has the following properties:
title: The title of the group
description: The subtitle displayed below the title.
widgets: An array of widgets.
Last updated
Was this helpful?