Skip to content

Commit a51ee66

Browse files
Improvement: Added Otel-collector setup for local dev environment (#8701)
* feat(devenv): add otel-collector support for local development - Add .devenv/docker/otel-collector/ with compose.yaml and config - Add devenv-otel-collector and devenv-up targets to Makefile - Update development.md with otel-collector setup instructions - Add README.md with usage documentation for otel-collector setup This enables developers to run the complete SigNoz stack locally, including the OpenTelemetry Collector for receiving telemetry data on ports 4317 (gRPC) and 4318 (HTTP). * docs: improve collector setup wordings * chore: fixed comment and service name * chore: docker service name updated otel-collector -> signoz-otel-collector
1 parent 75d1891 commit a51ee66

File tree

4 files changed

+178
-5
lines changed

4 files changed

+178
-5
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
services:
2+
signoz-otel-collector:
3+
image: signoz/signoz-otel-collector:v0.128.2
4+
container_name: signoz-otel-collector-dev
5+
command:
6+
- --config=/etc/otel-collector-config.yaml
7+
- --feature-gates=-pkg.translator.prometheus.NormalizeName
8+
volumes:
9+
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
10+
environment:
11+
- OTEL_RESOURCE_ATTRIBUTES=host.name=signoz-host,os.type=linux
12+
- LOW_CARDINAL_EXCEPTION_GROUPING=false
13+
ports:
14+
- "4317:4317" # OTLP gRPC receiver
15+
- "4318:4318" # OTLP HTTP receiver
16+
- "13133:13133" # health check extension
17+
healthcheck:
18+
test:
19+
- CMD
20+
- wget
21+
- --spider
22+
- -q
23+
- localhost:13133
24+
interval: 30s
25+
timeout: 5s
26+
retries: 3
27+
restart: unless-stopped
28+
extra_hosts:
29+
- "host.docker.internal:host-gateway"
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
receivers:
2+
otlp:
3+
protocols:
4+
grpc:
5+
endpoint: 0.0.0.0:4317
6+
http:
7+
endpoint: 0.0.0.0:4318
8+
prometheus:
9+
config:
10+
global:
11+
scrape_interval: 60s
12+
scrape_configs:
13+
- job_name: otel-collector
14+
static_configs:
15+
- targets:
16+
- localhost:8888
17+
labels:
18+
job_name: otel-collector
19+
20+
processors:
21+
batch:
22+
send_batch_size: 10000
23+
send_batch_max_size: 11000
24+
timeout: 10s
25+
resourcedetection:
26+
# Using OTEL_RESOURCE_ATTRIBUTES envvar, env detector adds custom labels.
27+
detectors: [env, system]
28+
timeout: 2s
29+
signozspanmetrics/delta:
30+
metrics_exporter: signozclickhousemetrics
31+
metrics_flush_interval: 60s
32+
latency_histogram_buckets: [100us, 1ms, 2ms, 6ms, 10ms, 50ms, 100ms, 250ms, 500ms, 1000ms, 1400ms, 2000ms, 5s, 10s, 20s, 40s, 60s ]
33+
dimensions_cache_size: 100000
34+
aggregation_temporality: AGGREGATION_TEMPORALITY_DELTA
35+
enable_exp_histogram: true
36+
dimensions:
37+
- name: service.namespace
38+
default: default
39+
- name: deployment.environment
40+
default: default
41+
# This is added to ensure the uniqueness of the timeseries
42+
# Otherwise, identical timeseries produced by multiple replicas of
43+
# collectors result in incorrect APM metrics
44+
- name: signoz.collector.id
45+
- name: service.version
46+
- name: browser.platform
47+
- name: browser.mobile
48+
- name: k8s.cluster.name
49+
- name: k8s.node.name
50+
- name: k8s.namespace.name
51+
- name: host.name
52+
- name: host.type
53+
- name: container.name
54+
55+
extensions:
56+
health_check:
57+
endpoint: 0.0.0.0:13133
58+
pprof:
59+
endpoint: 0.0.0.0:1777
60+
61+
exporters:
62+
clickhousetraces:
63+
datasource: tcp://host.docker.internal:9000/signoz_traces
64+
low_cardinal_exception_grouping: ${env:LOW_CARDINAL_EXCEPTION_GROUPING}
65+
use_new_schema: true
66+
signozclickhousemetrics:
67+
dsn: tcp://host.docker.internal:9000/signoz_metrics
68+
clickhouselogsexporter:
69+
dsn: tcp://host.docker.internal:9000/signoz_logs
70+
timeout: 10s
71+
use_new_schema: true
72+
73+
service:
74+
telemetry:
75+
logs:
76+
encoding: json
77+
extensions:
78+
- health_check
79+
- pprof
80+
pipelines:
81+
traces:
82+
receivers: [otlp]
83+
processors: [signozspanmetrics/delta, batch]
84+
exporters: [clickhousetraces]
85+
metrics:
86+
receivers: [otlp]
87+
processors: [batch]
88+
exporters: [signozclickhousemetrics]
89+
metrics/prometheus:
90+
receivers: [prometheus]
91+
processors: [batch]
92+
exporters: [signozclickhousemetrics]
93+
logs:
94+
receivers: [otlp]
95+
processors: [batch]
96+
exporters: [clickhouselogsexporter]

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ devenv-postgres: ## Run postgres in devenv
6161
@cd .devenv/docker/postgres; \
6262
docker compose -f compose.yaml up -d
6363

64+
.PHONY: devenv-signoz-otel-collector
65+
devenv-signoz-otel-collector: ## Run signoz-otel-collector in devenv (requires clickhouse to be running)
66+
@cd .devenv/docker/signoz-otel-collector; \
67+
docker compose -f compose.yaml up -d
68+
69+
.PHONY: devenv-up
70+
devenv-up: devenv-clickhouse devenv-signoz-otel-collector ## Start both clickhouse and signoz-otel-collector for local development
71+
@echo "Development environment is ready!"
72+
@echo " - ClickHouse: http://localhost:8123"
73+
@echo " - Signoz OTel Collector: grpc://localhost:4317, http://localhost:4318"
74+
6475
##############################################################
6576
# go commands
6677
##############################################################

docs/contributing/development.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,35 @@ Before diving in, make sure you have these tools installed:
4444

4545
SigNoz has three main components: Clickhouse, Backend, and Frontend. Let's set them up one by one.
4646

47-
### 1. Setting up Clickhouse
47+
### 1. Setting up ClickHouse
4848

49-
First, we need to get Clickhouse running:
49+
First, we need to get ClickHouse running:
5050

5151
```bash
5252
make devenv-clickhouse
5353
```
5454

5555
This command:
56-
- Starts Clickhouse in a single-shard, single-replica cluster
56+
- Starts ClickHouse in a single-shard, single-replica cluster
5757
- Sets up Zookeeper
5858
- Runs the latest schema migrations
5959

60-
### 2. Starting the Backend
60+
### 2. Setting up SigNoz OpenTelemetry Collector
61+
62+
Next, start the OpenTelemetry Collector to receive telemetry data:
63+
64+
```bash
65+
make devenv-signoz-otel-collector
66+
```
67+
68+
This command:
69+
- Starts the SigNoz OpenTelemetry Collector
70+
- Listens on port 4317 (gRPC) and 4318 (HTTP) for incoming telemetry data
71+
- Forwards data to ClickHouse for storage
72+
73+
> 💡 **Quick Setup**: Use `make devenv-up` to start both ClickHouse and OTel Collector together
74+
75+
### 3. Starting the Backend
6176

6277
1. Run the backend server:
6378
```bash
@@ -73,7 +88,7 @@ This command:
7388

7489
> 💡 **Tip**: The API server runs at `http://localhost:8080/` by default
7590
76-
### 3. Setting up the Frontend
91+
### 4. Setting up the Frontend
7792

7893
1. Navigate to the frontend directory:
7994
```bash
@@ -98,3 +113,25 @@ This command:
98113
> 💡 **Tip**: `yarn dev` will automatically rebuild when you make changes to the code
99114
100115
Now you're all set to start developing! Happy coding! 🎉
116+
117+
## Verifying Your Setup
118+
To verify everything is working correctly:
119+
120+
1. **Check ClickHouse**: `curl http://localhost:8123/ping` (should return "Ok.")
121+
2. **Check OTel Collector**: `curl http://localhost:13133` (should return health status)
122+
3. **Check Backend**: `curl http://localhost:8080/api/v1/health` (should return `{"status":"ok"}`)
123+
4. **Check Frontend**: Open `http://localhost:3301` in your browser
124+
125+
## How to send test data?
126+
127+
You can now send telemetry data to your local SigNoz instance:
128+
129+
- **OTLP gRPC**: `localhost:4317`
130+
- **OTLP HTTP**: `localhost:4318`
131+
132+
For example, using `curl` to send a test trace:
133+
```bash
134+
curl -X POST http://localhost:4318/v1/traces \
135+
-H "Content-Type: application/json" \
136+
-d '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"test-service"}}]},"scopeSpans":[{"spans":[{"traceId":"12345678901234567890123456789012","spanId":"1234567890123456","name":"test-span","startTimeUnixNano":"1609459200000000000","endTimeUnixNano":"1609459201000000000"}]}]}]}'
137+
```

0 commit comments

Comments
 (0)