diff --git a/alloy/config.alloy b/alloy/config.alloy new file mode 100644 index 0000000..02c8c35 --- /dev/null +++ b/alloy/config.alloy @@ -0,0 +1,65 @@ +faro.receiver "integrations_app_agent_receiver" { + extra_log_labels = { + app = "Frontend Observability", + kind = "", + } + + server { + listen_address = "0.0.0.0" + listen_port = "8027" + cors_allowed_origins = ["*"] + max_allowed_payload_size = "10MiB" + + rate_limiting { + rate = 50 + } + } + + sourcemaps { } + + output { + logs = [loki.process.logs_process_client.receiver] + traces = [] + } +} + +loki.process "logs_process_client" { + forward_to = [loki.write.logs_write_client.receiver] + + stage.json { + expressions = { + app = "", + service_name = "", + kind = "", + message = "", + level = "" + } + } + + stage.labels { + values = { + kind = "kind", + service_name = "service_name", + app = "app", + level = "level", + } + } + + stage.static_labels { + set = { + source = "faro", + } + } +} + +loki.write "logs_write_client" { + endpoint { + url = "http://loki:3100/loki/api/v1/push" + } + external_labels = { + } +} + +logging { + level = "info" +} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index cd1dac3..5bbe388 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,39 +1,37 @@ import "@/App.css"; import { - getWebInstrumentations, - initializeFaro, - ReactIntegration, - ConsoleInstrumentation, - WebVitalsInstrumentation, - LogLevel, + getWebInstrumentations, + initializeFaro, + ReactIntegration, + ConsoleInstrumentation, + WebVitalsInstrumentation, } from "@grafana/faro-react"; import Dashboard from "@/components/Dashboard/Dashboard"; function App() { - const isProduction = import.meta.env.PROD; + const isProduction = import.meta.env.PROD; - if (isProduction && window.location.hostname === "localhost") { - console.debug("Initializing Faro environment..."); + if (window.location.hostname === "localhost" && isProduction) { + initializeFaro({ + url: "http://alloy:8027/collect", + app: { + name: "monitor-im-flur", + version: "0.0.1", + environment: "production", + }, + instrumentations: [ + ...getWebInstrumentations({ + captureConsole: true, + }), + new ConsoleInstrumentation(), + new WebVitalsInstrumentation(), + new ReactIntegration(), + ], + }); + } - initializeFaro({ - url: "http://localhost:12347/collect", - app: { - name: "monitor-im-flur", - version: import.meta.env.VITE_APP_VERSION || "0.0.1", - environment: "production", - }, - instrumentations: [ - ...getWebInstrumentations({ - captureConsole: true, - }), - new ConsoleInstrumentation(), - new WebVitalsInstrumentation(), - new ReactIntegration(), - ], - }); - } - return ; + return ; } export default App;