mirror of
https://github.com/grafana/grafana.git
synced 2026-08-26 05:17:26 -05:00
InfluxDB: Add configuration option for enabling insecure gRPC connections (#83834)
* InfluxDB: add configuration option for enabling insecure gRPC connections * fix: add insecureGrpc to InfluxOptions * rename options label 'gRPC' -> 'Connection' Co-authored-by: ismail simsek <ismailsimsek09@gmail.com> * update docs: rename options label 'gRPC' -> 'Connection' Co-authored-by: ismail simsek <ismailsimsek09@gmail.com> * default insecure connection boolean to false in frontend Co-authored-by: ismail simsek <ismailsimsek09@gmail.com> * run prettier:write --------- Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
This commit is contained in:
co-authored by
ismail simsek
parent
388e0c27f2
commit
297d73a7df
@@ -126,10 +126,11 @@ Configure these options if you select the InfluxQL (classic InfluxDB) query lang
|
||||
|
||||
Configure these options if you select the SQL query language:
|
||||
|
||||
| Name | Description |
|
||||
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **Database** | Sets the ID of the bucket to query. Copy this from the Buckets page of the InfluxDB UI. |
|
||||
| **Token** | API token used for SQL queries. It can be generated on InfluxDB Cloud dashboard under [Load Data > API Tokens](https://docs.influxdata.com/influxdb/cloud-serverless/get-started/setup/#create-an-all-access-api-token) menu. |
|
||||
| Name | Description |
|
||||
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **Database** | Sets the ID of the bucket to query. Copy this from the Buckets page of the InfluxDB UI. |
|
||||
| **Token** | API token used for SQL queries. It can be generated on InfluxDB Cloud dashboard under [Load Data > API Tokens](https://docs.influxdata.com/influxdb/cloud-serverless/get-started/setup/#create-an-all-access-api-token) menu. |
|
||||
| **Insecure Connection** | Disable gRPC TLS security. |
|
||||
|
||||
### Configure Flux
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ func runnerFromDataSource(dsInfo *models.DatasourceInfo) (*runner, error) {
|
||||
md.Set("Authorization", fmt.Sprintf("Bearer %s", dsInfo.Token))
|
||||
}
|
||||
|
||||
fsqlClient, err := newFlightSQLClient(addr, md, dsInfo.SecureGrpc)
|
||||
fsqlClient, err := newFlightSQLClient(addr, md, !dsInfo.InsecureGrpc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -57,13 +57,13 @@ func (suite *FSQLTestSuite) TestIntegration_QueryData() {
|
||||
resp, err := Query(
|
||||
context.Background(),
|
||||
&models.DatasourceInfo{
|
||||
HTTPClient: nil,
|
||||
Token: "secret",
|
||||
URL: "http://localhost:12345",
|
||||
DbName: "influxdb",
|
||||
Version: "test",
|
||||
HTTPMode: "proxy",
|
||||
SecureGrpc: false,
|
||||
HTTPClient: nil,
|
||||
Token: "secret",
|
||||
URL: "http://localhost:12345",
|
||||
DbName: "influxdb",
|
||||
Version: "test",
|
||||
HTTPMode: "proxy",
|
||||
InsecureGrpc: true,
|
||||
},
|
||||
backend.QueryDataRequest{
|
||||
Queries: []backend.DataQuery{
|
||||
|
||||
@@ -82,7 +82,7 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
|
||||
DefaultBucket: jsonData.DefaultBucket,
|
||||
Organization: jsonData.Organization,
|
||||
MaxSeries: maxSeries,
|
||||
SecureGrpc: true,
|
||||
InsecureGrpc: jsonData.InsecureGrpc,
|
||||
Token: settings.DecryptedSecureJSONData["token"],
|
||||
Timeout: opts.Timeouts.Timeout,
|
||||
}
|
||||
|
||||
@@ -21,5 +21,5 @@ type DatasourceInfo struct {
|
||||
Timeout time.Duration
|
||||
|
||||
// FlightSQL grpc connection
|
||||
SecureGrpc bool `json:"secureGrpc"`
|
||||
InsecureGrpc bool `json:"insecureGrpc"`
|
||||
}
|
||||
|
||||
+20
-1
@@ -8,7 +8,7 @@ import {
|
||||
onUpdateDatasourceSecureJsonDataOption,
|
||||
updateDatasourcePluginResetOption,
|
||||
} from '@grafana/data';
|
||||
import { Field, InlineLabel, Input, SecretInput, useStyles2 } from '@grafana/ui';
|
||||
import { Field, InlineLabel, InlineSwitch, Input, SecretInput, useStyles2 } from '@grafana/ui';
|
||||
|
||||
import { InfluxOptions, InfluxSecureJsonData } from '../../../types';
|
||||
|
||||
@@ -57,6 +57,25 @@ export const InfluxSqlConfig = (props: Props) => {
|
||||
isConfigured={Boolean(secureJsonFields && secureJsonFields.token)}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
horizontal
|
||||
label={<InlineLabel width={WIDTH_SHORT}>Insecure Connection</InlineLabel>}
|
||||
className={styles.horizontalField}
|
||||
>
|
||||
<InlineSwitch
|
||||
id={`${htmlPrefix}-insecure-grpc`}
|
||||
value={jsonData.insecureGrpc ?? false}
|
||||
onChange={(event) => {
|
||||
onOptionsChange({
|
||||
...options,
|
||||
jsonData: {
|
||||
...jsonData,
|
||||
insecureGrpc: event.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ export interface InfluxOptions extends DataSourceJsonData {
|
||||
|
||||
// With SQL
|
||||
metadata?: Array<Record<string, string>>;
|
||||
insecureGrpc?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user