Skip to content

Commit

Permalink
Adding S3 metricset
Browse files Browse the repository at this point in the history
  • Loading branch information
simianhacker committed Nov 20, 2019
1 parent bf2a3bb commit e0aef39
Show file tree
Hide file tree
Showing 43 changed files with 672 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ export const sharedSchema = gql`
container
host
awsEC2
awsS3
}
`;
11 changes: 11 additions & 0 deletions x-pack/legacy/plugins/infra/common/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ export enum InfraNodeType {
container = 'container',
host = 'host',
awsEC2 = 'awsEC2',
awsS3 = 'awsS3',
}

export enum InfraSnapshotMetricType {
Expand All @@ -565,6 +566,11 @@ export enum InfraSnapshotMetricType {
logRate = 'logRate',
diskIOReadBytes = 'diskIOReadBytes',
diskIOWriteBytes = 'diskIOWriteBytes',
s3TotalRequests = 's3TotalRequests',
s3NumberOfObjects = 's3NumberOfObjects',
s3BucketSize = 's3BucketSize',
s3DownloadBytes = 's3DownloadBytes',
s3UploadBytes = 's3UploadBytes',
}

export enum InfraMetric {
Expand Down Expand Up @@ -608,6 +614,11 @@ export enum InfraMetric {
awsEC3CpuUtilization = 'awsEC2CpuUtilization',
awsEC2DiskIOBytes = 'awsEC2DiskIOBytes',
awsEC2NetworkTraffic = 'awsEC2NetworkTraffic',
awsS3TotalRequests = 'awsS3TotalRequests',
awsS3NumberOfObjects = 'awsS3NumberOfObjects',
awsS3BucketSize = 'awsS3BucketSize',
awsS3DownloadBytes = 'awsS3DownloadBytes',
awsS3UploadBytes = 'awsS3UploadBytes',
custom = 'custom',
}

Expand Down
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/infra/common/http_api/metadata_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,3 @@ export type InfraMetadataMachine = rt.TypeOf<typeof InfraMetadataMachineRT>;
export type InfraMetadataHost = rt.TypeOf<typeof InfraMetadataHostRT>;

export type InfraMetadataOS = rt.TypeOf<typeof InfraMetadataOSRT>;

export type InfraMetadataNodeType = rt.TypeOf<typeof InfraMetadataNodeTypeRT>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 { metrics } from './metrics';
import { InventoryModel } from '../types';

export const awsS3: InventoryModel = {
id: 'awsS3',
displayName: 'S3',
requiredModules: ['aws'],
metrics,
fields: {
id: 'aws.s3.bucket.name',
name: 'aws.s3.bucket.name',
},
requiredMetrics: [
'awsS3BucketSize',
'awsS3NumberOfObjects',
'awsS3TotalRequests',
'awsS3DownloadBytes',
'awsS3UploadBytes',
],
};
143 changes: 143 additions & 0 deletions x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
* 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 React from 'react';
import { i18n } from '@kbn/i18n';
import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types';
import { Section } from '../../../public/pages/metrics/components/section';
import { SubSection } from '../../../public/pages/metrics/components/sub_section';
import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis';
import { withTheme } from '../../../../../common/eui_styled_components';

export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => (
<React.Fragment>
<Section
navLabel="AWS S3"
sectionLabel={i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.overviewSection.sectionLabel',
{
defaultMessage: 'Aws S3 Overview',
}
)}
metrics={metrics}
>
<SubSection
id="awsS3BucketSize"
label={i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.bucketSize.sectionLabel',
{
defaultMessage: 'Bucket Size',
}
)}
>
<ChartSectionVis
type="bar"
formatter="bytes"
seriesOverrides={{
bytes: {
color: theme.eui.euiColorVis1,
name: i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.bucketSize.chartLabel',
{ defaultMessage: 'Total Bytes' }
),
},
}}
/>
</SubSection>
<SubSection
id="awsS3NumberOfObjects"
label={i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.numberOfObjects.sectionLabel',
{
defaultMessage: 'Number of Objects',
}
)}
>
<ChartSectionVis
type="bar"
formatter="abbreviatedNumber"
seriesOverrides={{
objects: {
color: theme.eui.euiColorVis1,
name: i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.numberOfObjects.chartLabel',
{ defaultMessage: 'Objects' }
),
},
}}
/>
</SubSection>
<SubSection
id="awsS3TotalRequests"
label={i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.totalRequests.sectionLabel',
{
defaultMessage: 'Total Requests',
}
)}
>
<ChartSectionVis
type="bar"
formatter="abbreviatedNumber"
seriesOverrides={{
total: {
color: theme.eui.euiColorVis1,
name: i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.totalRequests.chartLabel',
{ defaultMessage: 'Requests' }
),
},
}}
/>
</SubSection>
<SubSection
id="awsS3DownloadBytes"
label={i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.downloadBytes.sectionLabel',
{
defaultMessage: 'Downloaded Bytes',
}
)}
>
<ChartSectionVis
type="bar"
formatter="bytes"
seriesOverrides={{
bytes: {
color: theme.eui.euiColorVis1,
name: i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.downloadBytes.chartLabel',
{ defaultMessage: 'Bytes' }
),
},
}}
/>
</SubSection>
<SubSection
id="awsS3UploadBytes"
label={i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.uploadBytes.sectionLabel',
{
defaultMessage: 'Uploaded Bytes',
}
)}
>
<ChartSectionVis
type="bar"
formatter="bytes"
seriesOverrides={{
bytes: {
color: theme.eui.euiColorVis1,
name: i18n.translate(
'xpack.infra.metricDetailPage.s3MetricsLayout.uploadBytes.chartLabel',
{ defaultMessage: 'Bytes' }
),
},
}}
/>
</SubSection>
</Section>
</React.Fragment>
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 { InventoryMetrics } from '../../types';

import { awsS3BucketSize } from './tsvb/aws_s3_bucket_size';
import { awsS3TotalRequests } from './tsvb/aws_s3_total_requests';
import { awsS3NumberOfObjects } from './tsvb/aws_s3_number_of_objects';
import { awsS3DownloadBytes } from './tsvb/aws_s3_download_bytes';
import { awsS3UploadBytes } from './tsvb/aws_s3_upload_bytes';

import { s3BucketSize } from './snapshot/s3_bucket_size';
import { s3TotalRequests } from './snapshot/s3_total_requests';
import { s3NumberOfObjects } from './snapshot/s3_number_of_objects';
import { s3DownloadBytes } from './snapshot/s3_download_bytes';
import { s3UploadBytes } from './snapshot/s3_upload_bytes';

export const metrics: InventoryMetrics = {
tsvb: {
awsS3BucketSize,
awsS3TotalRequests,
awsS3NumberOfObjects,
awsS3DownloadBytes,
awsS3UploadBytes,
},
snapshot: {
s3BucketSize,
s3NumberOfObjects,
s3TotalRequests,
s3UploadBytes,
s3DownloadBytes,
},
defaultSnapshot: 's3BucketSize',
defaultTimeRangeInSeconds: 86400 * 7, // 7 days
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { SnapshotModel } from '../../../types';

export const s3BucketSize: SnapshotModel = {
s3BucketSize: {
max: {
field: 'aws.s3_daily_storage.bucket.size.bytes',
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { SnapshotModel } from '../../../types';

export const s3DownloadBytes: SnapshotModel = {
s3DownloadBytes: {
max: {
field: 'aws.s3_daily_storage.downloaded.bytes',
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { SnapshotModel } from '../../../types';

export const s3NumberOfObjects: SnapshotModel = {
s3NumberOfObjects: {
max: {
field: 'aws.s3_daily_storage.number_of_objects',
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { SnapshotModel } from '../../../types';

export const s3TotalRequests: SnapshotModel = {
s3TotalRequests: {
max: {
field: 'aws.s3_daily_storage.requests.total',
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { SnapshotModel } from '../../../types';

export const s3UploadBytes: SnapshotModel = {
s3UploadBytes: {
max: {
field: 'aws.s3_daily_storage.uploaded.bytes',
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 { TSVBMetricModelCreator, TSVBMetricModel } from '../../../types';

export const awsS3BucketSize: TSVBMetricModelCreator = (
timeField,
indexPattern
): TSVBMetricModel => ({
id: 'awsS3BucketSize',
requires: ['aws.s3_daily_storage'],
index_pattern: indexPattern,
interval: '>=86400s',
time_field: timeField,
type: 'timeseries',
series: [
{
id: 'bytes',
split_mode: 'everything',
metrics: [
{
field: 'aws.s3_daily_storage.bucket.size.bytes',
id: 'max-bytes',
type: 'max',
},
],
},
],
});
Loading

0 comments on commit e0aef39

Please sign in to comment.