Skip to content

Commit

Permalink
Reintroduce NAME_FIELDS for displayable names.
Browse files Browse the repository at this point in the history
  • Loading branch information
skh committed Apr 23, 2019
1 parent 48b2dbd commit d613e9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
InfraMetadataAggregationResponse,
} from '../framework';
import { InfraMetadataAdapter, InfraMetricsAdapterResponse } from './adapter_types';
import { NAME_FIELDS } from '../../constants';

export class ElasticsearchMetadataAdapter implements InfraMetadataAdapter {
private framework: InfraBackendFrameworkAdapter;
Expand Down Expand Up @@ -40,7 +41,7 @@ export class ElasticsearchMetadataAdapter implements InfraMetadataAdapter {
aggs: {
nodeName: {
terms: {
field: sourceConfiguration.fields[nodeType],
field: NAME_FIELDS[nodeType],
size: 1,
},
},
Expand Down Expand Up @@ -92,7 +93,7 @@ export class ElasticsearchMetadataAdapter implements InfraMetadataAdapter {
aggs: {
nodeName: {
terms: {
field: sourceConfiguration.fields[nodeType],
field: NAME_FIELDS[nodeType],
size: 1,
},
},
Expand Down
17 changes: 17 additions & 0 deletions x-pack/plugins/infra/server/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { InfraNodeType } from '../graphql/types';

// Used for metadata and snapshots resolvers to find the field that contains
// a displayable name of a node.
// Intentionally not the same as xpack.infra.sources.default.fields.{host,container,pod}.
// TODO: consider moving this to source configuration too.
export const NAME_FIELDS = {
[InfraNodeType.host]: 'host.name',
[InfraNodeType.pod]: 'kubernetes.pod.name',
[InfraNodeType.container]: 'container.name',
};

0 comments on commit d613e9c

Please sign in to comment.