-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on uptime homepage API (#70135)
Co-authored-by: Shahzad <[email protected]>
- Loading branch information
Showing
8 changed files
with
105 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
x-pack/plugins/uptime/public/apps/uptime_overview_fetcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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 { fetchPingHistogram, fetchSnapshotCount } from '../state/api'; | ||
import { UptimeFetchDataResponse } from '../../../observability/public/typings/fetch_data_response'; | ||
|
||
export async function fetchUptimeOverviewData({ | ||
startTime, | ||
endTime, | ||
bucketSize, | ||
}: { | ||
startTime: string; | ||
endTime: string; | ||
bucketSize: string; | ||
}) { | ||
const snapshot = await fetchSnapshotCount({ | ||
dateRangeStart: startTime, | ||
dateRangeEnd: endTime, | ||
}); | ||
|
||
const pings = await fetchPingHistogram({ dateStart: startTime, dateEnd: endTime, bucketSize }); | ||
|
||
const response: UptimeFetchDataResponse = { | ||
title: 'Uptime', | ||
appLink: '/app/uptime#/', | ||
stats: { | ||
monitors: { | ||
type: 'number', | ||
label: 'Monitors', | ||
value: snapshot.total, | ||
}, | ||
up: { | ||
type: 'number', | ||
label: 'Up', | ||
value: snapshot.up, | ||
}, | ||
down: { | ||
type: 'number', | ||
label: 'Down', | ||
value: snapshot.down, | ||
}, | ||
}, | ||
series: { | ||
up: { | ||
label: 'Up', | ||
coordinates: pings.histogram.map((p) => { | ||
return { x: p.x!, y: p.upCount || 0 }; | ||
}), | ||
}, | ||
down: { | ||
label: 'Down', | ||
coordinates: pings.histogram.map((p) => { | ||
return { x: p.x!, y: p.downCount || 0 }; | ||
}), | ||
}, | ||
}, | ||
}; | ||
return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters