mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
MySql Datasource: Improve Tooltips and Documentation (#64122)
* Add tooltips to Skip TLS and TLS Auth * Update docs with provisioning examples
This commit is contained in:
@@ -82,7 +82,9 @@ 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
|
```yaml
|
||||||
apiVersion: 1
|
apiVersion: 1
|
||||||
@@ -101,6 +103,51 @@ datasources:
|
|||||||
password: ${GRAFANA_MYSQL_PASSWORD}
|
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
|
||||||
|
apiVersion: 1
|
||||||
|
|
||||||
|
datasources:
|
||||||
|
- name: MySQL
|
||||||
|
type: mysql
|
||||||
|
url: localhost:3306
|
||||||
|
user: grafana
|
||||||
|
jsonData:
|
||||||
|
tlsAuth: true
|
||||||
|
skipTLSVerify: 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}
|
||||||
|
```
|
||||||
|
|
||||||
## Query builder
|
## Query builder
|
||||||
|
|
||||||
{{< figure src="/static/img/docs/v92/mysql_query_builder.png" class="docs-image--no-shadow" >}}
|
{{< figure src="/static/img/docs/v92/mysql_query_builder.png" class="docs-image--no-shadow" >}}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user