kibana/x-pack/plugins/infra/common/ecs_allowed_list.ts
Brandon Kobel 4584a8b570
Elastic License 2.0 (#90099)
* Updating everything except the license headers themselves

* Applying ESLint rules

* Manually replacing the stragglers
2021-02-03 18:12:39 -08:00

72 lines
1.9 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { first, memoize } from 'lodash';
export const ECS_ALLOWED_LIST = [
'host',
'cloud',
'event',
'agent',
'fields',
'service',
'ecs',
'metricset',
'tags',
'message',
'labels',
'@timestamp',
'source',
'container',
];
export const K8S_ALLOWED_LIST = [
'kubernetes.pod.name',
'kubernetes.pod.uid',
'kubernetes.namespace',
'kubernetes.node.name',
'kubernetes.labels',
'kubernetes.annotations',
'kubernetes.replicaset.name',
'kubernetes.deployment.name',
'kubernetes.statefulset.name',
'kubernetes.container.name',
'kubernetes.container.image',
];
export const PROMETHEUS_ALLOWED_LIST = ['prometheus.labels', 'prometheus.metrics'];
export const DOCKER_ALLOWED_LIST = [
'docker.container.id',
'docker.container.image',
'docker.container.name',
'docker.container.labels',
];
export const AWS_S3_ALLOWED_LIST = ['aws.s3'];
export const AWS_METRICS_ALLOWED_LIST = ['aws.dimensions'];
export const getAllowedListForPrefix = memoize((prefix: string) => {
const firstPart = first(prefix.split(/\./));
const defaultAllowedList = prefix ? [...ECS_ALLOWED_LIST, prefix] : ECS_ALLOWED_LIST;
switch (firstPart) {
case 'docker':
return [...defaultAllowedList, ...DOCKER_ALLOWED_LIST];
case 'prometheus':
return [...defaultAllowedList, ...PROMETHEUS_ALLOWED_LIST];
case 'kubernetes':
return [...defaultAllowedList, ...K8S_ALLOWED_LIST];
case 'aws':
if (prefix === 'aws.s3_daily_storage') {
return [...defaultAllowedList, ...AWS_S3_ALLOWED_LIST, ...AWS_METRICS_ALLOWED_LIST];
}
return [...defaultAllowedList, ...AWS_METRICS_ALLOWED_LIST];
default:
return defaultAllowedList;
}
});