Skip to content

Commit

Permalink
[APM] Fix missing apm indicies
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Dec 18, 2019
1 parent e03b15e commit d2dcddc
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@ import { APMRequestHandlerContext } from '../../../routes/typings';

export async function saveApmIndices(
context: APMRequestHandlerContext,
apmIndicesSavedObject: Partial<ApmIndicesConfig>
apmIndices: Partial<ApmIndicesConfig>
) {
return await context.core.savedObjects.client.create(
APM_INDICES_SAVED_OBJECT_TYPE,
apmIndicesSavedObject,
removeEmpty(apmIndices),
{
id: APM_INDICES_SAVED_OBJECT_ID,
overwrite: true
}
);
}

// remove empty/undefined values
function removeEmpty(apmIndices: Partial<ApmIndicesConfig>) {
return Object.fromEntries(
Object.entries(apmIndices)
.map(([key, value]) => [key, value?.trim()])
.filter(([key, value]) => !!value)
);
}

0 comments on commit d2dcddc

Please sign in to comment.