Skip to content

Commit

Permalink
ssl fixes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed Jul 7, 2020
1 parent 86c5d3d commit bfe2c00
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions x-pack/plugins/apm/common/elasticsearch_fieldnames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ describe('Transaction', () => {
name: 'java',
version: 'agent version',
},
cloud: {
availability_zone: 'europe-west1-c',
provider: 'gcp',
region: 'europe-west1',
},
http: {
request: { method: 'GET' },
response: { status_code: 200 },
Expand Down Expand Up @@ -74,6 +79,11 @@ describe('Span', () => {
name: 'java',
version: 'agent version',
},
cloud: {
availability_zone: 'europe-west1-c',
provider: 'gcp',
region: 'europe-west1',
},
processor: {
name: 'transaction',
event: 'span',
Expand Down Expand Up @@ -121,6 +131,11 @@ describe('Error', () => {
name: 'java',
version: 'agent version',
},
cloud: {
availability_zone: 'europe-west1-c',
provider: 'gcp',
region: 'europe-west1',
},
error: {
exception: [
{
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/apm/dev_docs/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ and/or config/kibana.dev.yml files.

Running the script with `--clear` will delete the index first.

If you're using an Elasticsearch instance without TLS verification (if you have `elasticsearch.ssl.verificationMode: none` set in your kibana.yml)
you can run the script with `env NODE_TLS_REJECT_UNAUTHORIZED=0` to avoid TLS connection errors.

After running the script you should see sample telemetry data in the "xpack-phone-home" index.

### Updating Data Telemetry Mappings
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ async function uploadData() {
...(httpAuth
? {
auth: { ...httpAuth, username: 'elastic' },
ssl: { rejectUnauthorized: false },
}
: { ssl: { rejectUnauthorized: false } }),
: {}),
});

// The new template is the template downloaded from the telemetry repo, with
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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 { tasks } from './tasks';
import { ApmIndicesConfig } from '../../settings/apm_indices/get_apm_indices';

describe('data telemetry collection tasks', () => {
const indices = {
'apm_oss.errorIndices': 'apm-8.0.0-error',
'apm_oss.metricsIndices': 'apm-8.0.0-metric',
'apm_oss.spanIndices': 'apm-8.0.0-span',
'apm_oss.transactionIndices': 'apm-8.0.0-transaction',
} as ApmIndicesConfig;

describe('cloud', () => {
const cloudTask = tasks.find((task) => task.name === 'cloud');

it('returns a map of cloud provider data', async () => {
const search = jest.fn().mockResolvedValueOnce({
aggregations: {
availability_zone: {
buckets: [
{ doc_count: 1, key: 'us-west-1' },
{ doc_count: 1, key: 'europe-west1-c' },
],
},
provider: {
buckets: [
{ doc_count: 1, key: 'aws' },
{ doc_count: 1, key: 'gcp' },
],
},
region: {
buckets: [
{ doc_count: 1, key: 'us-west' },
{ doc_count: 1, key: 'europe-west1' },
],
},
},
});

expect(await cloudTask?.executor({ indices, search } as any)).toEqual({
cloud: {
availability_zone: ['us-west-1', 'europe-west1-c'],
provider: ['aws', 'gcp'],
region: ['us-west', 'europe-west1'],
},
});
});

describe('with no results', () => {
it('returns an empty map', async () => {
const search = jest.fn().mockResolvedValueOnce({});

expect(await cloudTask?.executor({ indices, search } as any)).toEqual({
cloud: {
availability_zone: [],
provider: [],
region: [],
},
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const tasks: TelemetryTask[] = [
const { aggregations } = response;

if (!aggregations) {
return { [az]: [], [provider]: [], [region]: [] };
return { cloud: { [az]: [], [provider]: [], [region]: [] } };
}
const cloud = {
[az]: getBucketKeys(aggregations[az]),
Expand Down

0 comments on commit bfe2c00

Please sign in to comment.