Skip to content

Commit

Permalink
discover changes only
Browse files Browse the repository at this point in the history
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
  • Loading branch information
Arpit-Bandejiya committed Oct 20, 2022
1 parent fb39f7d commit 6b9347c
Show file tree
Hide file tree
Showing 25 changed files with 476 additions and 86 deletions.
8 changes: 4 additions & 4 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@

# Set the value of this setting to true to enables the experimental multiple data source
# support feature. Use with caution.
#data_source.enabled: false
data_source.enabled: true
# Set the value of these settings to custermize crypto materials to encryption saved credentials
# in data sources.
#data_source.encryption.wrappingKeyName: 'changeme'
#data_source.encryption.wrappingKeyNamespace: 'changeme'
#data_source.encryption.wrappingKey: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
data_source.encryption.wrappingKeyName: 'changeme'
data_source.encryption.wrappingKeyNamespace: 'changeme'
data_source.encryption.wrappingKey: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"angular-elastic": "^2.5.1",
"angular-sanitize": "^1.8.0",
"bluebird": "3.5.5",
"caniuse-lite": "^1.0.30001397",
"chalk": "^4.1.0",
"chokidar": "^3.4.2",
"color": "1.0.3",
Expand Down Expand Up @@ -212,6 +213,7 @@
"type-detect": "^4.0.8",
"uuid": "3.3.2",
"whatwg-fetch": "^3.0.0",
"yarn": "^1.22.19",
"yauzl": "^2.10.0"
},
"devDependencies": {
Expand Down Expand Up @@ -461,4 +463,4 @@
"node": "14.20.0",
"yarn": "^1.21.1"
}
}
}
1 change: 1 addition & 0 deletions src/core/server/opensearch/legacy/cluster_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const callAPI = async (
) => {
const clientPath = endpoint.split('.');
const api: any = get(client, clientPath);
console.log("This is the low level client call", clientPath, get(client, clientPath));
if (!api) {
throw new Error(`called with an invalid endpoint: ${endpoint}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function createIndexPatternCache(): PatternCache {
},
set: (id: string, prom: any) => {
vals[id] = prom;
console.log("This is the set value", prom);
return prom;
},
clear: (id: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface SavedObjectBody {
type FormatFieldFn = (hit: Record<string, any>, fieldName: string) => any;

const DATA_SOURCE_REFERNECE_NAME = 'dataSource';

export class IndexPattern implements IIndexPattern {
public id?: string;
public title: string = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export class IndexPatternsService {
fields: ['title'],
perPage: 10000,
});
console.log("this is the call for refresh saved object cache")
}

/**
Expand All @@ -126,6 +127,7 @@ export class IndexPatternsService {
*/
getIds = async (refresh: boolean = false) => {
if (!this.savedObjectsCache || refresh) {
console.log("fetching the ids")
await this.refreshSavedObjectsCache();
}
if (!this.savedObjectsCache) {
Expand All @@ -140,6 +142,7 @@ export class IndexPatternsService {
*/
getTitles = async (refresh: boolean = false): Promise<string[]> => {
if (!this.savedObjectsCache || refresh) {
console.log("get tittles")
await this.refreshSavedObjectsCache();
}
if (!this.savedObjectsCache) {
Expand All @@ -156,6 +159,7 @@ export class IndexPatternsService {
refresh: boolean = false
): Promise<Array<{ id: string; title: string }>> => {
if (!this.savedObjectsCache || refresh) {
console.log("Fetching ids with title")
await this.refreshSavedObjectsCache();
}
if (!this.savedObjectsCache) {
Expand All @@ -182,6 +186,7 @@ export class IndexPatternsService {

getCache = async () => {
if (!this.savedObjectsCache) {
console.log("get cache saved objects")
await this.refreshSavedObjectsCache();
}
return this.savedObjectsCache;
Expand Down Expand Up @@ -232,6 +237,7 @@ export class IndexPatternsService {
*/
getFieldsForWildcard = async (options: GetFieldsOptions = {}) => {
const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
console.log("fetching the value from the wildard values")
return this.apiClient.getFieldsForWildcard({
pattern: options.pattern,
metaFields,
Expand All @@ -248,14 +254,17 @@ export class IndexPatternsService {
getFieldsForIndexPattern = async (
indexPattern: IndexPattern | IndexPatternSpec,
options: GetFieldsOptions = {}
) =>
this.getFieldsForWildcard({
) => {
console.log(indexPattern.title)
return this.getFieldsForWildcard({
pattern: indexPattern.title as string,
...options,
type: indexPattern.type,
params: indexPattern.typeMeta && indexPattern.typeMeta.params,
dataSourceId: indexPattern.dataSourceRef?.id,
});
}


/**
* Refresh field list for a given index pattern
Expand All @@ -264,6 +273,7 @@ export class IndexPatternsService {
refreshFields = async (indexPattern: IndexPattern) => {
try {
const fields = await this.getFieldsForIndexPattern(indexPattern);
console.log("Fetching the fields from the Index patterns")
const scripted = indexPattern.getScriptedFields().map((field) => field.spec);
indexPattern.fields.replaceAll([...fields, ...scripted]);
} catch (err) {
Expand Down Expand Up @@ -388,6 +398,8 @@ export class IndexPatternsService {
get = async (id: string): Promise<IndexPattern> => {
const cache = indexPatternCache.get(id);
if (cache) {
console.log("This is in the cache");
console.log(cache);
return cache;
}

Expand All @@ -396,6 +408,8 @@ export class IndexPatternsService {
id
);

console.log("This is the saved object intially in the get call 409");
console.log(savedObject);
if (!savedObject.version) {
throw new SavedObjectNotFound(
savedObjectType,
Expand Down Expand Up @@ -523,6 +537,7 @@ export class IndexPatternsService {
}

find = async (search: string, size: number = 10): Promise<IndexPattern[]> => {
console.log("finding the search")
const savedObjects = await this.savedObjectsClient.find<IndexPatternSavedObjectAttrs>({
type: 'index-pattern',
fields: ['title'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export function getRequestInspectorStats(searchSource: ISearchSource) {
}),
};
}

return stats;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export function getSearchParamsFromRequest(
const { getConfig } = dependencies;
const searchParams = getSearchParams(getConfig);

if (searchRequest.body.pit) {
console.log("pit is present");
delete searchParams.preference;
return {
body: searchRequest.body, ...searchParams,
};
} else {
console.log("PIT is not present here");
}
return {
index: searchRequest.index.title || searchRequest.index,
body: searchRequest.body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import { GetFieldsOptions, IIndexPatternsApiClient } from '../../common/index_patterns/types';
import { GetFieldsOptions, IIndexPatternsApiClient } from '../../common';

export class IndexPatternsApiServer implements IIndexPatternsApiClient {
async getFieldsForTimePattern(options: GetFieldsOptions = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function getDefaultSearchParams(uiSettingsClient: IUiSettingsClient
maxConcurrentShardRequests:
maxConcurrentShardRequests > 0 ? maxConcurrentShardRequests : undefined,
ignoreThrottled,
ignoreUnavailable: true, // Don't fail if the index/indices don't exist
ignoreUnavailable: false, // Don't fail if the index/indices don't exist
trackTotalHits: true,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ export const opensearchSearchStrategyProvider = (

// ignoreThrottled is not supported in OSS
const { ignoreThrottled, ...defaultParams } = await getDefaultSearchParams(uiSettingsClient);

console.log("these are the default params",defaultParams)
const params = toSnakeCase({
...defaultParams,
...getShardTimeout(config),
...request.params,
});

if (params.body.pit) {
console.log("deleting the ignore unavailable values ");
delete params.ignore_unavailable;
}
console.log("these are the params",params);
try {
const client = await decideClient(context, request);
const promise = shimAbortSignal(client.search(params), options?.abortSignal);
Expand Down
Loading

0 comments on commit 6b9347c

Please sign in to comment.