2019-10-25 22:43:20 +08:00
|
|
|
import React, { useEffect } from 'react';
|
2020-12-09 21:27:40 +08:00
|
|
|
import { Alert, DataSourceHttpSettings } from '@grafana/ui';
|
2019-10-31 17:48:05 +08:00
|
|
|
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
2019-10-25 22:43:20 +08:00
|
|
|
import { ElasticsearchOptions } from '../types';
|
|
|
|
|
import { defaultMaxConcurrentShardRequests, ElasticDetails } from './ElasticDetails';
|
|
|
|
|
import { LogsConfig } from './LogsConfig';
|
2019-12-12 00:40:56 +08:00
|
|
|
import { DataLinks } from './DataLinks';
|
2020-10-08 16:03:20 +08:00
|
|
|
import { config } from 'app/core/config';
|
2019-10-25 22:43:20 +08:00
|
|
|
|
|
|
|
|
export type Props = DataSourcePluginOptionsEditorProps<ElasticsearchOptions>;
|
|
|
|
|
export const ConfigEditor = (props: Props) => {
|
|
|
|
|
const { options, onOptionsChange } = props;
|
|
|
|
|
|
|
|
|
|
// Apply some defaults on initial render
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const esVersion = options.jsonData.esVersion || 5;
|
|
|
|
|
onOptionsChange({
|
|
|
|
|
...options,
|
|
|
|
|
jsonData: {
|
|
|
|
|
...options.jsonData,
|
|
|
|
|
timeField: options.jsonData.timeField || '@timestamp',
|
|
|
|
|
esVersion,
|
|
|
|
|
maxConcurrentShardRequests:
|
|
|
|
|
options.jsonData.maxConcurrentShardRequests || defaultMaxConcurrentShardRequests(esVersion),
|
|
|
|
|
logMessageField: options.jsonData.logMessageField || '',
|
|
|
|
|
logLevelField: options.jsonData.logLevelField || '',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2020-12-09 21:27:40 +08:00
|
|
|
{options.access === 'direct' && (
|
|
|
|
|
<Alert title="Deprecation Notice" severity="warning">
|
|
|
|
|
Browser access mode in the Elasticsearch datasource is deprecated and will be removed in a future release.
|
|
|
|
|
</Alert>
|
|
|
|
|
)}
|
|
|
|
|
|
2019-10-25 22:43:20 +08:00
|
|
|
<DataSourceHttpSettings
|
2019-12-08 13:50:54 +08:00
|
|
|
defaultUrl={'http://localhost:9200'}
|
2019-10-25 22:43:20 +08:00
|
|
|
dataSourceConfig={options}
|
|
|
|
|
showAccessOptions={true}
|
|
|
|
|
onChange={onOptionsChange}
|
2020-10-08 16:03:20 +08:00
|
|
|
sigV4AuthToggleEnabled={config.sigV4AuthEnabled}
|
2019-10-25 22:43:20 +08:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<ElasticDetails value={options} onChange={onOptionsChange} />
|
|
|
|
|
|
|
|
|
|
<LogsConfig
|
|
|
|
|
value={options.jsonData}
|
2021-01-20 14:59:48 +08:00
|
|
|
onChange={(newValue) =>
|
2019-10-25 22:43:20 +08:00
|
|
|
onOptionsChange({
|
|
|
|
|
...options,
|
|
|
|
|
jsonData: newValue,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
2019-12-12 00:40:56 +08:00
|
|
|
|
|
|
|
|
<DataLinks
|
|
|
|
|
value={options.jsonData.dataLinks}
|
2021-01-20 14:59:48 +08:00
|
|
|
onChange={(newValue) => {
|
2019-12-12 00:40:56 +08:00
|
|
|
onOptionsChange({
|
|
|
|
|
...options,
|
|
|
|
|
jsonData: {
|
|
|
|
|
...options.jsonData,
|
|
|
|
|
dataLinks: newValue,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2019-10-25 22:43:20 +08:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|