mirror of
https://github.com/grafana/grafana.git
synced 2025-09-25 12:13:55 +08:00

* Revert "Revert "Elasticsearch: add frozen indices search support (#27472)" (#27726)" This reverts commit 4c7131425ba048c648435410f2153d4d85f20304. * Make label width a bit more consistent * Add documentation for X-Pack & Frozen Indices support in Elasticsearch * Change UI & docs casing * create default empty dataframe * Remove backticks and simplify regex * small doc improvement
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { DataSourceSettings } from '@grafana/data';
|
|
import { valid } from 'semver';
|
|
import { ElasticsearchOptions } from '../types';
|
|
import { coerceESVersion } from '../utils';
|
|
import { defaultMaxConcurrentShardRequests } from './ElasticDetails';
|
|
|
|
export const coerceOptions = (
|
|
options: DataSourceSettings<ElasticsearchOptions, {}>
|
|
): DataSourceSettings<ElasticsearchOptions, {}> => {
|
|
const esVersion = coerceESVersion(options.jsonData.esVersion);
|
|
|
|
return {
|
|
...options,
|
|
jsonData: {
|
|
...options.jsonData,
|
|
timeField: options.jsonData.timeField || '@timestamp',
|
|
esVersion,
|
|
maxConcurrentShardRequests:
|
|
options.jsonData.maxConcurrentShardRequests || defaultMaxConcurrentShardRequests(esVersion),
|
|
logMessageField: options.jsonData.logMessageField || '',
|
|
logLevelField: options.jsonData.logLevelField || '',
|
|
includeFrozen: options.jsonData.includeFrozen ?? false,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const isValidOptions = (options: DataSourceSettings<ElasticsearchOptions, {}>): boolean => {
|
|
return (
|
|
// esVersion should be a valid semver string
|
|
!!valid(options.jsonData.esVersion) &&
|
|
// timeField should not be empty or nullish
|
|
!!options.jsonData.timeField &&
|
|
// maxConcurrentShardRequests should be a number AND greater than 0
|
|
!!options.jsonData.maxConcurrentShardRequests &&
|
|
// message & level fields should be defined
|
|
options.jsonData.logMessageField !== undefined &&
|
|
options.jsonData.logLevelField !== undefined
|
|
);
|
|
};
|