diff --git a/ee/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql b/ee/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql index 86293a3c2..c8028d677 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql @@ -44,5 +44,7 @@ CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS autocomplete_unique_project_id_md BEGIN; DROP INDEX IF EXISTS autocomplete_unique; +DROP INDEX IF EXISTS events_common.requests_response_body_nn_idx; +DROP INDEX IF EXISTS events_common.requests_request_body_nn_idx; COMMIT; \ No newline at end of file diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 1a8da17ab..dab720b73 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -1203,9 +1203,7 @@ $$ ELSE 0 END)) gin_trgm_ops); CREATE INDEX IF NOT EXISTS requests_timestamp_session_id_failed_idx ON events_common.requests (timestamp, session_id) WHERE success = FALSE; - CREATE INDEX IF NOT EXISTS requests_request_body_nn_idx ON events_common.requests (request_body) WHERE request_body IS NOT NULL; CREATE INDEX IF NOT EXISTS requests_request_body_nn_gin_idx ON events_common.requests USING GIN (request_body gin_trgm_ops) WHERE request_body IS NOT NULL; - CREATE INDEX IF NOT EXISTS requests_response_body_nn_idx ON events_common.requests (response_body) WHERE response_body IS NOT NULL; CREATE INDEX IF NOT EXISTS requests_response_body_nn_gin_idx ON events_common.requests USING GIN (response_body gin_trgm_ops) WHERE response_body IS NOT NULL; CREATE INDEX IF NOT EXISTS requests_status_code_nn_idx ON events_common.requests (status_code) WHERE status_code IS NOT NULL; CREATE INDEX IF NOT EXISTS requests_host_nn_idx ON events_common.requests (host) WHERE host IS NOT NULL; diff --git a/ee/utilities/servers/websocket-cluster.js b/ee/utilities/servers/websocket-cluster.js index dfe2b5848..734dbfb4e 100644 --- a/ee/utilities/servers/websocket-cluster.js +++ b/ee/utilities/servers/websocket-cluster.js @@ -12,7 +12,8 @@ const { IDENTITIES, EVENTS_DEFINITION, extractSessionInfo, - socketConnexionTimeout + socketConnexionTimeout, + errorHandler } = require('../utils/assistHelper'); const { extractProjectKeyFromRequest, @@ -348,6 +349,9 @@ module.exports = { socket.to(socket.peerId).emit(EVENTS_DEFINITION.emit.UPDATE_EVENT, args[0]); }); + socket.on(EVENTS_DEFINITION.listen.CONNECT_ERROR, err => errorHandler(EVENTS_DEFINITION.listen.CONNECT_ERROR, err)); + socket.on(EVENTS_DEFINITION.listen.CONNECT_FAILED, err => errorHandler(EVENTS_DEFINITION.listen.CONNECT_FAILED, err)); + socket.onAny(async (eventName, ...args) => { if (Object.values(EVENTS_DEFINITION.listen).indexOf(eventName) >= 0) { debug && console.log(`received event:${eventName}, should be handled by another listener, stopping onAny.`); diff --git a/ee/utilities/servers/websocket.js b/ee/utilities/servers/websocket.js index b9b817f06..782f70348 100644 --- a/ee/utilities/servers/websocket.js +++ b/ee/utilities/servers/websocket.js @@ -12,7 +12,8 @@ const { IDENTITIES, EVENTS_DEFINITION, extractSessionInfo, - socketConnexionTimeout + socketConnexionTimeout, + errorHandler } = require('../utils/assistHelper'); const { extractProjectKeyFromRequest, @@ -324,6 +325,9 @@ module.exports = { socket.to(socket.peerId).emit(EVENTS_DEFINITION.emit.UPDATE_EVENT, args[0]); }); + socket.on(EVENTS_DEFINITION.listen.CONNECT_ERROR, err => errorHandler(EVENTS_DEFINITION.listen.CONNECT_ERROR, err)); + socket.on(EVENTS_DEFINITION.listen.CONNECT_FAILED, err => errorHandler(EVENTS_DEFINITION.listen.CONNECT_FAILED, err)); + socket.onAny(async (eventName, ...args) => { if (Object.values(EVENTS_DEFINITION.listen).indexOf(eventName) >= 0) { debug && console.log(`received event:${eventName}, should be handled by another listener, stopping onAny.`); diff --git a/scripts/helm/app/alerts.yaml b/scripts/helm/app/alerts.yaml index 59e6bc18b..8998f3a1f 100644 --- a/scripts/helm/app/alerts.yaml +++ b/scripts/helm/app/alerts.yaml @@ -27,6 +27,8 @@ env: pg_dbname: postgres pg_user: postgres pg_password: asayerPostgres + ch_host: clickhouse.db.svc.cluster.local + ch_port: 9000 EMAIL_HOST: '' EMAIL_PORT: '587' EMAIL_USER: '' diff --git a/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql b/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql index 84b650861..537c2082a 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.8.0/1.8.0.sql @@ -44,5 +44,6 @@ CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS autocomplete_unique_project_id_md BEGIN; DROP INDEX IF EXISTS autocomplete_unique; - +DROP INDEX IF EXISTS events_common.requests_response_body_nn_idx; +DROP INDEX IF EXISTS events_common.requests_request_body_nn_idx; COMMIT; \ No newline at end of file diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index f1179e995..77cab0e7b 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -604,9 +604,7 @@ $$ ELSE 0 END)) gin_trgm_ops); CREATE INDEX requests_timestamp_session_id_failed_idx ON events_common.requests (timestamp, session_id) WHERE success = FALSE; - CREATE INDEX requests_request_body_nn_idx ON events_common.requests (request_body) WHERE request_body IS NOT NULL; CREATE INDEX requests_request_body_nn_gin_idx ON events_common.requests USING GIN (request_body gin_trgm_ops) WHERE request_body IS NOT NULL; - CREATE INDEX requests_response_body_nn_idx ON events_common.requests (response_body) WHERE response_body IS NOT NULL; CREATE INDEX requests_response_body_nn_gin_idx ON events_common.requests USING GIN (response_body gin_trgm_ops) WHERE response_body IS NOT NULL; CREATE INDEX requests_status_code_nn_idx ON events_common.requests (status_code) WHERE status_code IS NOT NULL; CREATE INDEX requests_host_nn_idx ON events_common.requests (host) WHERE host IS NOT NULL; diff --git a/scripts/helmcharts/openreplay/charts/alerts/values.yaml b/scripts/helmcharts/openreplay/charts/alerts/values.yaml index 4bcc516c8..6562c3a46 100644 --- a/scripts/helmcharts/openreplay/charts/alerts/values.yaml +++ b/scripts/helmcharts/openreplay/charts/alerts/values.yaml @@ -90,6 +90,8 @@ autoscaling: # targetMemoryUtilizationPercentage: 80 env: + ch_host: clickhouse-openreplay-clickhouse.db.svc.cluster.local + ch_port: 9000 PYTHONUNBUFFERED: '0' diff --git a/utilities/servers/websocket.js b/utilities/servers/websocket.js index 037cb74bc..ac8866fbb 100644 --- a/utilities/servers/websocket.js +++ b/utilities/servers/websocket.js @@ -15,7 +15,8 @@ const { IDENTITIES, EVENTS_DEFINITION, extractSessionInfo, - socketConnexionTimeout + socketConnexionTimeout, + errorHandler } = require('../utils/assistHelper'); const wsRouter = express.Router(); @@ -305,6 +306,9 @@ module.exports = { socket.to(socket.peerId).emit(EVENTS_DEFINITION.emit.UPDATE_EVENT, args[0]); }); + socket.on(EVENTS_DEFINITION.listen.CONNECT_ERROR, err => errorHandler(EVENTS_DEFINITION.listen.CONNECT_ERROR, err)); + socket.on(EVENTS_DEFINITION.listen.CONNECT_FAILED, err => errorHandler(EVENTS_DEFINITION.listen.CONNECT_FAILED, err)); + socket.onAny(async (eventName, ...args) => { if (Object.values(EVENTS_DEFINITION.listen).indexOf(eventName) >= 0) { debug && console.log(`received event:${eventName}, should be handled by another listener, stopping onAny.`); diff --git a/utilities/utils/assistHelper.js b/utilities/utils/assistHelper.js index db7a45c0c..ed4d083ec 100644 --- a/utilities/utils/assistHelper.js +++ b/utilities/utils/assistHelper.js @@ -4,7 +4,7 @@ const {geoip} = require('./geoIP'); let debug = process.env.debug === "1" || false; const IDENTITIES = {agent: 'agent', session: 'session'}; const EVENTS_DEFINITION = { - listen: {UPDATE_EVENT: "UPDATE_SESSION"} + listen: {UPDATE_EVENT: "UPDATE_SESSION", CONNECT_ERROR: "connect_error", CONNECT_FAILED: "connect_failed"} }; EVENTS_DEFINITION.emit = { NEW_AGENT: "NEW_AGENT", @@ -93,6 +93,11 @@ function socketConnexionTimeout(io) { } } +function errorHandler(listenerName, error) { + console.error(`Error detected from ${listenerName}`); + console.error(error); +} + module.exports = { - extractSessionInfo, EVENTS_DEFINITION, IDENTITIES, socketConnexionTimeout + extractSessionInfo, EVENTS_DEFINITION, IDENTITIES, socketConnexionTimeout, errorHandler }; \ No newline at end of file