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

pull/84336/head
Ivana Huckova 1 year 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
MaxConcurrentShardRequests int64
IncludeFrozen bool
XPack bool
}
type ConfiguredFields struct {
@ -262,7 +261,7 @@ func (c *baseClientImpl) getMultiSearchQueryParameters() string {
}
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")
}

@ -58,7 +58,6 @@ func TestClient_ExecuteMultisearch(t *testing.T) {
Interval: "Daily",
MaxConcurrentShardRequests: 6,
IncludeFrozen: true,
XPack: true,
}
from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC)
@ -148,7 +147,6 @@ func TestClient_ExecuteMultisearch(t *testing.T) {
Interval: "Daily",
MaxConcurrentShardRequests: 6,
IncludeFrozen: true,
XPack: true,
}
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,
MaxConcurrentShardRequests: 6,
IncludeFrozen: true,
XPack: true,
}
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
}
xpack, ok := jsonData["xpack"].(bool)
if !ok {
xpack = false
}
configuredFields := es.ConfiguredFields{
TimeField: timeField,
LogLevelField: logLevelField,
@ -177,7 +172,6 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
ConfiguredFields: configuredFields,
Interval: interval,
IncludeFrozen: includeFrozen,
XPack: xpack,
}
return model, nil
}

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

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

@ -1056,19 +1056,13 @@ describe('ElasticDatasource', () => {
describe('getMultiSearchUrl', () => {
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/);
});
it('Should NOT add ignore_throttled if "includeFrozen" is disabled', () => {
const { ds } = getTestContext({ jsonData: { includeFrozen: false, xpack: true } });
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 } });
const { ds } = getTestContext({ jsonData: { includeFrozen: false } });
expect(ds.getMultiSearchUrl()).not.toMatch(/ignore_throttled=false/);
});

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

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

Loading…
Cancel
Save