feat: Add lazy loading for images in SettingsRoutes

This commit is contained in:
Simon Larsen
2024-08-02 13:44:59 -06:00
parent 9dc31fe536
commit 9b8a5c9c43
8 changed files with 103 additions and 4 deletions

View File

@@ -33,6 +33,7 @@ import UpdateActiveMonitorCountToBillingProvider from "./UpdateActiveMonitorCoun
import UpdateGlobalConfigFromEnv from "./UpdateGlobalCongfigFromEnv";
import MigrateServiceLanguageToTechStack from "./MigrateServiceLanguageToTechStack";
import DeleteOldTelemetryTable from "./DeleteOldTelelmetryTable";
import MoveTelemetryServiceTokenToTelemetryIngestionKey from "./MoveTelemetryServiceTokenToTelemetryIngestionKey";
// This is the order in which the migrations will be run. Add new migrations to the end of the array.
@@ -71,6 +72,7 @@ const DataMigrations: Array<DataMigrationBase> = [
new AddIsMonotonicToMetric(),
new MigrateServiceLanguageToTechStack(),
new DeleteOldTelemetryTable(),
new MoveTelemetryServiceTokenToTelemetryIngestionKey(),
];
export default DataMigrations;

View File

@@ -0,0 +1,52 @@
import DataMigrationBase from "./DataMigrationBase";
import TelemetryServiceService from "CommonServer/Services/TelemetryServiceService";
import LIMIT_MAX from "Common/Types/Database/LimitMax";
import TelemetryService from "Model/Models/TelemetryService";
import TelemetryIngestionKey from "Model/Models/TelemetryIngestionKey";
import TelemetryIngestionKeyService from "CommonServer/Services/TelemetryIngestionKeyService";
export default class MoveTelemetryServiceTokenToTelemetryIngestionKey extends DataMigrationBase {
public constructor() {
super("MoveTelemetryServiceTokenToTelemetryIngestionKey");
}
public override async migrate(): Promise<void> {
// get all telemetry services
const telemetryService: TelemetryService[] =
await TelemetryServiceService.findBy({
query: {},
props: {
isRoot: true,
},
select: {
projectId: true,
telemetryServiceToken: true,
name: true,
description: true,
},
limit: LIMIT_MAX,
skip: 0,
});
for (const service of telemetryService) {
const telemetryIngestionKey: TelemetryIngestionKey =
new TelemetryIngestionKey();
telemetryIngestionKey.projectId = service.projectId!;
telemetryIngestionKey.secretKey = service.telemetryServiceToken!;
telemetryIngestionKey.name = service.name!;
telemetryIngestionKey.description = service.description!;
await TelemetryIngestionKeyService.create({
data: telemetryIngestionKey,
props: {
isRoot: true,
},
});
}
}
public override async rollback(): Promise<void> {
return;
}
}

View File

@@ -13,7 +13,10 @@ export class Service extends DatabaseService<Model> {
protected override async onBeforeCreate(
createBy: CreateBy<Model>,
): Promise<OnCreate<Model>> {
createBy.data.secretKey = ObjectID.generate();
if (!createBy.data.secretKey) {
createBy.data.secretKey = ObjectID.generate();
}
return { createBy, carryForward: null };
}
}

14
Fluentd/README.md Normal file
View File

@@ -0,0 +1,14 @@
# Fluentd
This guide will help you test fluentd logs with OneUptime.
## Prerequisites
- Fluentd installed on your system
- OneUptime account
- OneUptime project
- Telemetry Ingestion Key (Create one from the OneUptime dashboard, Click on More -> Project Settings -> Telemetry Ingestion Key)
## Configuration

View File

@@ -15,10 +15,10 @@
@type http
# endpoint http://ingestor:3400/ingestor/fluentd/v1/logs # This is if you're testing in local development
endpoint https://test.oneuptime.com/fluentd/logs # This is for test environment
endpoint http://ingestor:3400/ingestor/fluentd/v1/logs # This is for test environment
open_timeout 2
headers {"x-oneuptime-token":"e83375b0-c1fc-11ee-a9f7-070615743da6"}
headers {"x-oneuptime-token":"6e16cfd0-5071-11ef-a5d5-e16a17b3db89", "x-oneuptime-service-name": "fluentd"}
content_type application/json
json_array true

View File

@@ -148,6 +148,11 @@ internalSmtp:
incidents:
disableAutomaticCreation: false
# If you would like to attach status page to custom domains use this setting.
# For example, lets say you would like the status page to be hosted on status.yourcompany.com, then
# 1. Create a A record in your DNS provider with the name "oneuptime.yourcompany.com" and value to Public IP of the server oneuptime is deployed on.
# 2. Set the statusPage.cnameRecord to "oneuptime.yourcompany.com"
# 3. Create CNAME record in your DNS provider with the name "status.yourcompany.com" and value "oneuptime.yourcompany.com"
statusPage:
cnameRecord:

View File

@@ -16,6 +16,7 @@ import Response from "CommonServer/Utils/Response";
import Log, { LogSeverity } from "Model/AnalyticsModels/Log";
import OTelIngestService from "../Service/OTelIngest";
import ObjectID from "Common/Types/ObjectID";
import JSONFunctions from "Common/Types/JSONFunctions";
export class FluentRequestMiddleware {
public static async getProductType(
@@ -95,6 +96,21 @@ router.post(
},
});
OTelIngestService.recordDataIngestedUsgaeBilling({
services: {
[oneuptimeServiceName as string]: {
dataIngestedInGB: JSONFunctions.getSizeOfJSONinGB(req.body),
dataRententionInDays: telemetryService.dataRententionInDays,
serviceId: telemetryService.serviceId,
serviceName: oneuptimeServiceName as string,
},
},
projectId: (req as TelemetryRequest).projectId,
productType: ProductType.Logs,
}).catch((err: Error) => {
logger.error(err);
});
return Response.sendEmptySuccessResponse(req, res);
} catch (err) {
return next(err);

View File

@@ -24,10 +24,17 @@ export default class TelemetryIngest {
try {
// check header.
const oneuptimeToken: string | undefined = req.headers[
let oneuptimeToken: string | undefined = req.headers[
"x-oneuptime-token"
] as string | undefined;
// if x-oneuptime-service-token header is present then use that as token.
if (!oneuptimeToken) {
oneuptimeToken = req.headers["x-oneuptime-service-token"] as
| string
| undefined;
}
if (!oneuptimeToken) {
throw new BadRequestException("Missing header: x-oneuptime-token");
}