@zyno-io/devtool-otel 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ Quick launch tool to launch a local Grafana LGTM environment for use in local development.
2
+
3
+ Startup: `npx @zyno-io/devtool-otel`\
4
+ Shutdown: `npx @zyno-io/devtool-otel down`
5
+
6
+ Exposes:
7
+ - Grafana at http://localhost:3200/explore
8
+ - gRPC OpenTelemetry collector at http://localhost:4317
9
+ - HTTP OpenTelemetry collector at http://localhost:4318
package/cli.mjs ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+
3
+ import which from "which";
4
+ import { execSync } from "child_process";
5
+ import { dirname } from "path";
6
+ import { fileURLToPath } from "url";
7
+
8
+ // exposed as import.meta.dirname in Node 20+
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+
11
+ const oldCompose = await which("docker-compose", { nothrow: true });
12
+ const composeCmd = oldCompose ? "docker-compose" : "docker compose";
13
+
14
+ const cmd = process.argv[2] ?? "up";
15
+
16
+ if (cmd === "up") {
17
+ await up();
18
+ } else if (cmd === "down") {
19
+ await down();
20
+ } else {
21
+ console.error(`Unknown command: ${cmd}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ async function up() {
26
+ await execSync(`${composeCmd} up -d`, {
27
+ cwd: __dirname + "/resources",
28
+ stdio: "inherit",
29
+ });
30
+
31
+ console.log(
32
+ `\nOpenTelemetry setup:\nexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318\n\nLoki push API:\nhttp://localhost:3100\n\nYou can now access Grafana at:\nhttp://localhost:3200/explore\n`
33
+ );
34
+ }
35
+
36
+ async function down() {
37
+ await execSync(`${composeCmd} down`, {
38
+ cwd: __dirname + "/resources",
39
+ stdio: "inherit",
40
+ });
41
+ }
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@zyno-io/devtool-otel",
3
+ "version": "0.0.7",
4
+ "description": "One-liner to start/stop local OpenTelemetry tools for development",
5
+ "main": "cli.mjs",
6
+ "bin": "./cli.mjs",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "author": {
11
+ "name": "Signal24 LLC dba Zyno Consulting",
12
+ "email": "support@zyno.io",
13
+ "url": "https://zyno.io"
14
+ },
15
+ "license": "MIT",
16
+ "dependencies": {
17
+ "which": "^6.0.1"
18
+ }
19
+ }
@@ -0,0 +1,72 @@
1
+ // OTLP Receivers
2
+ otelcol.receiver.otlp "receiver" {
3
+ debug_metrics {
4
+ disable_high_cardinality_metrics = true
5
+ }
6
+
7
+ grpc {
8
+ endpoint = "0.0.0.0:4317"
9
+ }
10
+
11
+ http {
12
+ endpoint = "0.0.0.0:4318"
13
+ cors {
14
+ allowed_origins = ["*"]
15
+ allowed_headers = ["*"]
16
+ }
17
+ }
18
+
19
+ output {
20
+ metrics = [otelcol.exporter.prometheus.metrics_converter.input]
21
+ traces = [otelcol.exporter.otlp.traces_service.input]
22
+ logs = [otelcol.exporter.loki.logs_service.input]
23
+ }
24
+ }
25
+
26
+ otelcol.exporter.prometheus "metrics_converter" {
27
+ forward_to = [prometheus.remote_write.metrics_service.receiver]
28
+ }
29
+
30
+ // Metrics Service
31
+ prometheus.remote_write "metrics_service" {
32
+ endpoint {
33
+ url = "http://mimir:9009/api/v1/push"
34
+ send_native_histograms = false
35
+ }
36
+
37
+ wal {
38
+ truncate_frequency = "2h"
39
+ min_keepalive_time = "5m"
40
+ max_keepalive_time = "8h"
41
+ }
42
+
43
+ external_labels = {
44
+ }
45
+ }
46
+
47
+ // Tempo
48
+ otelcol.exporter.otlp "traces_service" {
49
+ client {
50
+ endpoint = "tempo:4317"
51
+
52
+ tls {
53
+ insecure = true
54
+ }
55
+ }
56
+ }
57
+
58
+ // Loki
59
+ otelcol.exporter.loki "logs_service" {
60
+ forward_to = [loki.write.logs_service.receiver]
61
+ }
62
+
63
+ loki.write "logs_service" {
64
+ endpoint {
65
+ url = "http://loki:3100/loki/api/v1/push"
66
+ }
67
+ }
68
+
69
+ logging {
70
+ level = "info"
71
+ format = "logfmt"
72
+ }
@@ -0,0 +1,43 @@
1
+ services:
2
+ tempo:
3
+ image: grafana/tempo:latest
4
+ command: ["-config.file=/etc/tempo.yaml"]
5
+ volumes:
6
+ - ./tempo.yaml:/etc/tempo.yaml
7
+ ports:
8
+ - "4320:4318"
9
+
10
+ mimir:
11
+ image: grafana/mimir:latest
12
+ command: ["-config.file=/etc/mimir.yaml"]
13
+ volumes:
14
+ - ./mimir.yaml:/etc/mimir.yaml
15
+
16
+ loki:
17
+ image: grafana/loki:latest
18
+ command: ["-config.file=/etc/loki.yaml"]
19
+ volumes:
20
+ - ./loki.yaml:/etc/loki.yaml
21
+ ports:
22
+ - "4319:3100"
23
+
24
+ alloy:
25
+ image: grafana/alloy:latest
26
+ command: ["run", "/etc/alloy/config.alloy"]
27
+ volumes:
28
+ - ./config.alloy:/etc/alloy/config.alloy
29
+ ports:
30
+ - "4317:4317"
31
+ - "4318:4318"
32
+
33
+ grafana:
34
+ image: grafana/grafana:12.3.1
35
+ volumes:
36
+ - ./grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
37
+ environment:
38
+ - GF_AUTH_ANONYMOUS_ENABLED=true
39
+ - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
40
+ - GF_AUTH_DISABLE_LOGIN_FORM=true
41
+ - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor traceQLStreaming
42
+ ports:
43
+ - "4316:3000"
@@ -0,0 +1,35 @@
1
+ apiVersion: 1
2
+
3
+ datasources:
4
+ - name: Tempo
5
+ type: tempo
6
+ access: proxy
7
+ orgId: 1
8
+ url: http://tempo:3200
9
+ basicAuth: false
10
+ isDefault: true
11
+ version: 1
12
+ editable: false
13
+ apiVersion: 1
14
+ uid: tempo
15
+ jsonData:
16
+ httpMethod: GET
17
+ serviceMap:
18
+ datasourceUid: prometheus
19
+
20
+ - name: Loki
21
+ type: loki
22
+ access: proxy
23
+ orgId: 1
24
+ url: http://loki:3100
25
+ version: 1
26
+ editable: false
27
+ uid: loki
28
+
29
+ - name: Mimir
30
+ type: prometheus
31
+ access: proxy
32
+ orgId: 1
33
+ url: http://mimir:9009/prometheus
34
+ version: 1
35
+ editable: true
@@ -0,0 +1,30 @@
1
+ auth_enabled: false
2
+
3
+ server:
4
+ http_listen_port: 3100
5
+ log_level: error
6
+
7
+ common:
8
+ ring:
9
+ instance_addr: 127.0.0.1
10
+ kvstore:
11
+ store: inmemory
12
+ replication_factor: 1
13
+ path_prefix: /tmp/loki
14
+
15
+ schema_config:
16
+ configs:
17
+ - from: "2024-01-01"
18
+ store: tsdb
19
+ object_store: filesystem
20
+ schema: v13
21
+ index:
22
+ prefix: index_
23
+ period: 24h
24
+
25
+ storage_config:
26
+ filesystem:
27
+ directory: /tmp/loki/chunks
28
+
29
+ limits_config:
30
+ allow_structured_metadata: true
@@ -0,0 +1,42 @@
1
+ multitenancy_enabled: false
2
+
3
+ blocks_storage:
4
+ backend: filesystem
5
+ bucket_store:
6
+ sync_dir: /tmp/mimir/tsdb-sync
7
+ filesystem:
8
+ dir: /tmp/mimir/data/tsdb
9
+ tsdb:
10
+ dir: /tmp/mimir/tsdb
11
+
12
+ compactor:
13
+ data_dir: /tmp/mimir/compactor
14
+ sharding_ring:
15
+ kvstore:
16
+ store: memberlist
17
+
18
+ distributor:
19
+ ring:
20
+ instance_addr: 127.0.0.1
21
+ kvstore:
22
+ store: memberlist
23
+
24
+ ingester:
25
+ ring:
26
+ instance_addr: 127.0.0.1
27
+ kvstore:
28
+ store: memberlist
29
+ replication_factor: 1
30
+
31
+ ruler_storage:
32
+ backend: filesystem
33
+ filesystem:
34
+ dir: /tmp/mimir/rules
35
+
36
+ server:
37
+ http_listen_port: 9009
38
+ log_level: error
39
+
40
+ store_gateway:
41
+ sharding_ring:
42
+ replication_factor: 1
@@ -0,0 +1,38 @@
1
+ stream_over_http_enabled: true
2
+
3
+ server:
4
+ http_listen_port: 3200
5
+ log_level: info
6
+
7
+ query_frontend:
8
+ search:
9
+ duration_slo: 5s
10
+ throughput_bytes_slo: 1.073741824e+09
11
+ trace_by_id:
12
+ duration_slo: 5s
13
+
14
+ distributor:
15
+ receivers:
16
+ otlp:
17
+ protocols:
18
+ grpc:
19
+ endpoint: "0.0.0.0:4317"
20
+ http:
21
+ endpoint: "0.0.0.0:4318"
22
+
23
+ ingester:
24
+ flush_check_period: 5s
25
+ trace_idle_period: 5s
26
+ max_block_duration: 30s
27
+
28
+ compactor:
29
+ compaction:
30
+ block_retention: 24h
31
+
32
+ storage:
33
+ trace:
34
+ backend: local
35
+ wal:
36
+ path: /tmp/tempo/wal
37
+ local:
38
+ path: /tmp/tempo/blocks