Skip to content

Commit

Permalink
removed the sending docker logs to signoz set up and instead added su…
Browse files Browse the repository at this point in the history
…pport for sending pino logs and added trace log correlation
  • Loading branch information
yuvraajsj18 committed May 29, 2024
1 parent 0575299 commit f12322f
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 36 deletions.
13 changes: 0 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,6 @@ services:
networks:
- myapp-network

logspout:
image: "gliderlabs/logspout:v3.2.14"
container_name: signoz-logspout
volumes:
- /etc/hostname:/etc/host_hostname:ro
- /var/run/docker.sock:/var/run/docker.sock
command: syslog+tcp://otel-collector:2255
depends_on:
- otel-collector
networks:
- myapp-network
restart: on-failure

networks:
myapp-network:

Expand Down
22 changes: 18 additions & 4 deletions order-service/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@ import { trace } from "@opentelemetry/api";

const logger = pino({
transport: {
target: "pino-pretty",
targets: [
{
target: "pino-opentelemetry-transport",
options: {
resourceAttributes: {
"service.name": "order-service",
},
},
},
{
target: "pino-pretty",
level: "info",
options: { colorize: true },
},
],
},
formatters: {
log: (log) => {
const currentSpan = trace.getActiveSpan();
if (currentSpan) {
const { traceId, spanId } = currentSpan.spanContext();
const { traceId, spanId, traceFlags } = currentSpan.spanContext();

log.traceId = traceId;
log.spanId = spanId;
log.traceFlags = traceFlags;

console.log("Hereeee", traceId, " + ", spanId);
console.log("Hereeee in the object", traceId, " + ", spanId);
}
console.log(log);
return log;
},
},
Expand Down
171 changes: 171 additions & 0 deletions order-service/package-lock.json

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

1 change: 1 addition & 0 deletions order-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"mongoose": "^8.3.2",
"node-fetch": "^3.3.2",
"pino": "^9.1.0",
"pino-opentelemetry-transport": "^1.0.0",
"pino-pretty": "^11.1.0"
}
}
21 changes: 2 additions & 19 deletions otel-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ receivers:
- job_name: otel-collector-binary
static_configs:
- targets:
tcplog/docker:
listen_address: "0.0.0.0:2255"
operators:
- type: regex_parser
regex: '^<([0-9]+)>[0-9]+ (?P<timestamp>[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?) (?P<container_id>\S+) (?P<container_name>\S+) [0-9]+ - -( (?P<body>.*))?'
timestamp:
parse_from: attributes.timestamp
layout: '%Y-%m-%dT%H:%M:%S.%LZ'
- type: move
from: attributes["body"]
to: body
- type: remove
field: attributes.timestamp
# please remove names from below if you want to collect logs from them
- type: filter
id: signoz_logs_filter
expr: 'attributes.container_name matches "^signoz-(logspout|frontend|alertmanager|query-service|otel-collector|otel-collector-metrics|clickhouse|zookeeper)"'
processors:
batch:
send_batch_size: 1000
Expand Down Expand Up @@ -85,6 +68,6 @@ service:
processors: [batch]
exporters: [otlp]
logs:
receivers: [tcplog/docker]
receivers: [otlp]
processors: [batch]
exporters: [otlp]
exporters: [otlp]

0 comments on commit f12322f

Please sign in to comment.