import { SyntheticEvent, useState } from 'react'; import { DataSourcePluginOptionsEditorProps, onUpdateDatasourceJsonDataOption, onUpdateDatasourceSecureJsonDataOption, updateDatasourcePluginJsonDataOption, updateDatasourcePluginResetOption, } from '@grafana/data'; import { ConfigSection, ConfigSubSection, DataSourceDescription, EditorStack } from '@grafana/plugin-ui'; import { config } from '@grafana/runtime'; import { ConnectionLimits, Divider, TLSSecretsConfig, useMigrateDatabaseFields } from '@grafana/sql'; import { Collapse, Field, Icon, Input, Label, SecretInput, SecureSocksProxySettings, Switch, Tooltip, } from '@grafana/ui'; import { MySQLOptions } from '../types'; export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps) => { const [isOpen, setIsOpen] = useState(true); const { options, onOptionsChange } = props; const jsonData = options.jsonData; useMigrateDatabaseFields(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_LONG = 40; return ( <> setIsOpen((x) => !x)}> 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 docs for more information.
{jsonData.tlsAuth || jsonData.tlsAuthWithCACert ? ( <> {jsonData.tlsAuth || jsonData.tlsAuthWithCACert ? ( ) : null} ) : null} Session timezone Specify the timezone used in the database session, such as Europe/Berlin or +02:00. Required if the timezone of the database (or the host of the database) is set to something other than UTC. Set this to +00:00 so Grafana can handle times properly. Set the value used in the session with SET time_zone='...'. If you leave this field empty, the timezone will not be updated. You can find more information in the MySQL documentation. } > } > Min time interval 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. } > } description="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." > {config.secureSocksDSProxyEnabled && ( )} ); };