Skip to content

Commit

Permalink
refactor: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Siumauricio committed Dec 30, 2024
1 parent 18e5781 commit ce552c7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ShowExternalMariadbCredentials } from "@/components/dashboard/mariadb/g
import { ShowGeneralMariadb } from "@/components/dashboard/mariadb/general/show-general-mariadb";
import { ShowInternalMariadbCredentials } from "@/components/dashboard/mariadb/general/show-internal-mariadb-credentials";
import { UpdateMariadb } from "@/components/dashboard/mariadb/update-mariadb";
import { DockerMonitoring } from "@/components/dashboard/monitoring/docker/show";
import { ContainerMonitoring } from "@/components/dashboard/monitoring/container/show";
import { MariadbIcon } from "@/components/icons/data-tools-icons";
import { ProjectLayout } from "@/components/layouts/project-layout";
import { StatusTooltip } from "@/components/shared/status-tooltip";
Expand Down Expand Up @@ -214,7 +214,10 @@ const Mariadb = (
{!data?.serverId && (
<TabsContent value="monitoring">
<div className="flex flex-col gap-4 pt-2.5">
<DockerMonitoring appName={data?.appName || ""} />
<ContainerMonitoring
appName={data?.appName || ""}
BASE_URL={"http://localhost:3001"}
/>
</div>
</TabsContent>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ShowExternalMongoCredentials } from "@/components/dashboard/mongo/gener
import { ShowGeneralMongo } from "@/components/dashboard/mongo/general/show-general-mongo";
import { ShowInternalMongoCredentials } from "@/components/dashboard/mongo/general/show-internal-mongo-credentials";
import { UpdateMongo } from "@/components/dashboard/mongo/update-mongo";
import { DockerMonitoring } from "@/components/dashboard/monitoring/docker/show";
import { ContainerMonitoring } from "@/components/dashboard/monitoring/container/show";
import { MongodbIcon } from "@/components/icons/data-tools-icons";
import { ProjectLayout } from "@/components/layouts/project-layout";
import { StatusTooltip } from "@/components/shared/status-tooltip";
Expand Down Expand Up @@ -216,7 +216,11 @@ const Mongo = (
{!data?.serverId && (
<TabsContent value="monitoring">
<div className="flex flex-col gap-4 pt-2.5">
<DockerMonitoring appName={data?.appName || ""} />
<ContainerMonitoring
appName={data?.appName || ""}
BASE_URL={"http://localhost:3001"}
/>
{/* <DockerMonitoring appName={data?.appName || ""} /> */}
</div>
</TabsContent>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ShowDockerLogs } from "@/components/dashboard/application/logs/show";
import { DockerMonitoring } from "@/components/dashboard/monitoring/docker/show";
import { ContainerMonitoring } from "@/components/dashboard/monitoring/container/show";
import { ShowAdvancedMysql } from "@/components/dashboard/mysql/advanced/show-mysql-advanced-settings";
import { ShowBackupMySql } from "@/components/dashboard/mysql/backups/show-backup-mysql";
import { DeleteMysql } from "@/components/dashboard/mysql/delete-mysql";
Expand Down Expand Up @@ -215,7 +215,11 @@ const MySql = (
{!data?.serverId && (
<TabsContent value="monitoring">
<div className="flex flex-col gap-4 pt-2.5">
<DockerMonitoring appName={data?.appName || ""} />
<ContainerMonitoring
appName={data?.appName || ""}
BASE_URL={"http://localhost:3001"}
/>
{/* <DockerMonitoring appName={data?.appName || ""} /> */}
</div>
</TabsContent>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ShowDockerLogs } from "@/components/dashboard/application/logs/show";
import { DockerMonitoring } from "@/components/dashboard/monitoring/docker/show";
import { ContainerMonitoring } from "@/components/dashboard/monitoring/container/show";
import { ShowAdvancedPostgres } from "@/components/dashboard/postgres/advanced/show-postgres-advanced-settings";
import { ShowBackupPostgres } from "@/components/dashboard/postgres/backups/show-backup-postgres";
import { DeletePostgres } from "@/components/dashboard/postgres/delete-postgres";
Expand Down Expand Up @@ -216,7 +216,10 @@ const Postgresql = (
{!data?.serverId && (
<TabsContent value="monitoring">
<div className="flex flex-col gap-4 pt-2.5">
<DockerMonitoring appName={data?.appName || ""} />
<ContainerMonitoring
appName={data?.appName || ""}
BASE_URL={"http://localhost:3001"}
/>
</div>
</TabsContent>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ShowDockerLogs } from "@/components/dashboard/application/logs/show";
import { DockerMonitoring } from "@/components/dashboard/monitoring/docker/show";
import { ContainerMonitoring } from "@/components/dashboard/monitoring/container/show";
import { ShowAdvancedRedis } from "@/components/dashboard/redis/advanced/show-redis-advanced-settings";
import { DeleteRedis } from "@/components/dashboard/redis/delete-redis";
import { ShowRedisEnvironment } from "@/components/dashboard/redis/environment/show-redis-environment";
Expand Down Expand Up @@ -214,7 +214,11 @@ const Redis = (
{!data?.serverId && (
<TabsContent value="monitoring">
<div className="flex flex-col gap-4 pt-2.5">
<DockerMonitoring appName={data?.appName || ""} />
<ContainerMonitoring
appName={data?.appName || ""}
BASE_URL={"http://localhost:3001"}
/>
{/* <DockerMonitoring appName={data?.appName || ""} /> */}
</div>
</TabsContent>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/monitoring/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { config } from "dotenv";
import { serverLogFile, containerLogFile } from "./constants.js";
import { processMetricsFromFile } from "./utils.js";
import { logContainerMetrics } from "./monitoring/containers.js";
import { existsSync } from "fs";
import { existsSync } from "node:fs";
config();

const TOKEN = process.env.TOKEN || "default-token";
Expand Down
10 changes: 5 additions & 5 deletions apps/monitoring/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function parseLog(logContent: string) {
try {
return JSON.parse(line);
} catch (error) {
console.error(`Error parsing log line: ${error}`);
console.error(`Problematic line: ${line}`);
// console.error(`Error parsing log line: ${error}`);
// console.error(`Problematic line: ${line}`);
return null;
}
})
Expand Down Expand Up @@ -90,7 +90,7 @@ async function readLastNLines(filePath: string, limit: number) {
buffer,
length: chunkSize,
position: size - chunkSize,
offset: 0
offset: 0,
});
const content = Buffer.from(buffer).toString("utf8");
const lines = content.split("\n").filter((line) => line.trim());
Expand All @@ -101,8 +101,8 @@ async function readLastNLines(filePath: string, limit: number) {
try {
return JSON.parse(line);
} catch (error) {
console.error(`Error parsing log line: ${error}`);
console.error(`Problematic line: ${line}`);
// console.error(`Error parsing log line: ${error}`);
// console.error(`Problematic line: ${line}`);
return null;
}
})
Expand Down

0 comments on commit ce552c7

Please sign in to comment.