Plugins 〉YDB


Developer
YDB Platform

Resources

Sign up to receive occasional product news and updates:



Data Source
community

YDB

  • Overview
  • Installation
  • Change log
  • Related content

License Release Downloads

Telegram WebSite PRs Welcome

YDB data source for Grafana

Version compatibility

Plugin requires v9.2 and higher of Grafana.

The YDB data source plugin allows you to query and visualize YDB data from within Grafana.

Installation

For detailed instructions on how to install the plugin on Grafana Cloud or locally, please checkout the Plugin installation docs.

Configuration

YDB user for the data source

Set up an YDB user account with readonly permission (more about permissions) and access to databases and tables you want to query. Please note that Grafana does not validate that queries are safe. Queries can contain any SQL statement including modification instructions.

Data transfer protocol support

The plugin supports GRPCS and GRPC transport protocols. Please note that you need to provide TLS/SSL certificate when using grpcs.

Manual configuration

Once the plugin is installed on your Grafana instance, follow these instructions to add a new YDB data source, and enter configuration options.

With a configuration file

It is possible to configure data sources using configuration files with Grafana’s provisioning system. To read about how it works, including all the settings that you can set for this data source, refer to Provisioning Grafana data sources.

Plugin supports different authentication types authentication types.

Here is an example for this data source using user/password:

apiVersion: 1
datasources:
  - name: YDB
    type: ydbtech-ydb-datasource
    jsonData:
      authKind: "UserPassword",
      endpoint: 'grpcs://endpoint',
      dbLocation: 'location',
      user: 'username',
    secureJsonData:
      password: 'userpassword',
      certificate: 'certificate',

Here are fields that are supported in connection configuration:

    jsonData:
      authKind: "Anonymous" | "ServiceAccountKey" | "AccessToken" | "UserPassword" | "MetaData";
      endpoint: string;
      dbLocation: string;
      user?: string;
    secureJsonData:
      serviceAccAuthAccessKey?: string;
      accessToken?: string;
      password?: string;
      certificate?: string;

Building queries

YQL dialect is used to query YDB. Queries can contain macros which simplify syntax and allow for dynamic parts. The query editor allows you to get data in different representation: time series, table or logs.

Time series

Time series visualization options are selectable after adding to your query one field with Date, Datetime or Timestamp type and at least one field with number type. You can select time series visualizations using the visualization options. Grafana interprets timestamp rows without explicit time zone as UTC. Any other column is treated as a value column.

Multi-line time series

To create multi-line time series, the query must return at least 3 fields in the following order:

  • field 1: time field
  • field 2: value to group by
  • field 3+: the metric values

For example:

SELECT `timestamp`, `requestTime`, AVG(`responseStatus`) AS `avgRespStatus`
FROM `/database/endpoint/my-logs`
GROUP BY `requestTime`, `timestamp`
ORDER BY `timestamp`

Tables

Table visualizations will always be available for any valid YDB query.

Visualizing logs with the Logs Panel

To use the Logs panel your query must return a time and string values. You can select logs visualizations using the visualization options.

By default only the first text field will be represented as log line, but this can be customized using query builder.

Macros

To simplify syntax and to allow for dynamic parts, like date range filters, the query can contain macros.

Here is an example of a query with a macro that will use Grafana's time filter:

SELECT `timeCol`
FROM `/database/endpoint/my-logs`
WHERE $__timeFilter(`timeCol`)
MacroDescriptionOutput example
$__timeFilter(columnName)Replaced by a conditional that filters the data (using the provided column) based on the time range of the panel in microsecondsfoo >= CAST(1636717526371000 AS TIMESTAMP) AND foo <= CAST(1668253526371000 AS TIMESTAMP)' )
$__fromTimestampReplaced by the starting time of the range of the panel casted to TimestampCAST(1636717526371000 AS TIMESTAMP)
$__toTimestampReplaced by the ending time of the range of the panel casted to TimestampCAST(1636717526371000 AS TIMESTAMP)
$__varFallback(condition, $templateVar)Replaced by the first parameter when the template variable in the second parameter is not provided.condition or templateVarValue

Templates and variables

To add a new YDB query variable, refer to Add a query variable. After creating a variable, you can use it in your YDB queries by using Variable syntax. For more information about variables, refer to Templates and variables.

Learn more

Installing YDB on Grafana Cloud:

For more information, visit the docs on plugin installation.

Changelog

0.4.3

  • Default auth type should be identical for frontend and backend
  • Bug with filters when variable is multi-value

0.4.2

  • Update github.com/grafana/grafana-plugin-sdk-go

0.4.1

  • Support number limit to achieve backwards compatibility

0.4.0

  • Add ORDER BY to Query Builder
  • Different Improvements and bug fixes
  • Minimum required Grafana version increased to v9.2