parent
da13795ed4
commit
1dce600efe
6 changed files with 141 additions and 4 deletions
|
@ -675,6 +675,17 @@ exports[`APM telemetry helpers getApmTelemetry generates a JSON object with the
|
|||
}
|
||||
}
|
||||
},
|
||||
"host": {
|
||||
"properties": {
|
||||
"os": {
|
||||
"properties": {
|
||||
"platform": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"counts": {
|
||||
"properties": {
|
||||
"transaction": {
|
||||
|
@ -967,6 +978,17 @@ exports[`APM telemetry helpers getApmTelemetry generates a JSON object with the
|
|||
}
|
||||
}
|
||||
},
|
||||
"host": {
|
||||
"properties": {
|
||||
"took": {
|
||||
"properties": {
|
||||
"ms": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"processor_events": {
|
||||
"properties": {
|
||||
"took": {
|
||||
|
|
|
@ -209,6 +209,44 @@ describe('data telemetry collection tasks', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('host', () => {
|
||||
const task = tasks.find((t) => t.name === 'host');
|
||||
|
||||
it('returns a map of host provider data', async () => {
|
||||
const search = jest.fn().mockResolvedValueOnce({
|
||||
aggregations: {
|
||||
platform: {
|
||||
buckets: [
|
||||
{ doc_count: 1, key: 'linux' },
|
||||
{ doc_count: 1, key: 'windows' },
|
||||
{ doc_count: 1, key: 'macos' },
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(await task?.executor({ indices, search } as any)).toEqual({
|
||||
host: {
|
||||
os: { platform: ['linux', 'windows', 'macos'] },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
describe('with no results', () => {
|
||||
it('returns an empty map', async () => {
|
||||
const search = jest.fn().mockResolvedValueOnce({});
|
||||
|
||||
expect(await task?.executor({ indices, search } as any)).toEqual({
|
||||
host: {
|
||||
os: {
|
||||
platform: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('processor_events', () => {
|
||||
const task = tasks.find((t) => t.name === 'processor_events');
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
CONTAINER_ID,
|
||||
ERROR_GROUP_ID,
|
||||
HOST_NAME,
|
||||
HOST_OS_PLATFORM,
|
||||
OBSERVER_HOSTNAME,
|
||||
PARENT_ID,
|
||||
POD_NAME,
|
||||
|
@ -293,6 +294,53 @@ export const tasks: TelemetryTask[] = [
|
|||
return { cloud };
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'host',
|
||||
executor: async ({ indices, search }) => {
|
||||
function getBucketKeys({
|
||||
buckets,
|
||||
}: {
|
||||
buckets: Array<{
|
||||
doc_count: number;
|
||||
key: string | number;
|
||||
}>;
|
||||
}) {
|
||||
return buckets.map((bucket) => bucket.key as string);
|
||||
}
|
||||
|
||||
const response = await search({
|
||||
index: [
|
||||
indices['apm_oss.errorIndices'],
|
||||
indices['apm_oss.metricsIndices'],
|
||||
indices['apm_oss.spanIndices'],
|
||||
indices['apm_oss.transactionIndices'],
|
||||
],
|
||||
body: {
|
||||
size: 0,
|
||||
timeout,
|
||||
aggs: {
|
||||
platform: {
|
||||
terms: {
|
||||
field: HOST_OS_PLATFORM,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const { aggregations } = response;
|
||||
|
||||
if (!aggregations) {
|
||||
return { host: { os: { platform: [] } } };
|
||||
}
|
||||
const host = {
|
||||
os: {
|
||||
platform: getBucketKeys(aggregations.platform),
|
||||
},
|
||||
};
|
||||
return { host };
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'environments',
|
||||
executor: async ({ indices, search }) => {
|
||||
|
|
|
@ -135,6 +135,7 @@ export const apmSchema: MakeSchemaFrom<APMUsage> = {
|
|||
provider: { type: 'array', items: { type: 'keyword' } },
|
||||
region: { type: 'array', items: { type: 'keyword' } },
|
||||
},
|
||||
host: { os: { platform: { type: 'array', items: { type: 'keyword' } } } },
|
||||
counts: {
|
||||
transaction: timeframeMapSchema,
|
||||
span: timeframeMapSchema,
|
||||
|
@ -185,6 +186,7 @@ export const apmSchema: MakeSchemaFrom<APMUsage> = {
|
|||
tasks: {
|
||||
aggregated_transactions: { took: { ms: long } },
|
||||
cloud: { took: { ms: long } },
|
||||
host: { took: { ms: long } },
|
||||
processor_events: { took: { ms: long } },
|
||||
agent_configuration: { took: { ms: long } },
|
||||
services: { took: { ms: long } },
|
||||
|
|
|
@ -52,6 +52,7 @@ export interface APMUsage {
|
|||
provider: string[];
|
||||
region: string[];
|
||||
};
|
||||
host: { os: { platform: string[] } };
|
||||
counts: {
|
||||
transaction: TimeframeMap;
|
||||
span: TimeframeMap;
|
||||
|
@ -132,6 +133,7 @@ export interface APMUsage {
|
|||
tasks: Record<
|
||||
| 'aggregated_transactions'
|
||||
| 'cloud'
|
||||
| 'host'
|
||||
| 'processor_events'
|
||||
| 'agent_configuration'
|
||||
| 'services'
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
"__index": {
|
||||
"type": "long"
|
||||
},
|
||||
"__swimlane": {
|
||||
"__pagerduty": {
|
||||
"type": "long"
|
||||
},
|
||||
"__pagerduty": {
|
||||
"__swimlane": {
|
||||
"type": "long"
|
||||
},
|
||||
"__server-log": {
|
||||
|
@ -71,10 +71,10 @@
|
|||
"__index": {
|
||||
"type": "long"
|
||||
},
|
||||
"__swimlane": {
|
||||
"__pagerduty": {
|
||||
"type": "long"
|
||||
},
|
||||
"__pagerduty": {
|
||||
"__swimlane": {
|
||||
"type": "long"
|
||||
},
|
||||
"__server-log": {
|
||||
|
@ -1260,6 +1260,20 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"host": {
|
||||
"properties": {
|
||||
"os": {
|
||||
"properties": {
|
||||
"platform": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"counts": {
|
||||
"properties": {
|
||||
"transaction": {
|
||||
|
@ -1552,6 +1566,17 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"host": {
|
||||
"properties": {
|
||||
"took": {
|
||||
"properties": {
|
||||
"ms": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"processor_events": {
|
||||
"properties": {
|
||||
"took": {
|
||||
|
|
Loading…
Reference in a new issue