Plugin requires v9.2
and higher of Grafana.
The YDB data source plugin allows you to query and visualize YDB data from within Grafana.
For detailed instructions on how to install the plugin on Grafana Cloud or locally, please checkout the Plugin installation docs.
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.
The plugin supports GRPCS
and GRPC
transport protocols. Please note that you need to provide TLS/SSL certificate when using grpcs
.
Once the plugin is installed on your Grafana instance, follow these instructions to add a new YDB data source, and enter configuration options.
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;
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 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.
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`
Table visualizations will always be available for any valid YDB query.
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.
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`)
Macro | Description | Output example |
---|---|---|
$__timeFilter(columnName) | Replaced by a conditional that filters the data (using the provided column) based on the time range of the panel in microseconds | foo >= CAST(1636717526371000 AS TIMESTAMP) AND foo <= CAST(1668253526371000 AS TIMESTAMP)' ) |
$__fromTimestamp | Replaced by the starting time of the range of the panel casted to Timestamp | CAST(1636717526371000 AS TIMESTAMP) |
$__toTimestamp | Replaced by the ending time of the range of the panel casted to Timestamp | CAST(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 |
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.
- Add Annotations.
- Configure and use Templates and variables.
- Add Transformations.
- Set up alerting; refer to Alerts overview.