[APM] Add telemetry about the number of environments within the last day (#162315)

Add telemetry about the number of environments within the last day.

The indexer will be updated by
https://github.com/elastic/telemetry/pull/2402.

Closes https://github.com/elastic/kibana/issues/161982

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Giorgos Bamparopoulos 2023-07-24 14:56:19 +01:00 committed by GitHub
parent 50a9e13035
commit e298d2c51f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 18 deletions

View file

@ -937,6 +937,16 @@ exports[`APM telemetry helpers getApmTelemetry generates a JSON object with the
"type": "long"
}
}
},
"environments": {
"properties": {
"1d": {
"type": "long",
"_meta": {
"description": "Total number of unique environments within the last day"
}
}
}
}
}
},

View file

@ -776,28 +776,31 @@ export const tasks: TelemetryTask[] = [
})
).hits.total.value;
const servicesCount = (
await telemetryClient.search({
index: [indices.transaction, indices.error, indices.metric],
body: {
track_total_hits: false,
size: 0,
timeout,
query: {
bool: {
filter: [range1d],
const servicesAndEnvironmentsCount = await telemetryClient.search({
index: [indices.transaction, indices.error, indices.metric],
body: {
track_total_hits: false,
size: 0,
timeout,
query: {
bool: {
filter: [range1d],
},
},
aggs: {
service_name: {
cardinality: {
field: SERVICE_NAME,
},
},
aggs: {
service_name: {
cardinality: {
field: SERVICE_NAME,
},
service_environments: {
cardinality: {
field: SERVICE_ENVIRONMENT,
},
},
},
})
).aggregations?.service_name.value;
},
});
return {
counts: {
@ -811,7 +814,14 @@ export const tasks: TelemetryTask[] = [
'1d': tracesPerDayCount || 0,
},
services: {
'1d': servicesCount || 0,
'1d':
servicesAndEnvironmentsCount.aggregations?.service_name.value ||
0,
},
environments: {
'1d':
servicesAndEnvironmentsCount.aggregations?.service_environments
.value || 0,
},
},
};

View file

@ -202,6 +202,15 @@ export const apmSchema: MakeSchemaFrom<APMUsage> = {
max_error_groups_per_service: timeframeMapSchema,
traces: timeframeMapSchema,
services: timeframeMapSchema,
environments: {
'1d': {
...long,
_meta: {
description:
'Total number of unique environments within the last day',
},
},
},
},
cardinality: {
client: { geo: { country_iso_code: { rum: timeframeMap1dSchema } } },

View file

@ -108,6 +108,7 @@ export interface APMUsage {
max_error_groups_per_service: TimeframeMap;
traces: TimeframeMap;
services: TimeframeMap;
environments: TimeframeMap1d;
};
cardinality: {
client: { geo: { country_iso_code: { rum: TimeframeMap1d } } };

View file

@ -4001,6 +4001,16 @@
"type": "long"
}
}
},
"environments": {
"properties": {
"1d": {
"type": "long",
"_meta": {
"description": "Total number of unique environments within the last day"
}
}
}
}
}
},