diff --git a/Common/Server/Types/Markdown.ts b/Common/Server/Types/Markdown.ts index 17e05d0a7db..4bb5034ac8d 100644 --- a/Common/Server/Types/Markdown.ts +++ b/Common/Server/Types/Markdown.ts @@ -17,6 +17,10 @@ export default class Markdown { markdown: string, contentType: MarkdownContentType, ): Promise { + // convert tags > and < to > and < + markdown = markdown.replace(//g, ">"); + let renderer: Renderer | null = null; if (contentType === MarkdownContentType.Blog) { diff --git a/Dashboard/src/Components/Dashboard/Canvas/Index.tsx b/Dashboard/src/Components/Dashboard/Canvas/Index.tsx index 156b07d55a0..501ea946878 100644 --- a/Dashboard/src/Components/Dashboard/Canvas/Index.tsx +++ b/Dashboard/src/Components/Dashboard/Canvas/Index.tsx @@ -133,15 +133,19 @@ const DashboardCanvas: FunctionComponent = ( setSelectedComponentId(component.componentId.toString()); }} onComponentUpdate={(updatedComponent: DashboardBaseComponent) => { - const updatedComponents: Array = props.dashboardViewConfig.components.map( - (component: DashboardBaseComponent) => { - if (component.componentId.toString() === updatedComponent.componentId.toString()) { - return updatedComponent; - } - - return component; - }, - ); + const updatedComponents: Array = + props.dashboardViewConfig.components.map( + (component: DashboardBaseComponent) => { + if ( + component.componentId.toString() === + updatedComponent.componentId.toString() + ) { + return updatedComponent; + } + + return component; + }, + ); const updatedDashboardViewConfig: DashboardViewConfig = { ...props.dashboardViewConfig, diff --git a/Dashboard/src/Components/Dashboard/Components/DashboardBaseComponent.tsx b/Dashboard/src/Components/Dashboard/Components/DashboardBaseComponent.tsx index 85f6dcb7146..6f3d17e4011 100644 --- a/Dashboard/src/Components/Dashboard/Components/DashboardBaseComponent.tsx +++ b/Dashboard/src/Components/Dashboard/Components/DashboardBaseComponent.tsx @@ -52,17 +52,9 @@ const DashboardBaseComponentElement: FunctionComponent = ( left: "-9px", }} className="move-element cursor-move absolute w-4 h-4 bg-indigo-400 rounded-full cursor-pointer" - onDragStart={(_event: React.DragEvent) => { - - - }} - onDragEnd={(_event: React.DragEvent) => { - - - }} - > - - + onDragStart={(_event: React.DragEvent) => {}} + onDragEnd={(_event: React.DragEvent) => {}} + > ); }; @@ -111,7 +103,6 @@ const DashboardBaseComponentElement: FunctionComponent = ( style={{ height: `${heightInRem}rem`, }} - > {getMoveElement()} diff --git a/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx b/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx index 9ce7c917716..3dfc7f44a5c 100644 --- a/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx +++ b/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx @@ -6,9 +6,7 @@ export interface ComponentProps extends DashboardBaseComponentProps { component: DashboardChartComponent; } -const DashboardChartComponentElement: FunctionComponent = ( - _props: ComponentProps, -): ReactElement => { +const DashboardChartComponentElement: FunctionComponent = (): ReactElement => { return
Chart Component
; }; diff --git a/Dashboard/src/Components/Dashboard/Components/DashboardTextComponent.tsx b/Dashboard/src/Components/Dashboard/Components/DashboardTextComponent.tsx index 3b1a492bc11..bf9f57fc689 100644 --- a/Dashboard/src/Components/Dashboard/Components/DashboardTextComponent.tsx +++ b/Dashboard/src/Components/Dashboard/Components/DashboardTextComponent.tsx @@ -6,9 +6,7 @@ export interface ComponentProps extends DashboardBaseComponentProps { component: DashboardTextComponent; } -const DashboardTextComponentElement: FunctionComponent = ( - _props: ComponentProps, -): ReactElement => { +const DashboardTextComponentElement: FunctionComponent = (): ReactElement => { return
Text Component
; }; diff --git a/Dashboard/src/Components/Dashboard/Components/DashboardValueComponent.tsx b/Dashboard/src/Components/Dashboard/Components/DashboardValueComponent.tsx index 0cd9bf0dbbb..d7a06161e78 100644 --- a/Dashboard/src/Components/Dashboard/Components/DashboardValueComponent.tsx +++ b/Dashboard/src/Components/Dashboard/Components/DashboardValueComponent.tsx @@ -6,9 +6,7 @@ export interface ComponentProps extends DashboardBaseComponentProps { component: DashboardValueComponent; } -const DashboardValueComponentElement: FunctionComponent = ( - _props: ComponentProps, -): ReactElement => { +const DashboardValueComponentElement: FunctionComponent = (): ReactElement => { return
Value Component
; }; diff --git a/Fluentd/Dockerfile.tpl b/Fluentd/Dockerfile.tpl index 3528c665e1d..217fcb5b24e 100644 --- a/Fluentd/Dockerfile.tpl +++ b/Fluentd/Dockerfile.tpl @@ -4,4 +4,7 @@ FROM fluentd USER root # Install bash and curl. -RUN apk add bash curl \ No newline at end of file +RUN apk add bash curl + +EXPOSE 24224 +EXPOSE 8888 \ No newline at end of file diff --git a/Fluentd/README.md b/Fluentd/README.md index 2eea07f9d46..cd984ee0ef0 100644 --- a/Fluentd/README.md +++ b/Fluentd/README.md @@ -10,5 +10,18 @@ This guide will help you test fluentd logs with OneUptime. - Telemetry Ingestion Key (Create one from the OneUptime dashboard, Click on More -> Project Settings -> Telemetry Ingestion Key) -## Configuration +## Configuration and Testing + +- Please make sure the correct token and url is in the configuration file located at `Fluentd/fluent.conf`. +- Build the docker image using the command `npm run force-build fluentd` +- Run the docker image using the command `npm run dev fluentd` +- Send logs to the Fluentd container using the curl command + +```bash +curl -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/test.tag.here; +``` + +You should be able to see the logs in the OneUptime dashboard. + + diff --git a/Fluentd/fluent.conf b/Fluentd/fluent.conf index e443476ced8..6c3219410e7 100644 --- a/Fluentd/fluent.conf +++ b/Fluentd/fluent.conf @@ -10,15 +10,23 @@ bind 0.0.0.0 + + @type http + port 8888 + bind 0.0.0.0 + body_size_limit 32m + keepalive_timeout 10s + + # Match all patterns @type http # endpoint http://ingestor:3400/ingestor/fluentd/v1/logs # This is if you're testing in local development - endpoint http://ingestor:3400/ingestor/fluentd/v1/logs # This is for test environment + endpoint https://oneuptime.com/fluentd/logs # This is for prod environment open_timeout 2 - - headers {"x-oneuptime-token":"6e16cfd0-5071-11ef-a5d5-e16a17b3db89", "x-oneuptime-service-name": "fluentd"} + # Please make sure you change the token and service name to your own + headers {"x-oneuptime-token":"caf42a30-8ace-11ef-b10a-eb9302809cb8", "x-oneuptime-service-name": "fluentd-logs"} content_type application/json json_array true diff --git a/Ingestor/API/FluentIngest.ts b/Ingestor/API/FluentIngest.ts index 58fd8bb6b82..bb52349cbdd 100644 --- a/Ingestor/API/FluentIngest.ts +++ b/Ingestor/API/FluentIngest.ts @@ -50,9 +50,9 @@ router.post( const dbLogs: Array = []; - const logItems: Array = req.body as Array< - JSONObject | string - >; + let logItems: Array | JSONObject = req.body as + | Array + | JSONObject; let oneuptimeServiceName: string | string[] | undefined = req.headers["x-oneuptime-service-name"]; @@ -69,6 +69,20 @@ router.post( projectId: (req as TelemetryRequest).projectId, }); + if ( + logItems && + typeof logItems === "object" && + (logItems as JSONObject)["json"] + ) { + logItems = (logItems as JSONObject)["json"] as + | Array + | JSONObject; + } + + if (!Array.isArray(logItems)) { + logItems = [logItems]; + } + for (let logItem of logItems) { const dbLog: Log = new Log(); @@ -81,6 +95,15 @@ router.post( dbLog.severityText = LogSeverity.Unspecified; + if (typeof logItem === "string") { + // check if its parseable to json + try { + logItem = JSON.parse(logItem); + } catch (err) { + // do nothing + } + } + if (typeof logItem !== "string") { logItem = JSON.stringify(logItem); } diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 3324966c33c..f3f80e2afef 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -362,6 +362,7 @@ services: ports: - 24224:24224 - 24224:24224/udp + - 8888:8888 user: fluent extends: file: ./docker-compose.base.yml