A minimalistic adapter for logspout to send notifications to SigNoz using http(s) endpoint.
Let's say you are running your application using docker or docker compose. You want to send logs to SigNoz, then you can use this adapter to send logs to SigNoz.
- Direct post to signoz http endpoint. So this adapter can send more detailed logs.
- Auto detect service name, so no special configuration needed.
- For JSON logs, picks name from JSON service field.
- Otherwise pick service name from docker-compose or docker-swarm service name.
- Otherwise use docker image name as service name
- Auto detect env name, so no special configuration needed
- For JSON logs, picks name from JSON env field.
- Otherwise pick env from logspout-signoz env variable ENV.
- Auto parse JSON logs.
- Map well known JSON log attribute to appropriate Signoz log payload fields. e.g
leveltoSeverityText, etc - Pack other JSON attribute to into attributes key of Signoz log payload.
- Map well known JSON log attribute to appropriate Signoz log payload fields. e.g
First enable http log receiver by adding following to otel-collector-config.yaml
- Add
httplogreceiver/jsontoreceiverssection - Add
httplogreceiver/jsontoservice.pipelines.logs.receiverssection
receivers:
httplogreceiver/json:
endpoint: 0.0.0.0:8082
source: json
...
service:
pipelines:
logs:
receivers: [otlp, tcplog/docker, httplogreceiver/json]
processors: [batch]
exporters: [clickhouselogsexporter]Open the port 8082 in your otel-collector container as follows:
services:
otel-collector:
image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.102.10}
container_name: signoz-otel-collector
ports:
- "8082:8082" # SigNoz logsThen run the logspout-signoz container with the following command: (Run this on each node where you want to collect logs)
docker run -d \
--volume=/var/run/docker.sock:/var/run/docker.sock \
-e 'SIGNOZ_LOG_ENDPOINT=http://1.2.3.4:8082' \
-e 'ENV=prod' \
pavanputhra/logspout-signoz \
signoz://localhost:8082You can use the following environment variables to configure the adapter:
SIGNOZ_LOG_ENDPOINT: The URL of the SigNoz log endpoint. Default:http://localhost:8082ENV: The environment name.DISABLE_JSON_PARSE: Any string value will disable JSON parsing and sends the JSON log as it is.DISABLE_LOG_LEVEL_STRING_MATCH: For non-JSON logs, this adapter tries to detect log level by trying to search string "ERROR", "INFO", etc. and map it to Signoz log severity. Assigining any string value to this env var will disable detection of log level.
Follow the instructions to build your own logspout image including this module.
In a nutshell, copy the contents of the custom folder and add the following import line above others in modules.go:
package main
import (
_ "github.com/pavanputhra/logspout-signoz/signoz"
// ...
)If you'd like to select a particular version create the following Dockerfile:
ARG VERSION
FROM gliderlabs/logspout:$VERSION
ONBUILD COPY ./build.sh /src/build.sh
ONBUILD COPY ./modules.go /src/modules.go
Then build your image with: docker build --no-cache --pull --force-rm --build-arg VERSION=v3.2.11 -f dockerfile -t logspout:v3.2.11 .
You can use the standard logspout filters to filter container names and output types: