mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Update error message shown when testing the datasource (#70189)
* Elasticsearch: update error message shown when testing the datasource * Elasticsearch: update successful test message * Update e2e test
This commit is contained in:
@@ -75,7 +75,7 @@ export class LegacyQueryRunner {
|
|||||||
const message = err.data.error?.reason ?? err.data.message ?? 'Unknown error';
|
const message = err.data.error?.reason ?? err.data.message ?? 'Unknown error';
|
||||||
|
|
||||||
return throwError({
|
return throwError({
|
||||||
message: 'Elasticsearch error: ' + message,
|
message,
|
||||||
error: err.data.error,
|
error: err.data.error,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ describe('ElasticDatasource', () => {
|
|||||||
|
|
||||||
const errObject = {
|
const errObject = {
|
||||||
error: 'Bad Request',
|
error: 'Bad Request',
|
||||||
message: 'Elasticsearch error: Authentication to data source failed',
|
message: 'Authentication to data source failed',
|
||||||
};
|
};
|
||||||
|
|
||||||
await expect(ds.query(query)).toEmitValuesWith((received) => {
|
await expect(ds.query(query)).toEmitValuesWith((received) => {
|
||||||
|
|||||||
@@ -426,15 +426,12 @@ export class ElasticDatasource
|
|||||||
message: 'No date field named ' + this.timeField + ' found',
|
message: 'No date field named ' + this.timeField + ' found',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return of({ status: 'success', message: `${versionMessage}Index OK. Time field name OK` });
|
return of({ status: 'success', message: `${versionMessage}Data source successfully connected.` });
|
||||||
}),
|
}),
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
console.error(err);
|
const infoInParentheses = err.message ? ` (${err.message})` : '';
|
||||||
if (err.message) {
|
const message = `Unable to connect with Elasticsearch${infoInParentheses}. Please check the server logs for more details.`;
|
||||||
return of({ status: 'error', message: err.message });
|
return of({ status: 'error', message });
|
||||||
} else {
|
|
||||||
return of({ status: 'error', message: err.status });
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user