diff --git a/.env.example b/.env.example index f078b6dc..4057c56e 100644 --- a/.env.example +++ b/.env.example @@ -54,3 +54,8 @@ LOG_TO_CLOUDWATCH=false # Datadog logging LOG_TO_DATADOG=false DATADOG_API_KEY=myApiKey + +# Loki logging +LOG_TO_LOKI=false +LOKI_BASIC_AUTH=username:password +LOKI_HOST=http://localhost diff --git a/.github/workflows/canary-ap-northeast-2.yml b/.github/workflows/canary-ap-northeast-2.yml index 09b88a7c..599598ed 100644 --- a/.github/workflows/canary-ap-northeast-2.yml +++ b/.github/workflows/canary-ap-northeast-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-canary-redis.jmonrz.clustercfg.apn2.cache.amazonaws.com envkey_REGION: 'ap-northeast-2' envkey_REGION_NAME: '/canary/ap-northeast-2' diff --git a/.github/workflows/canary-ca-central-1.yml b/.github/workflows/canary-ca-central-1.yml index 57feb353..08da723b 100644 --- a/.github/workflows/canary-ca-central-1.yml +++ b/.github/workflows/canary-ca-central-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-canary-redis.gvqq2p.clustercfg.cac1.cache.amazonaws.com envkey_REGION: 'ca-central-1' envkey_REGION_NAME: '/canary/ca-central-1' diff --git a/.github/workflows/canary-eu-central-1.yml b/.github/workflows/canary-eu-central-1.yml index 47085b12..a469ff44 100644 --- a/.github/workflows/canary-eu-central-1.yml +++ b/.github/workflows/canary-eu-central-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-canary-redis.6iq570.clustercfg.euc1.cache.amazonaws.com envkey_REGION: 'eu-central-1' envkey_REGION_NAME: '/canary/eu-central-1' diff --git a/.github/workflows/canary-us-west-2.yml b/.github/workflows/canary-us-west-2.yml index d7bf248e..6af92e9e 100644 --- a/.github/workflows/canary-us-west-2.yml +++ b/.github/workflows/canary-us-west-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-canary-redis.js6zbp.clustercfg.usw2.cache.amazonaws.com envkey_REGION: 'us-west-2' envkey_REGION_NAME: '/canary/us-west-2' diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml index 927bc2e8..15d6c7dd 100644 --- a/.github/workflows/dockerhub.yml +++ b/.github/workflows/dockerhub.yml @@ -4,10 +4,12 @@ on: push: branches: - 'develop' - - 'v*.*.*' + tags: + - 'v*' pull_request: branches: - - 'main' + - 'develop' + - 'master' jobs: docker: diff --git a/.github/workflows/production-ap-east-1.yml b/.github/workflows/production-ap-east-1.yml index 48af533d..43c86ad6 100644 --- a/.github/workflows/production-ap-east-1.yml +++ b/.github/workflows/production-ap-east-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.hmerc8.clustercfg.ape1.cache.amazonaws.com envkey_REGION: 'ap-east-1' envkey_REGION_NAME: 'ap-east-1' diff --git a/.github/workflows/production-ap-northeast-1.yml b/.github/workflows/production-ap-northeast-1.yml index 5e305b56..bbc057fc 100644 --- a/.github/workflows/production-ap-northeast-1.yml +++ b/.github/workflows/production-ap-northeast-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.3vxfd0.clustercfg.apne1.cache.amazonaws.com envkey_REGION: 'ap-northeast-1' envkey_REGION_NAME: 'ap-northeast-1' diff --git a/.github/workflows/production-ap-northeast-2.yml b/.github/workflows/production-ap-northeast-2.yml index 5d7e8309..4284b945 100644 --- a/.github/workflows/production-ap-northeast-2.yml +++ b/.github/workflows/production-ap-northeast-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.jmonrz.clustercfg.apn2.cache.amazonaws.com envkey_REGION: 'ap-northeast-2' envkey_REGION_NAME: 'ap-northeast-2' diff --git a/.github/workflows/production-ap-south-1.yml b/.github/workflows/production-ap-south-1.yml index a0a25660..d9c6bbdf 100644 --- a/.github/workflows/production-ap-south-1.yml +++ b/.github/workflows/production-ap-south-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.qbodc0.clustercfg.aps1.cache.amazonaws.com envkey_REGION: 'ap-south-1' envkey_REGION_NAME: 'ap-south-1' diff --git a/.github/workflows/production-ap-southeast-1.yml b/.github/workflows/production-ap-southeast-1.yml index c2924502..7d9f1c93 100644 --- a/.github/workflows/production-ap-southeast-1.yml +++ b/.github/workflows/production-ap-southeast-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.y2p8qe.clustercfg.apse1.cache.amazonaws.com envkey_REGION: 'ap-southeast-1' envkey_REGION_NAME: 'ap-southeast-1' diff --git a/.github/workflows/production-ap-southeast-2.yml b/.github/workflows/production-ap-southeast-2.yml index 1ae6a1c8..2e7a7580 100644 --- a/.github/workflows/production-ap-southeast-2.yml +++ b/.github/workflows/production-ap-southeast-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.m1bwfz.clustercfg.apse2.cache.amazonaws.com envkey_REGION: 'ap-southeast-2' envkey_REGION_NAME: 'ap-southeast-2' diff --git a/.github/workflows/production-ca-central-1.yml b/.github/workflows/production-ca-central-1.yml index 322cbb99..e62b39ca 100644 --- a/.github/workflows/production-ca-central-1.yml +++ b/.github/workflows/production-ca-central-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.gvqq2p.clustercfg.cac1.cache.amazonaws.com envkey_REGION: 'ca-central-1' envkey_REGION_NAME: 'ca-central-1' diff --git a/.github/workflows/production-eu-central-1.yml b/.github/workflows/production-eu-central-1.yml index 0847adac..b1b4764a 100644 --- a/.github/workflows/production-eu-central-1.yml +++ b/.github/workflows/production-eu-central-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.6iq570.clustercfg.euc1.cache.amazonaws.com envkey_REGION: 'eu-central-1' envkey_REGION_NAME: 'eu-central-1' @@ -118,4 +122,4 @@ jobs: task-definition: ${{ steps.task-def-eu-central-1-datadog-agent.outputs.task-definition }} service: gateway-prod cluster: gateway-prod - wait-for-service-stability: true + wait-for-service-stability: true \ No newline at end of file diff --git a/.github/workflows/production-eu-north-1.yml b/.github/workflows/production-eu-north-1.yml index eb11652f..560843ad 100644 --- a/.github/workflows/production-eu-north-1.yml +++ b/.github/workflows/production-eu-north-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.0jyaag.clustercfg.eun1.cache.amazonaws.com envkey_REGION: 'eu-north-1' envkey_REGION_NAME: 'eu-north-1' diff --git a/.github/workflows/production-eu-south-1.yml b/.github/workflows/production-eu-south-1.yml index 11ad830d..bac31591 100644 --- a/.github/workflows/production-eu-south-1.yml +++ b/.github/workflows/production-eu-south-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.thcgg8.clustercfg.eus1.cache.amazonaws.com envkey_REGION: 'eu-south-1' envkey_REGION_NAME: 'eu-south-1' diff --git a/.github/workflows/production-eu-west-1.yml b/.github/workflows/production-eu-west-1.yml index 8810de08..11946beb 100644 --- a/.github/workflows/production-eu-west-1.yml +++ b/.github/workflows/production-eu-west-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.dj2dgc.clustercfg.euw1.cache.amazonaws.com envkey_REGION: 'eu-west-1' envkey_REGION_NAME: 'eu-west-1' diff --git a/.github/workflows/production-eu-west-2.yml b/.github/workflows/production-eu-west-2.yml index 7dfa73a9..e3947071 100644 --- a/.github/workflows/production-eu-west-2.yml +++ b/.github/workflows/production-eu-west-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.f8igmv.clustercfg.euw2.cache.amazonaws.com envkey_REGION: 'eu-west-2' envkey_REGION_NAME: 'eu-west-2' diff --git a/.github/workflows/production-eu-west-3.yml b/.github/workflows/production-eu-west-3.yml index 4e089643..13f683c3 100644 --- a/.github/workflows/production-eu-west-3.yml +++ b/.github/workflows/production-eu-west-3.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.65u27l.clustercfg.euw3.cache.amazonaws.com envkey_REGION: 'eu-west-3' envkey_REGION_NAME: 'eu-west-3' diff --git a/.github/workflows/production-us-east-1.yml b/.github/workflows/production-us-east-1.yml index 6b77b273..983240f8 100644 --- a/.github/workflows/production-us-east-1.yml +++ b/.github/workflows/production-us-east-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.ydxbbz.clustercfg.use1.cache.amazonaws.com envkey_REGION: 'us-east-1' envkey_REGION_NAME: 'us-east-1' diff --git a/.github/workflows/production-us-east-2.yml b/.github/workflows/production-us-east-2.yml index 1edb131d..ee924a0f 100644 --- a/.github/workflows/production-us-east-2.yml +++ b/.github/workflows/production-us-east-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.pzdhdc.clustercfg.use2.cache.amazonaws.com envkey_REGION: 'us-east-2' envkey_REGION_NAME: 'us-east-2' diff --git a/.github/workflows/production-us-west-1.yml b/.github/workflows/production-us-west-1.yml index a7401cb1..7080aacb 100644 --- a/.github/workflows/production-us-west-1.yml +++ b/.github/workflows/production-us-west-1.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.c8rv3u.clustercfg.usw1.cache.amazonaws.com envkey_REGION: 'us-west-1' envkey_REGION_NAME: 'us-west-1' diff --git a/.github/workflows/production-us-west-2.yml b/.github/workflows/production-us-west-2.yml index ab88a8b9..be7e7542 100644 --- a/.github/workflows/production-us-west-2.yml +++ b/.github/workflows/production-us-west-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-prod-redis.js6zbp.clustercfg.usw2.cache.amazonaws.com envkey_REGION: 'us-west-2' envkey_REGION_NAME: 'us-west-2' diff --git a/.github/workflows/staging-us-west-2.yml b/.github/workflows/staging-us-west-2.yml index 587f71b4..80c3db26 100644 --- a/.github/workflows/staging-us-west-2.yml +++ b/.github/workflows/staging-us-west-2.yml @@ -57,6 +57,9 @@ jobs: envkey_ARCHIVAL_CHAINS: 0022,0028,0010,000A,000B,000C envkey_LOG_TO_DATADOG: true envkey_DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + envkey_LOG_TO_LOKI: ${{ secrets.LOG_TO_LOKI }} + envkey_LOKI_BASIC_AUTH: ${{ secrets.LOKI_BASIC_AUTH }} + envkey_LOKI_HOST: ${{ secrets.LOKI_HOST }} envkey_ALWAYS_REDIRECT_TO_ALTRUISTS: ${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }} envkey_SILENT_LOGGING: true envkey_LOG_CHERRY_PICKER_STATS: ${{ secrets.LOG_CHERRY_PICKER_STATS }} @@ -66,6 +69,7 @@ jobs: envkey_INFLUX_TOKENS: ${{ secrets.INFLUX_TOKENS }} envkey_INFLUX_ORGS: ${{ secrets.INFLUX_ORGS }} envkey_ALTRUIST_ONLY_CHAINS: ${{ secrets.ALTRUIST_ONLY_CHAINS }} + envkey_GATEWAY_HOST: ${{ secrets.GATEWAY_HOST }} envkey_REMOTE_REDIS_ENDPOINT: gateway-staging-redis.js6zbp.clustercfg.usw2.cache.amazonaws.com envkey_REGION: 'us-west-2' envkey_REGION_NAME: 'staging' diff --git a/.github/workflows/tag_and_release.yml b/.github/workflows/tag_and_release.yml new file mode 100644 index 00000000..ad646eb6 --- /dev/null +++ b/.github/workflows/tag_and_release.yml @@ -0,0 +1,18 @@ +name: Tag and release +on: + push: + branches: + - develop + - master + +jobs: + release-on-push: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.POKT_BOT_GITHUB_TOKEN }} + steps: + - uses: rymndhng/release-on-push-action@master + with: + bump_version_scheme: patch + release_body: ':rocket: Release Notes !:fireworks:' + use_github_release_notes: true diff --git a/DEVELOPING.md b/DEVELOPING.md index 7656d44e..9a02cb3f 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -34,3 +34,17 @@ Install the following extensions: suite and lint the code for both programming and style errors. You should run this command manually whenever you have new changes to test. Test failures and linter errors will be printed to the terminal. + +### PR workflow + +1. Create a branch for your feature +2. Make your changes +3. Push your branch to GitHub +4. Open a pull request +5. Make sure the tests pass +6. Merge your pull request +7. Delete your branch + +the `release-on-push` action will run on all changes to master, and create a new tag and release on GitHub. A dockerimage build will be triggered by the new tag, and published to the container registry. + +> NOTES on PR workflow: if the PR has the label `release:major`, `release:minor`, or `release:patch`, this will override `bump_version_scheme`. diff --git a/package-lock.json b/package-lock.json index 175312f8..0e5dcbcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,8 @@ "strong-cryptor": "^2.2.0", "winston": "^3.3.3", "winston-cloudwatch": "^6.0.1", - "winston-logzio": "^5.1.2" + "winston-logzio": "^5.1.2", + "winston-loki": "^6.0.6" }, "devDependencies": { "@loopback/build": "^9.0.1", @@ -74,7 +75,7 @@ "typescript": "~4.7.4" }, "engines": { - "node": ">=12.16.0 <=16.14" + "node": ">=12.16.0 <=16.17" } }, "node_modules/@ampproject/remapping": { @@ -5976,6 +5977,201 @@ "node": "14 || 16 || 17 || 18" } }, + "node_modules/@napi-rs/snappy-android-arm-eabi": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-android-arm-eabi/-/snappy-android-arm-eabi-7.1.1.tgz", + "integrity": "sha512-NKd/ztuVEgQaAaNVQ5zZaCB9VV+7+uBXBHqhaE5iSapQhLc41szTlT0s68FCee75OoT3vhqdA6Jp5TrzZ2WOaw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-android-arm64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-android-arm64/-/snappy-android-arm64-7.1.1.tgz", + "integrity": "sha512-DktruMAO0K0toTnxNHg2GWNIAPJqdvIchCsdsRaKyuEnG101qBg0mYiRCAhxHgbT6RJlOGbUPKkbA9KKRhEJUg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-darwin-arm64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-darwin-arm64/-/snappy-darwin-arm64-7.1.1.tgz", + "integrity": "sha512-3LZyoAw3Qa5F7sCCTkSkhmGlydwUKU6L3Jl46eKHO2Ctm8Gcjxww6T7MfwlwGZ6JqAM6d1d++WLzUZPCGXVmag==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-darwin-x64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-darwin-x64/-/snappy-darwin-x64-7.1.1.tgz", + "integrity": "sha512-X1D2F67bQkPwr5iSR29/RnOrLwAkB55YO6t41toABzla3mflLDpzZcakz6FokIukykf7ey31/t73v/4pbgaBkg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-freebsd-x64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-freebsd-x64/-/snappy-freebsd-x64-7.1.1.tgz", + "integrity": "sha512-vSeuf+An8jFVHPAn5IbWE9hTGU9PFAaZLj/X7rKTQQtZstnDsHgWe6u4g7FHLuOdwQ8TvhcxAEpNlYIXIk4AJg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-linux-arm-gnueabihf": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-arm-gnueabihf/-/snappy-linux-arm-gnueabihf-7.1.1.tgz", + "integrity": "sha512-/yyN6QsnOs3D1+jI3SfRX+gtnD86rbixdfmgxv9g40+FrDaDTLAu/3VuZIqH02qqq/xiWbDnkO+42RGxXDzTCw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-linux-arm64-gnu": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-arm64-gnu/-/snappy-linux-arm64-gnu-7.1.1.tgz", + "integrity": "sha512-StEeUCSwUoajgrBtiCQPTkHu+0Q4QlYndghGZNdbN1zJ1ny70YzPpevaFBUyjI/eJ+FN9uICKtwTPtQNSILS5g==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-linux-arm64-musl": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-arm64-musl/-/snappy-linux-arm64-musl-7.1.1.tgz", + "integrity": "sha512-jWEBRzj+lswZVYf0b5eY0fjMlBL9L9yqjmTuv2UIMjJNHPuR282LK/s3Fm9sYIXQtKkiCo5JyhmIcoghZ3v0Eg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-linux-x64-gnu": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-x64-gnu/-/snappy-linux-x64-gnu-7.1.1.tgz", + "integrity": "sha512-41DPoAUFAU9VNrj/96qKfStH2Xq88ZYIsSz8BlITDm2ScoeDGOGbmaWguCXU7I+bC2uKWTmUVMXKqk6tVY6LEg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-linux-x64-musl": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-x64-musl/-/snappy-linux-x64-musl-7.1.1.tgz", + "integrity": "sha512-xR4hzFQqVq6J8Zf6XyUVtFJBaRgDyAQYUoBsCr92tZ7gI/0RlWCV6Q6JMO/wP5CSsvyFJIAtSUXXqlzIpw0GPA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-win32-arm64-msvc": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-win32-arm64-msvc/-/snappy-win32-arm64-msvc-7.1.1.tgz", + "integrity": "sha512-2mHPadctsaYtrfSV5Na8ooTdI5rflPxP1pceY4us6vbjeWrfgB+KQCuEFOHsGXqFNfsi6L9nWH8nB9swnxnSyw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-win32-ia32-msvc": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-win32-ia32-msvc/-/snappy-win32-ia32-msvc-7.1.1.tgz", + "integrity": "sha512-FOMgs9W71hdgjyl3T9F7b/WEIuoryfgBqsyhtHjAaa/98R0BUHl0bOoHg8ka0b5GgnhLBHkX2Yd6VD+Si9Q2ww==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/snappy-win32-x64-msvc": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-win32-x64-msvc/-/snappy-win32-x64-msvc-7.1.1.tgz", + "integrity": "sha512-Mu3yELySvzhBcNTVCq+hYxVh+lH3/KjoQ5HIEb3DDPoX0AGRTm3XZa+usq8pFWjl91Cgp9nWK+9lVSkCCIRaKA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@noble/ed25519": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.6.0.tgz", @@ -8230,6 +8426,14 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" }, + "node_modules/async-exit-hook": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/async-exit-hook/-/async-exit-hook-2.0.1.tgz", + "integrity": "sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", @@ -8930,6 +9134,17 @@ "node": ">=0.6.19" } }, + "node_modules/btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==", + "bin": { + "btoa": "bin/btoa.js" + }, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/buffer": { "version": "4.9.2", "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", @@ -21946,6 +22161,34 @@ "node": ">=0.10.0" } }, + "node_modules/snappy": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/snappy/-/snappy-7.1.1.tgz", + "integrity": "sha512-mL7GGPJ+WdsaFT5aR/uEqCq8cPg2VbhyifDEP7AeqIVDsAC8LBGYbZP1Qzoa2Ym84OW7JEQXqIpwqFp1EQw5BA==", + "optional": true, + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "optionalDependencies": { + "@napi-rs/snappy-android-arm-eabi": "7.1.1", + "@napi-rs/snappy-android-arm64": "7.1.1", + "@napi-rs/snappy-darwin-arm64": "7.1.1", + "@napi-rs/snappy-darwin-x64": "7.1.1", + "@napi-rs/snappy-freebsd-x64": "7.1.1", + "@napi-rs/snappy-linux-arm-gnueabihf": "7.1.1", + "@napi-rs/snappy-linux-arm64-gnu": "7.1.1", + "@napi-rs/snappy-linux-arm64-musl": "7.1.1", + "@napi-rs/snappy-linux-x64-gnu": "7.1.1", + "@napi-rs/snappy-linux-x64-musl": "7.1.1", + "@napi-rs/snappy-win32-arm64-msvc": "7.1.1", + "@napi-rs/snappy-win32-ia32-msvc": "7.1.1", + "@napi-rs/snappy-win32-x64-msvc": "7.1.1" + } + }, "node_modules/snyk": { "version": "1.956.0", "resolved": "https://registry.npmjs.org/snyk/-/snyk-1.956.0.tgz", @@ -23893,6 +24136,20 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.21.tgz", "integrity": "sha512-x5W9s+8P4XteaxT/jKF0PSb7XEvo5VmqEWgsMlyeY4ZlLK8I6aH6g5TPPyDlLAep+GYf4kefb7HFyc7PAO3m+Q==" }, + "node_modules/winston-loki": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/winston-loki/-/winston-loki-6.0.6.tgz", + "integrity": "sha512-cll+nv5T/b9uJXqca0N2WKL1JJNuJND9E6WOOAuSGkZ44L9VQ/QK9F+/5VKbv6LIP9p0nvPSOYxtACCDb/9iWw==", + "dependencies": { + "async-exit-hook": "2.0.1", + "btoa": "^1.2.1", + "protobufjs": "^6.8.8", + "winston-transport": "^4.3.0" + }, + "optionalDependencies": { + "snappy": "7.1.1" + } + }, "node_modules/winston-transport": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.5.0.tgz", @@ -28717,6 +28974,84 @@ "tslib": "^2.4.0" } }, + "@napi-rs/snappy-android-arm-eabi": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-android-arm-eabi/-/snappy-android-arm-eabi-7.1.1.tgz", + "integrity": "sha512-NKd/ztuVEgQaAaNVQ5zZaCB9VV+7+uBXBHqhaE5iSapQhLc41szTlT0s68FCee75OoT3vhqdA6Jp5TrzZ2WOaw==", + "optional": true + }, + "@napi-rs/snappy-android-arm64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-android-arm64/-/snappy-android-arm64-7.1.1.tgz", + "integrity": "sha512-DktruMAO0K0toTnxNHg2GWNIAPJqdvIchCsdsRaKyuEnG101qBg0mYiRCAhxHgbT6RJlOGbUPKkbA9KKRhEJUg==", + "optional": true + }, + "@napi-rs/snappy-darwin-arm64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-darwin-arm64/-/snappy-darwin-arm64-7.1.1.tgz", + "integrity": "sha512-3LZyoAw3Qa5F7sCCTkSkhmGlydwUKU6L3Jl46eKHO2Ctm8Gcjxww6T7MfwlwGZ6JqAM6d1d++WLzUZPCGXVmag==", + "optional": true + }, + "@napi-rs/snappy-darwin-x64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-darwin-x64/-/snappy-darwin-x64-7.1.1.tgz", + "integrity": "sha512-X1D2F67bQkPwr5iSR29/RnOrLwAkB55YO6t41toABzla3mflLDpzZcakz6FokIukykf7ey31/t73v/4pbgaBkg==", + "optional": true + }, + "@napi-rs/snappy-freebsd-x64": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-freebsd-x64/-/snappy-freebsd-x64-7.1.1.tgz", + "integrity": "sha512-vSeuf+An8jFVHPAn5IbWE9hTGU9PFAaZLj/X7rKTQQtZstnDsHgWe6u4g7FHLuOdwQ8TvhcxAEpNlYIXIk4AJg==", + "optional": true + }, + "@napi-rs/snappy-linux-arm-gnueabihf": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-arm-gnueabihf/-/snappy-linux-arm-gnueabihf-7.1.1.tgz", + "integrity": "sha512-/yyN6QsnOs3D1+jI3SfRX+gtnD86rbixdfmgxv9g40+FrDaDTLAu/3VuZIqH02qqq/xiWbDnkO+42RGxXDzTCw==", + "optional": true + }, + "@napi-rs/snappy-linux-arm64-gnu": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-arm64-gnu/-/snappy-linux-arm64-gnu-7.1.1.tgz", + "integrity": "sha512-StEeUCSwUoajgrBtiCQPTkHu+0Q4QlYndghGZNdbN1zJ1ny70YzPpevaFBUyjI/eJ+FN9uICKtwTPtQNSILS5g==", + "optional": true + }, + "@napi-rs/snappy-linux-arm64-musl": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-arm64-musl/-/snappy-linux-arm64-musl-7.1.1.tgz", + "integrity": "sha512-jWEBRzj+lswZVYf0b5eY0fjMlBL9L9yqjmTuv2UIMjJNHPuR282LK/s3Fm9sYIXQtKkiCo5JyhmIcoghZ3v0Eg==", + "optional": true + }, + "@napi-rs/snappy-linux-x64-gnu": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-x64-gnu/-/snappy-linux-x64-gnu-7.1.1.tgz", + "integrity": "sha512-41DPoAUFAU9VNrj/96qKfStH2Xq88ZYIsSz8BlITDm2ScoeDGOGbmaWguCXU7I+bC2uKWTmUVMXKqk6tVY6LEg==", + "optional": true + }, + "@napi-rs/snappy-linux-x64-musl": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-linux-x64-musl/-/snappy-linux-x64-musl-7.1.1.tgz", + "integrity": "sha512-xR4hzFQqVq6J8Zf6XyUVtFJBaRgDyAQYUoBsCr92tZ7gI/0RlWCV6Q6JMO/wP5CSsvyFJIAtSUXXqlzIpw0GPA==", + "optional": true + }, + "@napi-rs/snappy-win32-arm64-msvc": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-win32-arm64-msvc/-/snappy-win32-arm64-msvc-7.1.1.tgz", + "integrity": "sha512-2mHPadctsaYtrfSV5Na8ooTdI5rflPxP1pceY4us6vbjeWrfgB+KQCuEFOHsGXqFNfsi6L9nWH8nB9swnxnSyw==", + "optional": true + }, + "@napi-rs/snappy-win32-ia32-msvc": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-win32-ia32-msvc/-/snappy-win32-ia32-msvc-7.1.1.tgz", + "integrity": "sha512-FOMgs9W71hdgjyl3T9F7b/WEIuoryfgBqsyhtHjAaa/98R0BUHl0bOoHg8ka0b5GgnhLBHkX2Yd6VD+Si9Q2ww==", + "optional": true + }, + "@napi-rs/snappy-win32-x64-msvc": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/snappy-win32-x64-msvc/-/snappy-win32-x64-msvc-7.1.1.tgz", + "integrity": "sha512-Mu3yELySvzhBcNTVCq+hYxVh+lH3/KjoQ5HIEb3DDPoX0AGRTm3XZa+usq8pFWjl91Cgp9nWK+9lVSkCCIRaKA==", + "optional": true + }, "@noble/ed25519": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.6.0.tgz", @@ -30566,6 +30901,11 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" }, + "async-exit-hook": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/async-exit-hook/-/async-exit-hook-2.0.1.tgz", + "integrity": "sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==" + }, "async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", @@ -31157,6 +31497,11 @@ "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", "integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==" }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, "buffer": { "version": "4.9.2", "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", @@ -41538,6 +41883,27 @@ } } }, + "snappy": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/snappy/-/snappy-7.1.1.tgz", + "integrity": "sha512-mL7GGPJ+WdsaFT5aR/uEqCq8cPg2VbhyifDEP7AeqIVDsAC8LBGYbZP1Qzoa2Ym84OW7JEQXqIpwqFp1EQw5BA==", + "optional": true, + "requires": { + "@napi-rs/snappy-android-arm-eabi": "7.1.1", + "@napi-rs/snappy-android-arm64": "7.1.1", + "@napi-rs/snappy-darwin-arm64": "7.1.1", + "@napi-rs/snappy-darwin-x64": "7.1.1", + "@napi-rs/snappy-freebsd-x64": "7.1.1", + "@napi-rs/snappy-linux-arm-gnueabihf": "7.1.1", + "@napi-rs/snappy-linux-arm64-gnu": "7.1.1", + "@napi-rs/snappy-linux-arm64-musl": "7.1.1", + "@napi-rs/snappy-linux-x64-gnu": "7.1.1", + "@napi-rs/snappy-linux-x64-musl": "7.1.1", + "@napi-rs/snappy-win32-arm64-msvc": "7.1.1", + "@napi-rs/snappy-win32-ia32-msvc": "7.1.1", + "@napi-rs/snappy-win32-x64-msvc": "7.1.1" + } + }, "snyk": { "version": "1.956.0", "resolved": "https://registry.npmjs.org/snyk/-/snyk-1.956.0.tgz", @@ -43111,6 +43477,18 @@ } } }, + "winston-loki": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/winston-loki/-/winston-loki-6.0.6.tgz", + "integrity": "sha512-cll+nv5T/b9uJXqca0N2WKL1JJNuJND9E6WOOAuSGkZ44L9VQ/QK9F+/5VKbv6LIP9p0nvPSOYxtACCDb/9iWw==", + "requires": { + "async-exit-hook": "2.0.1", + "btoa": "^1.2.1", + "protobufjs": "^6.8.8", + "snappy": "7.1.1", + "winston-transport": "^4.3.0" + } + }, "winston-transport": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.5.0.tgz", diff --git a/package.json b/package.json index 72ab7d95..c85c2732 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,8 @@ "strong-cryptor": "^2.2.0", "winston": "^3.3.3", "winston-cloudwatch": "^6.0.1", - "winston-logzio": "^5.1.2" + "winston-logzio": "^5.1.2", + "winston-loki": "^6.0.6" }, "devDependencies": { "@loopback/build": "^9.0.1", diff --git a/pocket-gateway/tasks/shared-envs.json b/pocket-gateway/tasks/shared-envs.json index ef53412a..443089bc 100644 --- a/pocket-gateway/tasks/shared-envs.json +++ b/pocket-gateway/tasks/shared-envs.json @@ -112,7 +112,18 @@ "key": "DATADOG_API_KEY", "value": "${{ secrets.DATADOG_API_KEY }}" }, - + { + "key": "LOG_TO_LOKI", + "value": "${{ secrets.LOG_TO_LOKI }}" + }, + { + "key": "LOKI_BASIC_AUTH", + "value": "${{ secrets.LOKI_BASIC_AUTH }}" + }, + { + "key": "LOKI_HOST", + "value": "${{ secrets.LOKI_HOST }}" + }, { "key": "ALWAYS_REDIRECT_TO_ALTRUISTS", "value": "${{ secrets.ALWAYS_REDIRECT_TO_ALTRUISTS }}" @@ -132,8 +143,7 @@ { "key": "RATE_LIMITER_TOKEN", "value": "${{ secrets.RATE_LIMITER_TOKEN }}" - } - , + }, { "key": "INFLUX_URLS", "value": "${{ secrets.INFLUX_URLS }}" @@ -149,6 +159,10 @@ { "key": "ALTRUIST_ONLY_CHAINS", "value": "${{ secrets.ALTRUIST_ONLY_CHAINS }}" + }, + { + "key": "GATEWAY_HOST", + "value": "${{ secrets.GATEWAY_HOST }}" } ] -} +} \ No newline at end of file diff --git a/src/application.ts b/src/application.ts index 325495c4..788cbf50 100644 --- a/src/application.ts +++ b/src/application.ts @@ -72,6 +72,7 @@ export class PocketGatewayApplication extends BootMixin(ServiceMixin(RepositoryM REDIS_LOCAL_TTL_FACTOR, RATE_LIMITER_URL, RATE_LIMITER_TOKEN, + GATEWAY_HOST, }: // eslint-disable-next-line @typescript-eslint/no-explicit-any any = await this.get('configuration.environment.values') @@ -90,6 +91,7 @@ export class PocketGatewayApplication extends BootMixin(ServiceMixin(RepositoryM const ttlFactor = parseFloat(REDIS_LOCAL_TTL_FACTOR) || 1 const rateLimiterURL: string = RATE_LIMITER_URL || '' const rateLimiterToken: string = RATE_LIMITER_TOKEN || '' + const gatewayHost: string = GATEWAY_HOST || 'localhost' const influxURLs = (INFLUX_URLS || '').split(',') const influxTokens = (INFLUX_TOKENS || '').split(',') @@ -117,6 +119,7 @@ export class PocketGatewayApplication extends BootMixin(ServiceMixin(RepositoryM this.bind('altruistOnlyChains').to(altruistOnlyChains) this.bind('rateLimiterURL').to(rateLimiterURL) this.bind('rateLimiterToken').to(rateLimiterToken) + this.bind('gatewayHost').to(gatewayHost) const redisPort: string = REDIS_PORT || '' diff --git a/src/controllers/v1.controller.ts b/src/controllers/v1.controller.ts index 87eaf3e0..ea4109c8 100644 --- a/src/controllers/v1.controller.ts +++ b/src/controllers/v1.controller.ts @@ -4,7 +4,7 @@ import jsonrpc, { ErrorObject, JsonRpcError } from 'jsonrpc-lite' import { Pool as PGPool } from 'pg' import { inject } from '@loopback/context' import { FilterExcludingWhere, repository } from '@loopback/repository' -import { get, param, post, requestBody } from '@loopback/rest' +import { get, param, post, requestBody, Request, RestBindings } from '@loopback/rest' import { WriteApi } from '@influxdata/influxdb-client' import { Applications, GatewaySettings, LoadBalancers } from '../models' import { StickinessOptions } from '../models/load-balancers.model' @@ -45,6 +45,7 @@ export class V1Controller { mergeChecker: MergeChecker constructor( + @inject(RestBindings.Http.REQUEST) private request: Request, @inject('secretKey') private secretKey: string, @inject('host') private host: string, @inject('origin') private origin: string, @@ -70,6 +71,7 @@ export class V1Controller { @inject('dispatchURL') private dispatchURL: string, @inject('rateLimiterURL') private rateLimiterURL: string, @inject('rateLimiterToken') private rateLimiterToken: string, + @inject('gatewayHost') private gatewayHost: string, @repository(ApplicationsRepository) public applicationsRepository: ApplicationsRepository, @repository(BlockchainsRepository) @@ -114,6 +116,7 @@ export class V1Controller { alwaysRedirectToAltruists: this.alwaysRedirectToAltruists, altruistOnlyChains: this.altruistOnlyChains, dispatchers: this.dispatchURL, + request: this.request, }) } @@ -156,8 +159,7 @@ export class V1Controller { ) // Any alias works to load a specific blockchain - // TODO: Move URL to ENV - this.host = `${blockchainAliases[0]}.gateway.pokt.network` + this.host = `${blockchainAliases[0]}.${this.gatewayHost}` const { blockchainRedirects, blockchainPath } = await loadBlockchain( this.host, diff --git a/src/observers/environment.observer.ts b/src/observers/environment.observer.ts index 0ab396cb..660a7c4c 100644 --- a/src/observers/environment.observer.ts +++ b/src/observers/environment.observer.ts @@ -37,6 +37,7 @@ export class EnvironmentObserver implements LifeCycleObserver { // Not required in code, but must be present in .env 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', + 'GATEWAY_HOST', ] private static requiredEnvVarsOnlyInProd = [] diff --git a/src/services/chain-checker.ts b/src/services/chain-checker.ts index 85468fda..e040cc68 100644 --- a/src/services/chain-checker.ts +++ b/src/services/chain-checker.ts @@ -339,7 +339,6 @@ export class ChainChecker { error: typeof relay.message === 'object' ? JSON.stringify(relay.message) : relay.message, code: undefined, origin: this.origin, - data: undefined, session, }) .catch(function log(e) { @@ -377,7 +376,6 @@ export class ChainChecker { error: JSON.stringify(relay), code: undefined, origin: this.origin, - data: undefined, session, }) .catch(function log(e) { diff --git a/src/services/logger.ts b/src/services/logger.ts index 1fa54b0a..5b5531df 100644 --- a/src/services/logger.ts +++ b/src/services/logger.ts @@ -6,8 +6,9 @@ import { HttpErrors } from '@loopback/rest' require('dotenv').config() const DatadogWinston = require('datadog-winston') - const { createLogger, format, transports: winstonTransports } = require('winston') +const LokiWinston = require('winston-loki') + const { printf } = format interface Log { @@ -37,6 +38,10 @@ const logToDataDog = process.env.LOG_TO_DATADOG === 'true' const ddApiKey = process.env.DATADOG_API_KEY || '' const silent = process.env.SILENT_LOGGING === 'true' +const logToLoki = process.env.LOG_TO_LOKI === 'true' +const lokiHost = process.env.LOKI_HOST || 'http://127.0.0.1:3100' +const lokiBasicAuth = process.env.LOKI_BASIC_AUTH || '' + const timestampUTC = () => { const timestamp = new Date() @@ -114,6 +119,15 @@ const options = { intakeRegion: 'eu', ddtags: `region:${region}`, }, + loki: { + host: lokiHost, + basicAuth: lokiBasicAuth, + json: true, + labels: { app: logName, hostname: os.hostname(), source: 'nodejs', region: region }, + format: format.json(), + replaceTimestamp: true, + onConnectionError: (err) => console.error(err), + }, } const getTransports = () => { @@ -137,6 +151,14 @@ const getTransports = () => { transports.push(new DatadogWinston(options.datadog)) } + + if (logToLoki) { + if (!lokiHost) { + throw new HttpErrors.InternalServerError('LOKI_HOST required in ENV') + } + + transports.push(new LokiWinston(options.loki)) + } } return transports diff --git a/src/services/merge-checker.ts b/src/services/merge-checker.ts index be2c4ba1..573a08fe 100644 --- a/src/services/merge-checker.ts +++ b/src/services/merge-checker.ts @@ -358,7 +358,6 @@ export class MergeChecker { error: typeof relay.message === 'object' ? JSON.stringify(relay.message) : relay.message, code: undefined, origin: this.origin, - data: undefined, session, }) .catch(function log(e) { @@ -396,7 +395,6 @@ export class MergeChecker { error: JSON.stringify(relay), code: undefined, origin: this.origin, - data: undefined, session, }) .catch(function log(e) { diff --git a/src/services/metrics-recorder.ts b/src/services/metrics-recorder.ts index d276eb94..480d819b 100644 --- a/src/services/metrics-recorder.ts +++ b/src/services/metrics-recorder.ts @@ -50,20 +50,19 @@ export class MetricsRecorder { serviceNode, relayStart, result, - responseStart, bytes, fallback, method, error, code, origin, - data, session, timeout, sticky, elapsedTime = 0, gigastakeAppID, forcedFallback = false, + url, }: { requestID: string applicationID: string @@ -73,20 +72,19 @@ export class MetricsRecorder { serviceNode: string | undefined relayStart?: [number, number] result: number - responseStart?: string | undefined bytes: number fallback: boolean method: string | undefined error: string | undefined code: string | undefined origin: string | undefined - data: string | undefined session: Session | undefined timeout?: number sticky?: string elapsedTime?: number gigastakeAppID?: string forcedFallback?: boolean + url?: string }): Promise { try { const { key: sessionKey } = session || {} @@ -120,7 +118,7 @@ export class MetricsRecorder { // Parse value if coming as BigInt if (result === 200) { - logger.log('info', 'SUCCESS' + fallbackTag + ' RELAYING ' + blockchainID + ' req: ' + data, { + logger.log('info', 'SUCCESS' + fallbackTag + ' RELAYING ' + blockchainID, { requestID, relayType: 'APP', typeID: applicationID, @@ -129,18 +127,17 @@ export class MetricsRecorder { serviceURL, serviceDomain, elapsedTime, - origin, blockchainSubdomain: blockchain, blockchainID, sessionKey, sticky, sessionBlockHeight: session?.header.sessionBlockHeight, blockHeight: session?.blockHeight, - responseStart, forcedFallback, + url, }) } else if (result === 500) { - logger.log('error', 'FAILURE' + fallbackTag + ' RELAYING ' + blockchainID + ' req: ' + data, { + logger.log('error', 'FAILURE' + fallbackTag + ' RELAYING ' + blockchainID, { requestID, relayType: 'APP', typeID: applicationID, @@ -150,7 +147,6 @@ export class MetricsRecorder { serviceDomain, elapsedTime, error, - origin, blockchainSubdomain: blockchain, blockchainID, sessionKey, @@ -158,9 +154,10 @@ export class MetricsRecorder { sessionBlockHeight: session.header.sessionBlockHeight, blockHeight: session.blockHeight, forcedFallback, + url, }) } else if (result === 503) { - logger.log('error', 'INVALID RESPONSE' + fallbackTag + ' RELAYING ' + blockchainID + ' req: ' + data, { + logger.log('error', 'INVALID RESPONSE' + fallbackTag + ' RELAYING ' + blockchainID, { requestID, relayType: 'APP', typeID: applicationID, @@ -170,7 +167,6 @@ export class MetricsRecorder { serviceDomain, elapsedTime, error, - origin, blockchainSubdomain: blockchain, blockchainID, sessionKey, diff --git a/src/services/pocket-relayer.ts b/src/services/pocket-relayer.ts index cdb6bf98..8aa0bcb7 100644 --- a/src/services/pocket-relayer.ts +++ b/src/services/pocket-relayer.ts @@ -2,6 +2,7 @@ import { EvidenceSealedError, Relayer } from '@pokt-foundation/pocketjs-relayer' import { Session, Node, PocketAAT, HTTPMethod } from '@pokt-foundation/pocketjs-types' import axios, { AxiosRequestConfig, Method } from 'axios' import jsonrpc, { ErrorObject, IParsedObject } from 'jsonrpc-lite' +import { Request } from '@loopback/rest' import AatPlans from '../config/aat-plans.json' import { RelayError } from '../errors/types' import { Applications } from '../models' @@ -54,6 +55,7 @@ export class PocketRelayer { alwaysRedirectToAltruists: boolean altruistOnlyChains: string[] dispatchers: string + requestURL: string constructor({ host, @@ -77,6 +79,7 @@ export class PocketRelayer { alwaysRedirectToAltruists = false, altruistOnlyChains = [], dispatchers, + request, }: { host: string origin: string @@ -99,6 +102,7 @@ export class PocketRelayer { alwaysRedirectToAltruists?: boolean altruistOnlyChains?: string[] dispatchers?: string + request?: Request }) { this.host = host this.origin = origin @@ -121,6 +125,7 @@ export class PocketRelayer { this.alwaysRedirectToAltruists = alwaysRedirectToAltruists this.altruistOnlyChains = altruistOnlyChains this.dispatchers = dispatchers + this.requestURL = `${request?.headers?.host}${request?.url}` } async sendRelay({ @@ -175,7 +180,7 @@ export class PocketRelayer { rpcID ).catch((e) => { logger.log('error', `Incorrect blockchain: ${this.host}`, { - origin: this.origin, + applicationID, }) throw e }) @@ -224,7 +229,6 @@ export class PocketRelayer { relayType: 'APP', error: `${restriction.error.message}`, typeID: application.id, - origin: this.origin, }) return restriction } @@ -316,10 +320,10 @@ export class PocketRelayer { error: userErrorMessage, code: userErrorCode, origin: this.origin, - data, session: this.session, sticky: await NodeSticker.stickyRelayResult(preferredNodeAddress, relay.serviceNode.publicKey), gigastakeAppID: applicationID !== application.id ? application.id : undefined, + url: this.requestURL, }) .catch(function log(e) { logger.log('error', 'Error recording metrics: ' + e, { @@ -376,11 +380,11 @@ export class PocketRelayer { error, code: String(relay.code), origin: this.origin, - data, // TODO: Add pocket session again session: this.session, sticky, gigastakeAppID: applicationID !== application.id ? application.id : undefined, + url: this.requestURL, }) .catch(function log(e) { logger.log('error', 'Error recording metrics: ' + e, { @@ -406,7 +410,6 @@ export class PocketRelayer { relayType: 'APP', typeID: application.id, error: e, - origin: this.origin, trace: e.stack, }) } @@ -447,7 +450,6 @@ export class PocketRelayer { relayType: 'FALLBACK', typeID: application.id, serviceNode: 'fallback:' + redactedAltruistURL, - origin: this.origin, }) } @@ -487,17 +489,16 @@ export class PocketRelayer { serviceNode: 'fallback:' + redactedAltruistURL, relayStart, result: 200, - responseStart: Buffer.from(JSON.stringify(responseParsed)).toString('utf-8', 0, 200), bytes: Buffer.byteLength(JSON.stringify(responseParsed), 'utf8'), fallback: true, method: method, error: undefined, code: undefined, origin: this.origin, - data, session: this.session, gigastakeAppID: applicationID !== application.id ? application.id : undefined, forcedFallback: !notForceFallback, + url: this.requestURL, }) .catch(function log(e) { logger.log('error', 'Error recording metrics: ' + e, { @@ -517,7 +518,6 @@ export class PocketRelayer { typeID: application.id, serviceNode: 'fallback:' + redactedAltruistURL, blockchainID, - origin: this.origin, forcedFallback: !notForceFallback, }) } @@ -529,7 +529,6 @@ export class PocketRelayer { typeID: application.id, serviceNode: 'fallback:' + redactedAltruistURL, blockchainID, - origin: this.origin, forcedFallback: !notForceFallback, }) } @@ -541,7 +540,6 @@ export class PocketRelayer { relayType: 'EXHAUSTED', typeID: application.id, blockchainID, - origin: this.origin, }) throw new ErrorObject(rpcID, new jsonrpc.JsonRpcError('Internal JSON-RPC error.', -32603)) @@ -667,7 +665,6 @@ export class PocketRelayer { logger.log('error', 'ERROR obtaining a session: ' + error, { relayType: 'APP', typeID: application.id, - origin: this.origin, blockchainID, requestID, error: error.message, @@ -701,7 +698,6 @@ export class PocketRelayer { relayType: 'APP', typeID: application.id, blockchainID, - origin: this.origin, }) return new Error("session doesn't have any available nodes") } @@ -799,7 +795,6 @@ export class PocketRelayer { error, code: undefined, origin: this.origin, - data, session: this.session, gigastakeAppID: applicationID !== application.id ? application.id : undefined, }) @@ -839,7 +834,6 @@ export class PocketRelayer { error, code: undefined, origin: this.origin, - data, session: this.session, gigastakeAppID: applicationID !== application.id ? application.id : undefined, }) diff --git a/src/services/sync-checker.ts b/src/services/sync-checker.ts index c7a6eadb..5104fe53 100644 --- a/src/services/sync-checker.ts +++ b/src/services/sync-checker.ts @@ -285,7 +285,6 @@ export class SyncChecker { error: `OUT OF SYNC: current block height on chain ${blockchainID}: ${highestNodeBlockHeight} - altruist block height: ${altruistBlockHeight} - nodes height: ${blockHeight} - sync allowance: ${syncAllowance}`, code: undefined, origin: this.origin, - data: undefined, session, }) .catch(function log(e) { @@ -521,7 +520,6 @@ export class SyncChecker { error: typeof relay.message === 'object' ? JSON.stringify(relay.message) : relay.message, code: undefined, origin: this.origin, - data: undefined, session, }) .catch(function log(e) { @@ -559,7 +557,6 @@ export class SyncChecker { error: JSON.stringify(relay), code: undefined, origin: this.origin, - data: undefined, session, }) .catch(function log(e) { diff --git a/tests/acceptance/test-helper.ts b/tests/acceptance/test-helper.ts index cb7c4343..7afe65c0 100644 --- a/tests/acceptance/test-helper.ts +++ b/tests/acceptance/test-helper.ts @@ -35,6 +35,7 @@ export const DUMMY_ENV = { RATE_LIMITER_URL: 'https://rate.limiter', RATE_LIMITER_TOKEN: 'rate-limiter-token', ALTRUIST_ONLY_CHAINS: '', + GATEWAY_HOST: 'localhost', } export async function setupApplication(pocket?: Relayer, envs?: object): Promise { diff --git a/tests/acceptance/v1.controller.acceptance.ts b/tests/acceptance/v1.controller.acceptance.ts index bd5ccf06..ac48400e 100644 --- a/tests/acceptance/v1.controller.acceptance.ts +++ b/tests/acceptance/v1.controller.acceptance.ts @@ -815,9 +815,13 @@ describe('V1 controller (acceptance)', () => { }) it('redirects empty path with specific load balancer', async () => { + const gatewayHost = 'custom-host' + const gatewayHostKey = 'gatewayHost' const pocket = pocketMock.object() - ;({ app, client } = await setupApplication(pocket)) + ;({ app, client } = await setupApplication(pocket, { + GATEWAY_HOST: gatewayHost, + })) const response = await client .post('/') @@ -826,6 +830,7 @@ describe('V1 controller (acceptance)', () => { .set('host', 'eth-mainnet-x') .expect(200) + expect(app.find(gatewayHostKey)[0].getValue(app.getOwnerContext(gatewayHostKey))).equal(gatewayHost) expect(response.headers).to.containDeep({ 'content-type': 'application/json' }) expect(response.body).to.have.properties('id', 'jsonrpc', 'result') expect(parseInt(response.body.result, 16)).to.be.aboveOrEqual(0) @@ -1983,8 +1988,7 @@ describe('V1 controller (acceptance)', () => { expect(response.body.error.message).to.startWith('Restricted endpoint: contract address not allowed') }) - // eslint-disable-next-line mocha/no-exclusive-tests - it.only('invokes POST /v1/{appId} and successfully relays a request only through the altruist', async () => { + it('invokes POST /v1/{appId} and successfully relays a request only through the altruist', async () => { const pocket = pocketMock.object() const logSpy = sinon.spy(logger, 'log')