import React, { SyntheticEvent } from 'react'; import { DataSourcePluginOptionsEditorProps, onUpdateDatasourceJsonDataOption, onUpdateDatasourceSecureJsonDataOption, updateDatasourcePluginJsonDataOption, updateDatasourcePluginResetOption, } from '@grafana/data'; import { Alert, FieldSet, InlineField, InlineFieldRow, InlineSwitch, Input, Link, SecretInput, SecureSocksProxySettings, } from '@grafana/ui'; import { config } from 'app/core/config'; import { ConnectionLimits } from 'app/features/plugins/sql/components/configuration/ConnectionLimits'; import { TLSSecretsConfig } from 'app/features/plugins/sql/components/configuration/TLSSecretsConfig'; import { useMigrateDatabaseField } from 'app/features/plugins/sql/components/configuration/useMigrateDatabaseField'; import { MySQLOptions } from '../types'; export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps) => { const { options, onOptionsChange } = props; const jsonData = options.jsonData; useMigrateDatabaseField(props); const onResetPassword = () => { updateDatasourcePluginResetOption(props, 'password'); }; const onDSOptionChanged = (property: keyof MySQLOptions) => { return (event: SyntheticEvent) => { onOptionsChange({ ...options, ...{ [property]: event.currentTarget.value } }); }; }; const onSwitchChanged = (property: keyof MySQLOptions) => { return (event: SyntheticEvent) => { updateDatasourcePluginJsonDataOption(props, property, event.currentTarget.checked); }; }; const WIDTH_SHORT = 15; const WIDTH_MEDIUM = 22; const WIDTH_LONG = 40; return ( <>
Specify the time zone used in the database session, e.g. Europe/Berlin or +02:00. This is necessary, if the timezone of the database (or the host of the database) is set to something other than UTC. The value is set in the session with SET time_zone='...'. If you leave this field empty, the timezone is not updated. You can find more information in the MySQL documentation. } label="Session timezone" labelWidth={WIDTH_MEDIUM} >
{config.featureToggles.secureSocksDatasourceProxy && ( )} {jsonData.tlsAuth || jsonData.tlsAuthWithCACert ? (
) : null} { updateDatasourcePluginJsonDataOption(props, property, value); }} >
A lower limit for the auto group by time interval. Recommended to be set to write frequency, for example 1m if your data is written every minute. } labelWidth={WIDTH_MEDIUM} label="Min time interval" >
The database user should only be granted SELECT permissions on the specified database & tables you want to query. Grafana does not validate that queries are safe so queries can contain any SQL statement. For example, statements like USE otherdb; and DROP TABLE user; would be executed. To protect against this we Highly recommend you create a specific MySQL user with restricted permissions. Check out the{' '} MySQL Data Source Docs {' '} for more information. ); };