Skip to content

Commit

Permalink
Add agent/indices data; script to upload sample data
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Dec 5, 2019
1 parent 3db70f3 commit a2d96cc
Show file tree
Hide file tree
Showing 12 changed files with 733 additions and 689 deletions.
39 changes: 21 additions & 18 deletions x-pack/legacy/plugins/apm/common/agent_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,32 @@
* definitions in mappings.json (for telemetry), the AgentName type, and the
* agentNames object.
*/
import { AgentName } from '../typings/es_schemas/ui/fields/Agent';
export const AGENT_NAMES = [
'java',
'js-base',
'rum-js',
'dotnet',
'go',
'java',
'nodejs',
'python',
'ruby'
] as const;

const agentNames: { [agentName in AgentName]: agentName } = {
python: 'python',
java: 'java',
nodejs: 'nodejs',
'js-base': 'js-base',
'rum-js': 'rum-js',
dotnet: 'dotnet',
ruby: 'ruby',
go: 'go'
};
export type AgentName = typeof AGENT_NAMES[number];

export function isAgentName(agentName: string): boolean {
return Object.values(agentNames).includes(agentName as AgentName);
return AGENT_NAMES.includes(agentName as AgentName);
}

export function isRumAgentName(agentName: string | undefined) {
return (
agentName === agentNames['js-base'] || agentName === agentNames['rum-js']
);
export function isRumAgentName(
agentName: string | undefined
): agentName is AgentName {
return agentName === 'js-base' || agentName === 'rum-js';
}

export function isJavaAgentName(agentName: string | undefined) {
return agentName === agentNames.java;
export function isJavaAgentName(
agentName: string | undefined
): agentName is 'java' {
return agentName === 'java';
}
198 changes: 2 additions & 196 deletions x-pack/legacy/plugins/apm/mappings.json
Original file line number Diff line number Diff line change
@@ -1,201 +1,7 @@
{
"apm-telemetry": {
"properties": {
"counts": {
"properties": {
"agent_configuration": {
"properties": {
"all": {
"type": "long"
}
}
},
"error": {
"properties": {
"1M": {
"type": "long"
},
"1d": {
"type": "long"
},
"6M": {
"type": "long"
},
"all": {
"type": "long"
}
}
},
"max_error_groups_per_service": {
"properties": {
"all": {
"type": "long"
}
}
},
"max_transaction_groups_per_service": {
"properties": {
"all": {
"type": "long"
}
}
},
"metric": {
"properties": {
"1M": {
"type": "long"
},
"1d": {
"type": "long"
},
"6M": {
"type": "long"
},
"all": {
"type": "long"
}
}
},
"onboarding": {
"properties": {
"1M": {
"type": "long"
},
"1d": {
"type": "long"
},
"6M": {
"type": "long"
},
"all": {
"type": "long"
}
}
},
"services": {
"properties": {
"all": {
"type": "long"
}
}
},
"sourcemap": {
"properties": {
"1M": {
"type": "long"
},
"1d": {
"type": "long"
},
"6M": {
"type": "long"
},
"all": {
"type": "long"
}
}
},
"span": {
"properties": {
"1M": {
"type": "long"
},
"1d": {
"type": "long"
},
"6M": {
"type": "long"
},
"all": {
"type": "long"
}
}
},
"traces": {
"properties": {
"all": {
"type": "long"
}
}
},
"transaction": {
"properties": {
"1M": {
"type": "long"
},
"1d": {
"type": "long"
},
"6M": {
"type": "long"
},
"all": {
"type": "long"
}
}
}
}
},
"has_any_services": {
"type": "boolean"
},
"integrations": {
"properties": {
"ml": {
"properties": {
"has_anomalies_indices": {
"type": "boolean"
}
}
}
}
},
"services_per_agent": {
"properties": {
"dotnet": {
"type": "long"
},
"go": {
"type": "long"
},
"java": {
"type": "long"
},
"js-base": {
"type": "long"
},
"nodejs": {
"type": "long"
},
"python": {
"type": "long"
},
"ruby": {
"type": "long"
},
"rum-js": {
"type": "long"
}
}
},
"versions": {
"properties": {
"apm_server": {
"properties": {
"major": {
"type": "long"
},
"minor": {
"type": "long"
},
"patch": {
"type": "long"
}
}
}
}
}
}
"properties": {},
"dynamic": true
},
"apm-indices": {
"properties": {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/apm/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@octokit/rest": "^16.35.0"
"@octokit/rest": "^16.35.0",
"console-stamp": "^0.2.9"
}
}
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/apm/scripts/setup-kibana-security.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
******************************/

// compile typescript on the fly
// eslint-disable-next-line import/no-extraneous-dependencies
require('@babel/register')({
extensions: ['.ts'],
plugins: ['@babel/plugin-proposal-optional-chaining'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import {
} from 'lodash';
import uuid from 'uuid';
import {
telemetryMetricsTasks,
TelemetryTask
} from '../../server/lib/apm_telemetry/telemetry_metrics_tasks';

type TaskExecutorOptions = Parameters<TelemetryTask['executor']>[0];
collectDataTelemetry,
CollectTelemetryParams
} from '../../server/lib/apm_telemetry/collect_data_telemetry';

interface GenerateOptions {
days: number;
Expand Down Expand Up @@ -54,10 +52,10 @@ const mapValuesDeep = (

export async function generateSampleDocuments(
options: DeepPartial<GenerateOptions> & {
taskExecutorOptions: TaskExecutorOptions;
collectTelemetryParams: CollectTelemetryParams;
}
) {
const { taskExecutorOptions, ...preferredOptions } = options;
const { collectTelemetryParams, ...preferredOptions } = options;

const opts: GenerateOptions = defaultsDeep(
{
Expand All @@ -71,11 +69,7 @@ export async function generateSampleDocuments(
preferredOptions
);

const sample = await telemetryMetricsTasks.reduce((prev, task) => {
return prev.then(async data => {
return merge({}, data, await task.executor(taskExecutorOptions));
});
}, Promise.resolve({}));
const sample = await collectDataTelemetry(collectTelemetryParams);

const dateOfScriptExecution = new Date();

Expand Down
Loading

0 comments on commit a2d96cc

Please sign in to comment.