MySql Datasource: Improve Tooltips and Documentation (#64122)

* Add tooltips to Skip TLS and TLS Auth

* Update docs with provisioning examples
pull/64514/head
Kyle Cunningham 2 years ago committed by GitHub
parent 9f551400c3
commit 09f71a6901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      docs/sources/datasources/mysql/_index.md
  2. 48
      public/app/plugins/datasource/mysql/configuration/ConfigurationEditor.tsx

@ -82,7 +82,50 @@ You can use wildcards (`*`) in place of database or table if you want to grant a
You can define and configure the data source in YAML files as part of Grafana's provisioning system. You can define and configure the data source in YAML files as part of Grafana's provisioning system.
For more information about provisioning, and for available configuration options, refer to [Provisioning Grafana]({{< relref "../../administration/provisioning/#data-sources" >}}). For more information about provisioning, and for available configuration options, refer to [Provisioning Grafana]({{< relref "../../administration/provisioning/#data-sources" >}}).
#### Provisioning example #### Provisioning examples
##### Basic Provisioning
```yaml
apiVersion: 1
datasources:
- name: MySQL
type: mysql
url: localhost:3306
user: grafana
jsonData:
database: grafana
maxOpenConns: 0 # Grafana v5.4+
maxIdleConns: 2 # Grafana v5.4+
connMaxLifetime: 14400 # Grafana v5.4+
secureJsonData:
password: ${GRAFANA_MYSQL_PASSWORD}
```
##### Using TLS Verificaiton
```yaml
apiVersion: 1
datasources:
- name: MySQL
type: mysql
url: localhost:3306
user: grafana
jsonData:
tlsAuth: true
database: grafana
maxOpenConns: 0 # Grafana v5.4+
maxIdleConns: 2 # Grafana v5.4+
connMaxLifetime: 14400 # Grafana v5.4+
secureJsonData:
password: ${GRAFANA_MYSQL_PASSWORD}
tlsClientCert: ${GRAFANA_TLS_CLIENT_CERT}
tlsCACert: ${GRAFANA_TLS_CA_CERT}
```
##### Use TLS and Skip Certificate Verification
```yaml ```yaml
apiVersion: 1 apiVersion: 1
@ -93,12 +136,16 @@ datasources:
url: localhost:3306 url: localhost:3306
user: grafana user: grafana
jsonData: jsonData:
tlsAuth: true
skipTLSVerify: true
database: grafana database: grafana
maxOpenConns: 0 # Grafana v5.4+ maxOpenConns: 0 # Grafana v5.4+
maxIdleConns: 2 # Grafana v5.4+ maxIdleConns: 2 # Grafana v5.4+
connMaxLifetime: 14400 # Grafana v5.4+ connMaxLifetime: 14400 # Grafana v5.4+
secureJsonData: secureJsonData:
password: ${GRAFANA_MYSQL_PASSWORD} password: ${GRAFANA_MYSQL_PASSWORD}
tlsClientCert: ${GRAFANA_TLS_CLIENT_CERT}
tlsCACert: ${GRAFANA_TLS_CA_CERT}
``` ```
## Query builder ## Query builder

@ -36,16 +36,16 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
}; };
}; };
const mediumWidth = 20; const WIDTH_SHORT = 15;
const shortWidth = 15; const WIDTH_MEDIUM = 22;
const longWidth = 40; const WIDTH_LONG = 40;
return ( return (
<> <>
<FieldSet label="MySQL Connection" width={400}> <FieldSet label="MySQL Connection" width={400}>
<InlineField labelWidth={shortWidth} label="Host"> <InlineField labelWidth={WIDTH_SHORT} label="Host">
<Input <Input
width={longWidth} width={WIDTH_LONG}
name="host" name="host"
type="text" type="text"
value={options.url || ''} value={options.url || ''}
@ -53,9 +53,9 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
onChange={onDSOptionChanged('url')} onChange={onDSOptionChanged('url')}
></Input> ></Input>
</InlineField> </InlineField>
<InlineField labelWidth={shortWidth} label="Database"> <InlineField labelWidth={WIDTH_SHORT} label="Database">
<Input <Input
width={longWidth} width={WIDTH_LONG}
name="database" name="database"
value={jsonData.database || ''} value={jsonData.database || ''}
placeholder="database name" placeholder="database name"
@ -63,17 +63,17 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
></Input> ></Input>
</InlineField> </InlineField>
<InlineFieldRow> <InlineFieldRow>
<InlineField labelWidth={shortWidth} label="User"> <InlineField labelWidth={WIDTH_SHORT} label="User">
<Input <Input
width={shortWidth} width={WIDTH_SHORT}
value={options.user || ''} value={options.user || ''}
placeholder="user" placeholder="user"
onChange={onDSOptionChanged('user')} onChange={onDSOptionChanged('user')}
></Input> ></Input>
</InlineField> </InlineField>
<InlineField labelWidth={shortWidth - 5} label="Password"> <InlineField labelWidth={WIDTH_SHORT - 5} label="Password">
<SecretInput <SecretInput
width={shortWidth} width={WIDTH_SHORT}
placeholder="Password" placeholder="Password"
isConfigured={options.secureJsonFields && options.secureJsonFields.password} isConfigured={options.secureJsonFields && options.secureJsonFields.password}
onReset={onResetPassword} onReset={onResetPassword}
@ -92,17 +92,22 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
</span> </span>
} }
label="Session timezone" label="Session timezone"
labelWidth={mediumWidth} labelWidth={WIDTH_MEDIUM}
> >
<Input <Input
width={longWidth - 5} width={WIDTH_LONG - 5}
value={jsonData.timezone || ''} value={jsonData.timezone || ''}
onChange={onUpdateDatasourceJsonDataOption(props, 'timezone')} onChange={onUpdateDatasourceJsonDataOption(props, 'timezone')}
placeholder="(default)" placeholder="(default)"
></Input> ></Input>
</InlineField> </InlineField>
<InlineFieldRow> <InlineFieldRow>
<InlineField labelWidth={mediumWidth} htmlFor="tlsAuth" label="TLS Client Auth"> <InlineField
labelWidth={WIDTH_MEDIUM}
tooltip="Enables TLS authentication using client cert configured in secure json data."
htmlFor="tlsAuth"
label="Use TLS Client Auth"
>
<InlineSwitch <InlineSwitch
id="tlsAuth" id="tlsAuth"
onChange={onSwitchChanged('tlsAuth')} onChange={onSwitchChanged('tlsAuth')}
@ -110,8 +115,8 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
></InlineSwitch> ></InlineSwitch>
</InlineField> </InlineField>
<InlineField <InlineField
labelWidth={mediumWidth} labelWidth={WIDTH_MEDIUM}
tooltip="Needed for verifing self-signed TLS Certs" tooltip="Needed for verifing self-signed TLS Certs."
htmlFor="tlsCaCert" htmlFor="tlsCaCert"
label="With CA Cert" label="With CA Cert"
> >
@ -122,7 +127,12 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
></InlineSwitch> ></InlineSwitch>
</InlineField> </InlineField>
</InlineFieldRow> </InlineFieldRow>
<InlineField labelWidth={mediumWidth} htmlFor="skipTLSVerify" label="Skip TLS Verify"> <InlineField
labelWidth={WIDTH_MEDIUM}
tooltip="When enabled, skips verification of the MySql server's TLS certificate chain and host name."
htmlFor="skipTLSVerify"
label="Skip TLS Verification"
>
<InlineSwitch <InlineSwitch
id="skipTLSVerify" id="skipTLSVerify"
onChange={onSwitchChanged('tlsSkipVerify')} onChange={onSwitchChanged('tlsSkipVerify')}
@ -143,7 +153,7 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
) : null} ) : null}
<ConnectionLimits <ConnectionLimits
labelWidth={shortWidth} labelWidth={WIDTH_SHORT}
jsonData={jsonData} jsonData={jsonData}
onPropertyChanged={(property, value) => { onPropertyChanged={(property, value) => {
updateDatasourcePluginJsonDataOption(props, property, value); updateDatasourcePluginJsonDataOption(props, property, value);
@ -158,7 +168,7 @@ export const ConfigurationEditor = (props: DataSourcePluginOptionsEditorProps<My
<code>1m</code> if your data is written every minute. <code>1m</code> if your data is written every minute.
</span> </span>
} }
labelWidth={mediumWidth} labelWidth={WIDTH_MEDIUM}
label="Min time interval" label="Min time interval"
> >
<Input <Input

Loading…
Cancel
Save