-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
267 additions
and
34 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { fetchData } from '@/lib/clickhouse' | ||
import { cn } from '@/lib/utils' | ||
import { ChartCard } from '@/components/chart-card' | ||
import type { ChartProps } from '@/components/charts/chart-props' | ||
import { AreaChart } from '@/components/tremor' | ||
|
||
export async function ChartDisksUsage({ | ||
title, | ||
interval = 'toStartOfHour', | ||
className, | ||
chartClassName, | ||
lastHours = 24 * 7, | ||
...props | ||
}: ChartProps) { | ||
const data = await fetchData(` | ||
WITH CAST(sumMap(map(metric, value)), 'Map(LowCardinality(String), UInt32)') AS map | ||
SELECT | ||
${interval}(event_time) as event_time, | ||
map['DiskAvailable_default'] as DiskAvailable_default, | ||
formatReadableSize(DiskAvailable_default) as readable_DiskAvailable_default | ||
FROM system.asynchronous_metric_log | ||
WHERE event_time >= (now() - INTERVAL ${lastHours} HOUR) | ||
GROUP BY 1 | ||
ORDER BY 1 ASC | ||
`) | ||
|
||
return ( | ||
<ChartCard title={title} className={className}> | ||
<AreaChart | ||
className={cn('h-52', chartClassName)} | ||
data={data} | ||
index="event_time" | ||
categories={['DiskAvailable_default']} | ||
readableColumns={['readable_DiskAvailable_default']} | ||
{...props} | ||
/> | ||
</ChartCard> | ||
) | ||
} | ||
|
||
export default ChartDisksUsage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react' | ||
|
||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' | ||
import { Button } from '@/components/ui/button' | ||
|
||
interface ErrorAlertProps { | ||
title?: string | ||
message?: string | React.ReactNode | React.ReactNode[] | ||
reset?: () => void | ||
} | ||
|
||
export function ErrorAlert({ | ||
title = 'Something went wrong!', | ||
message = 'Checking console for more details.', | ||
reset, | ||
}: ErrorAlertProps) { | ||
return ( | ||
<Alert variant="destructive"> | ||
<AlertTitle className="text-lg">{title}</AlertTitle> | ||
<AlertDescription> | ||
<div className="mb-5 font-light"> | ||
<code>{message}</code> | ||
</div> | ||
|
||
{reset ? ( | ||
<Button | ||
variant="outline" | ||
onClick={ | ||
// Attempt to recover by trying to re-render the segment | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</Button> | ||
) : null} | ||
</AlertDescription> | ||
</Alert> | ||
) | ||
} |
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
Oops, something went wrong.