Elasticsearch: Remove xpack button and make includeFrozen not dependant on it (#84734)

pull/84336/head
Ivana Huckova 2 years ago committed by GitHub
parent fba2b61408
commit 77b1c97482
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      pkg/tsdb/elasticsearch/client/client.go
  2. 3
      pkg/tsdb/elasticsearch/client/client_test.go
  3. 6
      pkg/tsdb/elasticsearch/elasticsearch.go
  4. 1
      pkg/tsdb/elasticsearch/querydata_test.go
  5. 29
      public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx
  6. 10
      public/app/plugins/datasource/elasticsearch/datasource.test.ts
  7. 4
      public/app/plugins/datasource/elasticsearch/datasource.ts
  8. 1
      public/app/plugins/datasource/elasticsearch/types.ts

@ -38,7 +38,6 @@ type DatasourceInfo struct {
Interval string Interval string
MaxConcurrentShardRequests int64 MaxConcurrentShardRequests int64
IncludeFrozen bool IncludeFrozen bool
XPack bool
} }
type ConfiguredFields struct { type ConfiguredFields struct {
@ -262,7 +261,7 @@ func (c *baseClientImpl) getMultiSearchQueryParameters() string {
} }
qs = append(qs, fmt.Sprintf("max_concurrent_shard_requests=%d", maxConcurrentShardRequests)) qs = append(qs, fmt.Sprintf("max_concurrent_shard_requests=%d", maxConcurrentShardRequests))
if c.ds.IncludeFrozen && c.ds.XPack { if c.ds.IncludeFrozen {
qs = append(qs, "ignore_throttled=false") qs = append(qs, "ignore_throttled=false")
} }

@ -58,7 +58,6 @@ func TestClient_ExecuteMultisearch(t *testing.T) {
Interval: "Daily", Interval: "Daily",
MaxConcurrentShardRequests: 6, MaxConcurrentShardRequests: 6,
IncludeFrozen: true, IncludeFrozen: true,
XPack: true,
} }
from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC) from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC)
@ -148,7 +147,6 @@ func TestClient_ExecuteMultisearch(t *testing.T) {
Interval: "Daily", Interval: "Daily",
MaxConcurrentShardRequests: 6, MaxConcurrentShardRequests: 6,
IncludeFrozen: true, IncludeFrozen: true,
XPack: true,
} }
from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC) from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC)
@ -253,7 +251,6 @@ func TestClient_Index(t *testing.T) {
Interval: test.patternInDatasource, Interval: test.patternInDatasource,
MaxConcurrentShardRequests: 6, MaxConcurrentShardRequests: 6,
IncludeFrozen: true, IncludeFrozen: true,
XPack: true,
} }
from := time.Date(2018, 5, 10, 17, 50, 0, 0, time.UTC) from := time.Date(2018, 5, 10, 17, 50, 0, 0, time.UTC)

@ -157,11 +157,6 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
includeFrozen = false includeFrozen = false
} }
xpack, ok := jsonData["xpack"].(bool)
if !ok {
xpack = false
}
configuredFields := es.ConfiguredFields{ configuredFields := es.ConfiguredFields{
TimeField: timeField, TimeField: timeField,
LogLevelField: logLevelField, LogLevelField: logLevelField,
@ -177,7 +172,6 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
ConfiguredFields: configuredFields, ConfiguredFields: configuredFields,
Interval: interval, Interval: interval,
IncludeFrozen: includeFrozen, IncludeFrozen: includeFrozen,
XPack: xpack,
} }
return model, nil return model, nil
} }

@ -57,7 +57,6 @@ func newFlowTestDsInfo(body []byte, statusCode int, requestCallback func(req *ht
HTTPClient: &client, HTTPClient: &client,
MaxConcurrentShardRequests: 42, MaxConcurrentShardRequests: 42,
IncludeFrozen: false, IncludeFrozen: false,
XPack: true,
} }
} }

@ -115,29 +115,18 @@ export const ElasticDetails = ({ value, onChange }: Props) => {
placeholder="10s" placeholder="10s"
/> />
</InlineField> </InlineField>
<InlineField
<InlineField label="X-Pack enabled" labelWidth={29} tooltip="Enable or disable X-Pack specific features"> label="Include Frozen Indices"
htmlFor="es_config_frozenIndices"
labelWidth={29}
tooltip="Include frozen indices in searches."
>
<InlineSwitch <InlineSwitch
id="es_config_xpackEnabled" id="es_config_frozenIndices"
value={value.jsonData.xpack || false} value={value.jsonData.includeFrozen ?? false}
onChange={jsonDataSwitchChangeHandler('xpack', value, onChange)} onChange={jsonDataSwitchChangeHandler('includeFrozen', value, onChange)}
/> />
</InlineField> </InlineField>
{value.jsonData.xpack && (
<InlineField
label="Include Frozen Indices"
htmlFor="es_config_frozenIndices"
labelWidth={29}
tooltip="Include frozen indices in searches."
>
<InlineSwitch
id="es_config_frozenIndices"
value={value.jsonData.includeFrozen ?? false}
onChange={jsonDataSwitchChangeHandler('includeFrozen', value, onChange)}
/>
</InlineField>
)}
</ConfigSubSection> </ConfigSubSection>
); );
}; };

@ -1056,19 +1056,13 @@ describe('ElasticDatasource', () => {
describe('getMultiSearchUrl', () => { describe('getMultiSearchUrl', () => {
it('Should add correct params to URL if "includeFrozen" is enabled', () => { it('Should add correct params to URL if "includeFrozen" is enabled', () => {
const { ds } = getTestContext({ jsonData: { includeFrozen: true, xpack: true } }); const { ds } = getTestContext({ jsonData: { includeFrozen: true } });
expect(ds.getMultiSearchUrl()).toMatch(/ignore_throttled=false/); expect(ds.getMultiSearchUrl()).toMatch(/ignore_throttled=false/);
}); });
it('Should NOT add ignore_throttled if "includeFrozen" is disabled', () => { it('Should NOT add ignore_throttled if "includeFrozen" is disabled', () => {
const { ds } = getTestContext({ jsonData: { includeFrozen: false, xpack: true } }); const { ds } = getTestContext({ jsonData: { includeFrozen: false } });
expect(ds.getMultiSearchUrl()).not.toMatch(/ignore_throttled=false/);
});
it('Should NOT add ignore_throttled if "xpack" is disabled', () => {
const { ds } = getTestContext({ jsonData: { includeFrozen: true, xpack: false } });
expect(ds.getMultiSearchUrl()).not.toMatch(/ignore_throttled=false/); expect(ds.getMultiSearchUrl()).not.toMatch(/ignore_throttled=false/);
}); });

@ -115,7 +115,6 @@ export class ElasticDatasource
name: string; name: string;
index: string; index: string;
timeField: string; timeField: string;
xpack: boolean;
interval: string; interval: string;
maxConcurrentShardRequests?: number; maxConcurrentShardRequests?: number;
queryBuilder: ElasticQueryBuilder; queryBuilder: ElasticQueryBuilder;
@ -144,7 +143,6 @@ export class ElasticDatasource
this.index = settingsData.index ?? instanceSettings.database ?? ''; this.index = settingsData.index ?? instanceSettings.database ?? '';
this.timeField = settingsData.timeField; this.timeField = settingsData.timeField;
this.xpack = Boolean(settingsData.xpack);
this.indexPattern = new IndexPattern(this.index, settingsData.interval); this.indexPattern = new IndexPattern(this.index, settingsData.interval);
this.intervalPattern = settingsData.interval; this.intervalPattern = settingsData.interval;
this.interval = settingsData.timeInterval; this.interval = settingsData.timeInterval;
@ -827,7 +825,7 @@ export class ElasticDatasource
searchParams.append('max_concurrent_shard_requests', `${this.maxConcurrentShardRequests}`); searchParams.append('max_concurrent_shard_requests', `${this.maxConcurrentShardRequests}`);
} }
if (this.xpack && this.includeFrozen) { if (this.includeFrozen) {
searchParams.append('ignore_throttled', 'false'); searchParams.append('ignore_throttled', 'false');
} }

@ -56,7 +56,6 @@ export interface ElasticsearchOptions extends DataSourceJsonData {
timeField: string; timeField: string;
// we used to have a field named `esVersion` in the past, // we used to have a field named `esVersion` in the past,
// please do not use that name in the future. // please do not use that name in the future.
xpack?: boolean;
interval?: Interval; interval?: Interval;
timeInterval: string; timeInterval: string;
maxConcurrentShardRequests?: number; maxConcurrentShardRequests?: number;

Loading…
Cancel
Save