prometheus: more correct jsonData typescript type (#40559)

* prometheus: fix strict-mode typescript error

* it does not make the limit lower

but the change is still correct
This commit is contained in:
Gábor Farkas 2021-10-18 11:21:30 +02:00 committed by GitHub
parent 4a3be0f845
commit bd8e07d6ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -56,7 +56,7 @@ export class PrometheusDatasource extends DataSourceWithBackend<PromQuery, PromO
withCredentials: any;
metricsNameCache = new LRU<string, string[]>(10);
interval: string;
queryTimeout: string;
queryTimeout: string | undefined;
httpMethod: string;
languageProvider: PrometheusLanguageProvider;
exemplarTraceIdDestinations: ExemplarTraceIdDestination[] | undefined;
@ -80,7 +80,9 @@ export class PrometheusDatasource extends DataSourceWithBackend<PromQuery, PromO
this.interval = instanceSettings.jsonData.timeInterval || '15s';
this.queryTimeout = instanceSettings.jsonData.queryTimeout;
this.httpMethod = instanceSettings.jsonData.httpMethod || 'POST';
this.directUrl = instanceSettings.jsonData.directUrl;
// `directUrl` is never undefined, we set it at https://github.com/grafana/grafana/blob/main/pkg/api/frontendsettings.go#L108
// here we "fall back" to this.url to make typescript happy, but it should never happen
this.directUrl = instanceSettings.jsonData.directUrl ?? this.url;
this.exemplarTraceIdDestinations = instanceSettings.jsonData.exemplarTraceIdDestinations;
this.ruleMappings = {};
this.languageProvider = new PrometheusLanguageProvider(this);

View File

@ -20,10 +20,10 @@ export interface PromQuery extends DataQuery {
}
export interface PromOptions extends DataSourceJsonData {
timeInterval: string;
queryTimeout: string;
httpMethod: string;
directUrl: string;
timeInterval?: string;
queryTimeout?: string;
httpMethod?: string;
directUrl?: string;
customQueryParameters?: string;
disableMetricsLookup?: boolean;
exemplarTraceIdDestinations?: ExemplarTraceIdDestination[];