Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5405,35 +5405,59 @@
"monitor_name_stats": {
"properties": {
"avg_length": {
"type": "float"
"type": "float",
"_meta": {
"description": "This field represents the average length of monitor names"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for adding theses additional descriptions

}
},
"max_length": {
"type": "long"
"type": "long",
"_meta": {
"description": "This field represents the max length of monitor names"
}
},
"min_length": {
"type": "long"
"type": "long",
"_meta": {
"description": "This field represents the min length of monitor names"
}
}
}
},
"monitor_page": {
"type": "long"
},
"no_of_unique_monitors": {
"type": "long"
"type": "long",
"_meta": {
"description": "This field represents the number of unique configured monitors"
}
},
"no_of_unique_observer_locations": {
"type": "long"
"type": "long",
"_meta": {
"description": "This field represents the number of unique monitor observer locations"
}
},
"observer_location_name_stats": {
"properties": {
"avg_length": {
"type": "float"
"type": "float",
"_meta": {
"description": "This field represents the average length of monitor observer location names"
}
},
"max_length": {
"type": "long"
"type": "long",
"_meta": {
"description": "This field represents the max length of monitor observer location names"
}
},
"min_length": {
"type": "long"
"type": "long",
"_meta": {
"description": "This field represents the min length of monitor observer location names"
}
}
}
},
Expand All @@ -5442,6 +5466,43 @@
},
"settings_page": {
"type": "long"
},
"fleet_monitor_name_stats": {
"properties": {
"avg_length": {
"type": "float",
"_meta": {
"description": "This field represents the average length of fleet managed monitor names"
}
},
"max_length": {
"type": "long",
"_meta": {
"description": "This field represents the max length of fleet managed monitor names"
}
},
"min_length": {
"type": "long",
"_meta": {
"description": "This field represents the min length of fleet managed monitor names"
}
}
}
},
"fleet_monitor_frequency": {
"type": "array",
"items": {
"type": "long",
"_meta": {
"description": "This field represents the average the monitor frequency of fleet managed monitors"
}
}
},
"fleet_no_of_unique_monitors": {
"type": "long",
"_meta": {
"description": "This field represents the number of unique configured fleet managed monitors"
}
}
}
}
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ describe('KibanaTelemetryAdapter', () => {
},
};
getSavedObjectsClient = () => {
return {};
return {
get: () => {},
};
};
collectorFetchContext = createCollectorFetchContextMock();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,104 @@ export class KibanaTelemetryAdapter {
dateRangeStart: { type: 'array', items: { type: 'date' } },
monitor_frequency: { type: 'array', items: { type: 'long' } },
monitor_name_stats: {
avg_length: { type: 'float' },
max_length: { type: 'long' },
min_length: { type: 'long' },
avg_length: {
type: 'float',
_meta: {
description: 'This field represents the average length of monitor names',
},
},
max_length: {
type: 'long',
_meta: {
description: 'This field represents the max length of monitor names',
},
},
min_length: {
type: 'long',
_meta: {
description: 'This field represents the min length of monitor names',
},
},
},
monitor_page: { type: 'long' },
no_of_unique_monitors: { type: 'long' },
no_of_unique_observer_locations: { type: 'long' },
no_of_unique_monitors: {
type: 'long',
_meta: {
description: 'This field represents the number of unique configured monitors',
},
},
no_of_unique_observer_locations: {
type: 'long',
_meta: {
description:
'This field represents the number of unique monitor observer locations',
},
},
observer_location_name_stats: {
avg_length: { type: 'float' },
max_length: { type: 'long' },
min_length: { type: 'long' },
avg_length: {
type: 'float',
_meta: {
description:
'This field represents the average length of monitor observer location names',
},
},
max_length: {
type: 'long',
_meta: {
description:
'This field represents the max length of monitor observer location names',
},
},
min_length: {
type: 'long',
_meta: {
description:
'This field represents the min length of monitor observer location names',
},
},
},
overview_page: { type: 'long' },
settings_page: { type: 'long' },
fleet_monitor_name_stats: {
avg_length: {
type: 'float',
_meta: {
description:
'This field represents the average length of fleet managed monitor names',
},
},
max_length: {
type: 'long',
_meta: {
description:
'This field represents the max length of fleet managed monitor names',
},
},
min_length: {
type: 'long',
_meta: {
description:
'This field represents the min length of fleet managed monitor names',
},
},
},
fleet_monitor_frequency: {
type: 'array',
items: {
type: 'long',
_meta: {
description:
'This field represents the average the monitor frequency of fleet managed monitors',
},
},
},
fleet_no_of_unique_monitors: {
type: 'long',
_meta: {
description:
'This field represents the number of unique configured fleet managed monitors',
},
},
},
},
},
Expand All @@ -74,6 +158,7 @@ export class KibanaTelemetryAdapter {
if (savedObjectsClient) {
const uptimeEsClient = createUptimeESClient({ esClient, savedObjectsClient });
await this.countNoOfUniqueMonitorAndLocations(uptimeEsClient, savedObjectsClient);
await this.countNoOfUniqueFleetManagedMonitors(uptimeEsClient);
}
const report = this.getReport();
return { last_24_hours: { hits: { ...report } } };
Expand Down Expand Up @@ -218,6 +303,79 @@ export class KibanaTelemetryAdapter {
return bucket;
}

public static async countNoOfUniqueFleetManagedMonitors(callCluster: UptimeESClient) {
const params = {
index: 'synthetics-*',
body: {
query: {
bool: {
must: [
{
range: {
'@timestamp': {
gte: 'now-1d/d',
lt: 'now',
},
},
},
{
term: {
'monitor.fleet_managed': true,
},
},
],
},
},
size: 0,
aggs: {
unique_monitors: {
cardinality: {
field: 'monitor.id',
},
},
monitor_name: {
string_stats: {
field: 'monitor.name',
},
},
monitors: {
terms: {
field: 'monitor.id',
size: 1000,
},
aggs: {
docs: {
top_hits: {
size: 1,
_source: ['monitor.timespan'],
},
},
},
},
},
},
};

const { body: result } = await callCluster.search(params);

const numberOfUniqueMonitors: number = result?.aggregations?.unique_monitors?.value ?? 0;
const monitorNameStats = result?.aggregations?.monitor_name;
const uniqueMonitors: any = result?.aggregations?.monitors.buckets;

const bucketId = this.getBucketToIncrement();
const bucket = this.collector[bucketId];

bucket.fleet_no_of_unique_monitors = numberOfUniqueMonitors;
bucket.fleet_monitor_name_stats = {
min_length: monitorNameStats?.min_length ?? 0,
max_length: monitorNameStats?.max_length ?? 0,
avg_length: +(monitorNameStats?.avg_length?.toFixed(2) ?? 0),
};

bucket.fleet_monitor_frequency = this.getMonitorsFrequency(uniqueMonitors);
return bucket;
}

private static getMonitorsFrequency(uniqueMonitors = []) {
const frequencies: number[] = [];
uniqueMonitors
Expand Down Expand Up @@ -285,6 +443,14 @@ export class KibanaTelemetryAdapter {
dateRangeEnd: [],
autoRefreshEnabled: false,
autorefreshInterval: [],

fleet_no_of_unique_monitors: 0,
fleet_monitor_frequency: [],
fleet_monitor_name_stats: {
min_length: 0,
max_length: 0,
avg_length: 0,
},
};
}
return bucketId;
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/uptime/server/lib/adapters/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ export interface UptimeTelemetry {
dateRangeEnd: string[];
autorefreshInterval: number[];
autoRefreshEnabled: boolean;

fleet_no_of_unique_monitors: number;
fleet_monitor_frequency: number[];
fleet_monitor_name_stats: Stats;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const createLogPageViewRoute: UMRestApiRouteFactory = () => ({
uptimeEsClient,
savedObjectsClient
);
await KibanaTelemetryAdapter.countNoOfUniqueFleetManagedMonitors(uptimeEsClient);
return KibanaTelemetryAdapter.countPageView(pageView as PageViewParams);
},
});
Loading