Explorar o código

Loki: Apply start parameter to speed up test query (#18266)

David %!s(int64=6) %!d(string=hai) anos
pai
achega
e8790c32ca
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      public/app/plugins/datasource/loki/datasource.ts

+ 4 - 1
public/app/plugins/datasource/loki/datasource.ts

@@ -357,7 +357,10 @@ export class LokiDatasource extends DataSourceApi<LokiQuery, LokiOptions> {
   };
 
   testDatasource() {
-    return this._request('/api/prom/label')
+    // Consider only last 10 minutes otherwise request takes too long
+    const startMs = Date.now() - 10 * 60 * 1000;
+    const start = `${startMs}000000`; // API expects nanoseconds
+    return this._request('/api/prom/label', { start })
       .then((res: DataQueryResponse) => {
         if (res && res.data && res.data.values && res.data.values.length > 0) {
           return { status: 'success', message: 'Data source connected and labels found.' };