mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 17:22:18 +08:00
Azure Monitor: Support request timeout configuration (#105487)
Support request timeout configuration
This commit is contained in:
@ -66,6 +66,10 @@ export interface AzureMonitorQuery extends common.DataQuery {
|
||||
* Subscriptions to be queried via Azure Resource Graph.
|
||||
*/
|
||||
subscriptions?: Array<string>;
|
||||
/**
|
||||
* Used to configure the HTTP request timeout
|
||||
*/
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export const defaultAzureMonitorQuery: Partial<AzureMonitorQuery> = {
|
||||
|
@ -52,13 +52,15 @@ type AzureMonitorQuery struct {
|
||||
Region *string `json:"region,omitempty"`
|
||||
// Custom namespace used in template variable queries
|
||||
CustomNamespace *string `json:"customNamespace,omitempty"`
|
||||
// Used only for exemplar queries from Prometheus
|
||||
Query *string `json:"query,omitempty"`
|
||||
// For mixed data sources the selected datasource is on the query level.
|
||||
// For non mixed scenarios this is undefined.
|
||||
// TODO find a better way to do this ^ that's friendly to schema
|
||||
// TODO this shouldn't be unknown but DataSourceRef | null
|
||||
Datasource any `json:"datasource,omitempty"`
|
||||
// Used only for exemplar queries from Prometheus
|
||||
Query *string `json:"query,omitempty"`
|
||||
// Used to configure the HTTP request timeout
|
||||
Timeout *float64 `json:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
// NewAzureMonitorQuery creates a new AzureMonitorQuery object.
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { PureComponent } from 'react';
|
||||
import { ChangeEvent, PureComponent } from 'react';
|
||||
|
||||
import { DataSourcePluginOptionsEditorProps, SelectableValue, updateDatasourcePluginOption } from '@grafana/data';
|
||||
import { t } from '@grafana/i18n/internal';
|
||||
import { ConfigSection, DataSourceDescription } from '@grafana/plugin-ui';
|
||||
import { getBackendSrv, getTemplateSrv, isFetchError, TemplateSrv, config } from '@grafana/runtime';
|
||||
import { Alert, Divider, SecureSocksProxySettings } from '@grafana/ui';
|
||||
import { Alert, Divider, Field, Input, SecureSocksProxySettings } from '@grafana/ui';
|
||||
|
||||
import ResponseParser from '../../azure_monitor/response_parser';
|
||||
import {
|
||||
@ -100,6 +100,23 @@ export class ConfigEditor extends PureComponent<Props, State> {
|
||||
const { options, onOptionsChange } = this.props;
|
||||
const { error } = this.state;
|
||||
|
||||
const onTimeoutChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.currentTarget.value?.trim() === '') {
|
||||
this.updateOptions((options) => ({
|
||||
...options,
|
||||
jsonData: { ...options.jsonData, timeout: undefined },
|
||||
}));
|
||||
} else {
|
||||
const newVal = Number(e.currentTarget.value);
|
||||
if (!Number.isNaN(newVal)) {
|
||||
this.updateOptions((options) => ({
|
||||
...options,
|
||||
jsonData: { ...options.jsonData, timeout: newVal },
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DataSourceDescription
|
||||
@ -115,22 +132,38 @@ export class ConfigEditor extends PureComponent<Props, State> {
|
||||
{error.details && <details style={{ whiteSpace: 'pre-wrap' }}>{error.details}</details>}
|
||||
</Alert>
|
||||
)}
|
||||
{config.secureSocksDSProxyEnabled && (
|
||||
<>
|
||||
<Divider />
|
||||
<ConfigSection
|
||||
title={t('components.config-editor.title-additional-settings', 'Additional settings')}
|
||||
<>
|
||||
<Divider />
|
||||
<ConfigSection
|
||||
title={t('components.config-editor.title-additional-settings', 'Additional settings')}
|
||||
description={t(
|
||||
'components.config-editor.description-additional-settings',
|
||||
'Additional settings are optional settings that can be configured for more control over your data source. This includes Secure Socks Proxy.'
|
||||
)}
|
||||
isCollapsible={true}
|
||||
isInitiallyOpen={options.jsonData.enableSecureSocksProxy !== undefined}
|
||||
>
|
||||
<Field
|
||||
label={t('components.config-editor.title-request-timeout', 'Request Timeout')}
|
||||
description={t(
|
||||
'components.config-editor.description-additional-settings',
|
||||
'Additional settings are optional settings that can be configured for more control over your data source. This includes Secure Socks Proxy.'
|
||||
'components.config-editor.description-request-timeout',
|
||||
'Set the request timeout in seconds. Default is 30 seconds.'
|
||||
)}
|
||||
isCollapsible={true}
|
||||
isInitiallyOpen={options.jsonData.enableSecureSocksProxy !== undefined}
|
||||
>
|
||||
<Input
|
||||
value={options.jsonData.timeout}
|
||||
type="number"
|
||||
className="width-15"
|
||||
// eslint-disable-next-line @grafana/no-untranslated-strings
|
||||
placeholder="30"
|
||||
onChange={onTimeoutChange}
|
||||
/>
|
||||
</Field>
|
||||
{config.secureSocksDSProxyEnabled && (
|
||||
<SecureSocksProxySettings options={options} onOptionsChange={onOptionsChange} />
|
||||
</ConfigSection>
|
||||
</>
|
||||
)}
|
||||
)}
|
||||
</ConfigSection>
|
||||
</>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -59,6 +59,9 @@ composableKinds: DataQuery: {
|
||||
|
||||
// Used only for exemplar queries from Prometheus
|
||||
query?: string
|
||||
|
||||
// Used to configure the HTTP request timeout
|
||||
timeout?: number
|
||||
} @cuetsy(kind="interface") @grafana(TSVeneer="type")
|
||||
|
||||
// Defines the supported queryTypes. GrafanaTemplateVariableFn is deprecated
|
||||
|
@ -64,6 +64,10 @@ export interface AzureMonitorQuery extends common.DataQuery {
|
||||
* Subscriptions to be queried via Azure Resource Graph.
|
||||
*/
|
||||
subscriptions?: Array<string>;
|
||||
/**
|
||||
* Used to configure the HTTP request timeout
|
||||
*/
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export const defaultAzureMonitorQuery: Partial<AzureMonitorQuery> = {
|
||||
|
@ -72,7 +72,9 @@
|
||||
},
|
||||
"config-editor": {
|
||||
"description-additional-settings": "Additional settings are optional settings that can be configured for more control over your data source. This includes Secure Socks Proxy.",
|
||||
"title-additional-settings": "Additional settings"
|
||||
"title-additional-settings": "Additional settings",
|
||||
"title-request-timeout": "Request timeout",
|
||||
"description-request-timeout": "Set the request timeout in seconds. Default is 30 seconds."
|
||||
},
|
||||
"current-user-fallback-credentials": {
|
||||
"alert-fallback-credentials-disabled": "Fallback credentials have been disabled. As user-based authentication only inherently supports requests with a user in scope, features such as alerting, recorded queries, or reporting will not function as expected. Please review the <2>documentation</2> for more details.",
|
||||
|
@ -41,6 +41,7 @@ export interface AzureMonitorDataSourceJsonData extends AzureDataSourceJsonData
|
||||
appInsightsAppId?: string;
|
||||
|
||||
enableSecureSocksProxy?: boolean;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export interface AzureMonitorDataSourceSecureJsonData extends AzureDataSourceSecureJsonData {
|
||||
|
Reference in New Issue
Block a user