Skip to content

Commit

Permalink
feat(coralogix): integrate coralogix
Browse files Browse the repository at this point in the history
  • Loading branch information
yossi-eynav committed Feb 17, 2024
1 parent 8649e46 commit a5e4987
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 61 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ jobs:
SERVER_SENTRY_DSN=${{ secrets.SERVER_SENTRY_DSN }}
AWS_ACCESS_KEY_ID=${{ secrets.SERVER_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.SERVER_AWS_SECRET_ACCESS_KEY }}
SERVER_CORALOGIX_SERVICE_NAME=${{ vars.SERVER_CORALOGIX_SERVICE_NAME }}
SERVER_CORALOGIX_API_KEY=${{secrets.SERVER_CORALOGIX_API_KEY}}
VERSION=${{github.sha}}
NODE_ENV=staging
- name: Deploy Amazon ECS task definition
Expand Down Expand Up @@ -174,6 +176,8 @@ jobs:
VERSION=${{github.sha}}
AWS_ACCESS_KEY_ID=${{ secrets.SERVER_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.SERVER_AWS_SECRET_ACCESS_KEY }}
SERVER_CORALOGIX_SERVICE_NAME=${{ vars.SERVER_CORALOGIX_SERVICE_NAME }}
SERVER_CORALOGIX_API_KEY=${{secrets.SERVER_CORALOGIX_API_KEY}}
NODE_ENV=production
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 37 additions & 19 deletions server/api/lib/log.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
const winston = require('winston');
const os = require('os');
const Config = require('./config');

const apikey = Config.get('coralogix.apikey');
const serviceName = Config.get('coralogix.serviceName');
const host = Config.get('coralogix.host');


const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
defaultMeta: { version: process.env.VERSION, env: process.env.NODE_ENV },
transports: [
new winston.transports.Console()
//
// - Write to all logs with level `info` and below to `combined.log`
// - Write all logs error (and below) to `error.log`.
//
// new winston.transports.File({ filename: 'error.log', level: 'error' }),
// new winston.transports.File({ filename: 'combined.log' })
new winston.transports.Console(),
new winston.transports.Http({
name: "coralogix",
level: "info",
format: winston.format((info) => ({
applicationName: "meirim",
subsystemName: serviceName,
computerName: os.hostname(),
timestamp: Date.now(),
severity: {
silly: 1,
debug: 1,
verbose: 2,
info: 3,
warn: 4,
error: 5,
critical: 6
}[info.level] || 3,
text: info.message,
}))(),
host: host,
path: "logs/v1/singles",
headers: {
"authorization": "Bearer " + apikey,
},
ssl: true,
batchInterval: 1000,
handleExceptions: true,
}),
]
});

//
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
// //
// if (process.env.NODE_ENV !== 'production') {
// logger.add(new winston.transports.Console({
// format: winston.format.simple()
// }));
// }

logger.level = 'debug';

module.exports = {
debug: (...args) => {
Expand Down
2 changes: 2 additions & 0 deletions server/bin/serve
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ server.on('error', (error) => {
server.on('listening', () => {
const addr = server.address();
const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;

l.info("this is a test!")
console.log('Listening on ' + bind);
});

Expand Down
1 change: 1 addition & 0 deletions server/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"coralogix": {"apikey": "SERVER_CORALOGIX_API_KEY", "serviceName": "SERVER_CORALOGIX_SERVICE_NAME"},
"sentry_dsn": "SERVER_SENTRY_DSN",
"geocoder": {
"apiKey": "SERVER_GEOCODER_API_KEY"
Expand Down
3 changes: 3 additions & 0 deletions server/config/default.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"coralogix": {
"host": "ingress.cx498.coralogix.com"
},
"geocoder": {
"provider": "google",
"httpAdapter": "https",
Expand Down
113 changes: 72 additions & 41 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"staticmaps": "^1.10.0",
"terraformer-wkt-parser": "^1.2.1",
"turf": "^3.0.14",
"winston": "^3.3.3",
"winston": "^3.10.3",
"xlsx": "^0.16.9"
},
"scripts": {
Expand Down

0 comments on commit a5e4987

Please sign in to comment.