Skip to content

Commit 3296303

Browse files
committed
feat(experimental): kick off inventory project
Track projects and their licenses Docker compose configuration for dev with logging tracing and metrics (mostly done) CRUD for mongo
1 parent f696fd4 commit 3296303

25 files changed

+9488
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: Loki
5+
type: loki
6+
uid: loki
7+
access: proxy
8+
url: http://loki:3100
9+
basicAuth: false
10+
version: 1
11+
editable: false
12+
isDefault: true
13+
14+
- name: Prometheus
15+
type: prometheus
16+
uid: prometheus
17+
access: proxy
18+
orgId: 1
19+
url: http://prometheus:9090
20+
basicAuth: false
21+
isDefault: false
22+
version: 1
23+
editable: false
24+
jsonData:
25+
httpMethod: GET
26+
27+
- name: Tempo
28+
type: tempo
29+
uid: tempo
30+
access: proxy
31+
orgId: 1
32+
url: http://tempo:3200
33+
basicAuth: false
34+
isDefault: false
35+
version: 1
36+
editable: false
37+
jsonData:
38+
tracesToLogsV2:
39+
datasourceUid: loki
40+
filterByTraceID: true
41+
filterBySpanID: true
42+
tracesToMetrics:
43+
datasourceUid: prometheus
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
auth_enabled: false
2+
3+
server:
4+
http_listen_port: 3100
5+
grpc_listen_port: 9096
6+
7+
common:
8+
instance_addr: 127.0.0.1
9+
path_prefix: /tmp/loki
10+
storage:
11+
filesystem:
12+
chunks_directory: /tmp/loki/chunks
13+
rules_directory: /tmp/loki/rules
14+
replication_factor: 1
15+
ring:
16+
kvstore:
17+
store: inmemory
18+
19+
frontend:
20+
max_outstanding_per_tenant: 2048
21+
22+
pattern_ingester:
23+
enabled: true
24+
25+
limits_config:
26+
max_global_streams_per_user: 0
27+
ingestion_rate_mb: 50000
28+
ingestion_burst_size_mb: 50000
29+
volume_enabled: true
30+
31+
query_range:
32+
results_cache:
33+
cache:
34+
embedded_cache:
35+
enabled: true
36+
max_size_mb: 100
37+
38+
schema_config:
39+
configs:
40+
- from: 2020-10-24
41+
store: tsdb
42+
object_store: filesystem
43+
schema: v13
44+
index:
45+
prefix: index_
46+
period: 24h
47+
48+
analytics:
49+
reporting_enabled: false
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
extensions:
2+
health_check:
3+
pprof:
4+
endpoint: 127.0.0.1:1777
5+
zpages:
6+
endpoint: 127.0.0.1:55679
7+
8+
receivers:
9+
otlp:
10+
protocols:
11+
http:
12+
endpoint: 0.0.0.0:4318
13+
14+
# collect own metrics
15+
prometheus:
16+
config:
17+
scrape_configs:
18+
- job_name: otel-collector
19+
scrape_interval: 10s
20+
static_configs:
21+
- targets:
22+
- 127.0.0.1:8888
23+
24+
exporters:
25+
loki:
26+
endpoint: http://loki:3100/loki/api/v1/push
27+
prometheus:
28+
endpoint: 127.0.0.1:8889
29+
namespace: otel-collector
30+
send_timestamps: true
31+
metric_expiration: 180m
32+
enable_open_metrics: true
33+
add_metric_suffixes: false
34+
resource_to_telemetry_conversion:
35+
enabled: true
36+
otlphttp:
37+
endpoint: http://tempo:4318
38+
39+
processors:
40+
batch:
41+
42+
service:
43+
pipelines:
44+
traces:
45+
receivers: [otlp]
46+
exporters: [otlphttp]
47+
metrics:
48+
receivers: [otlp]
49+
exporters: [prometheus]
50+
logs:
51+
receivers: [otlp]
52+
exporters: [loki]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
global:
2+
scrape_interval: 15s
3+
evaluation_interval: 15s
4+
5+
scrape_configs:
6+
- job_name: prometheus
7+
static_configs:
8+
- targets: [ 'localhost:9090' ]
9+
- job_name: tempo
10+
static_configs:
11+
- targets: [ 'tempo:3200' ]
12+
- job_name: promtail
13+
static_configs:
14+
- targets: [ 'promtail:9080' ]
15+
- job_name: otel-collector
16+
static_configs:
17+
- targets: [ 'otel-collector:8889' ]
18+
- job_name: otel-collector-meta
19+
static_configs:
20+
- targets: [ 'otel-collector:8888' ]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
positions:
2+
filename: /tmp/positions.yaml
3+
4+
clients:
5+
- url: http://loki:3100/loki/api/v1/push
6+
7+
scrape_configs:
8+
- job_name: system
9+
static_configs:
10+
- targets:
11+
- localhost
12+
labels:
13+
job: mongo
14+
__path__: /var/log-mongo/mongo.log*
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
stream_over_http_enabled: true
2+
server:
3+
http_listen_port: 3200
4+
5+
distributor:
6+
receivers:
7+
otlp:
8+
protocols:
9+
http:
10+
11+
compactor:
12+
compaction:
13+
block_retention: 1h
14+
15+
metrics_generator:
16+
registry:
17+
external_labels:
18+
source: tempo
19+
cluster: docker-compose
20+
storage:
21+
path: /var/tempo/generator/wal
22+
remote_write:
23+
- url: http://prometheus:9090/api/v1/write
24+
send_exemplars: true
25+
traces_storage:
26+
path: /var/tempo/generator/traces
27+
28+
storage:
29+
trace:
30+
backend: local
31+
wal:
32+
path: /var/tempo/wal
33+
local:
34+
path: /var/tempo/blocks
35+
36+
overrides:
37+
defaults:
38+
metrics_generator:
39+
processors: [service-graphs, span-metrics, local-blocks]
40+
generate_native_histograms: both
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
services:
2+
init:
3+
image: alpine:3.20
4+
init: true
5+
volumes:
6+
- mongo-logs:/var/log-mongo
7+
- tempo-data:/var/tempo
8+
command: >
9+
chmod 777 /var/log-mongo && chown -R 10001:10001 /var/tempo
10+
11+
app:
12+
container_name: license-inventory
13+
image: node:23-alpine
14+
# ensure colours show
15+
tty: true
16+
command: >
17+
sh -c "npm install --include=optional && npm run dev"
18+
environment:
19+
MONGO_URI: mongodb://mongo:27017/inventory
20+
OTEL_TRACES_EXPORTER: otlp
21+
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
22+
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
23+
OTEL_SERVICE_NAME: license-inventory
24+
OTEL_RESOURCE_ATTRIBUTES: service.version=0.0.0
25+
NODE_OPTIONS: --require @opentelemetry/auto-instrumentations-node/register
26+
ports:
27+
- 3000:3000
28+
working_dir: /usr/src/app
29+
volumes:
30+
- .:/usr/src/app
31+
# have a separate node dependencies
32+
# avoids permissions conflicts
33+
- node-deps:/usr/src/app/node_modules
34+
depends_on:
35+
- mongo
36+
- otel-collector
37+
38+
mongo:
39+
image: mongo:8.0.3
40+
command: --logpath=/var/log/mongo.log
41+
ports:
42+
- 27017:27017
43+
volumes:
44+
- mongo-data:/data/db
45+
- mongo-logs:/var/log
46+
depends_on:
47+
- init
48+
49+
otel-collector:
50+
image: otel/opentelemetry-collector-contrib:0.114.0
51+
volumes:
52+
- ./dev/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
53+
depends_on:
54+
- loki
55+
- tempo
56+
57+
promtail:
58+
image: grafana/promtail:3.3.0
59+
command:
60+
- -config.file=/etc/promtail/config.yaml
61+
- -log.level=warn
62+
volumes:
63+
- ./dev/promtail.yaml:/etc/promtail/config.yaml
64+
- mongo-logs:/var/log-mongo
65+
depends_on:
66+
- loki
67+
68+
# traces
69+
tempo:
70+
image: grafana/tempo:2.6.1
71+
command:
72+
- -config.file=/etc/tempo.yaml
73+
- -log.level=warn
74+
volumes:
75+
- ./dev/tempo.yaml:/etc/tempo.yaml
76+
- tempo-data:/var/tempo
77+
depends_on:
78+
- init
79+
- prometheus
80+
81+
# metrics
82+
prometheus:
83+
image: prom/prometheus:v3.0.0
84+
command:
85+
- --config.file=/etc/prometheus.yaml
86+
- --enable-feature=exemplar-storage
87+
- --enable-feature=native-histograms
88+
- --web.enable-remote-write-receiver
89+
- --enable-feature=otlp-write-receive
90+
- --web.enable-otlp-receiver
91+
- --log.level=warn
92+
volumes:
93+
- ./dev/prometheus.yaml:/etc/prometheus.yaml
94+
ports:
95+
- 9090:9090
96+
97+
# logs
98+
loki:
99+
image: grafana/loki:3.3.0
100+
command:
101+
- -config.file=/etc/loki/loki.yaml
102+
- -log.level=warn
103+
ports:
104+
- 3100:3100
105+
volumes:
106+
- ./dev/loki.yaml:/etc/loki/loki.yaml
107+
108+
# everything dashboard
109+
grafana:
110+
image: grafana/grafana:11.3.1
111+
ports:
112+
- 3001:3000
113+
volumes:
114+
- ./dev/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
115+
environment:
116+
- GF_AUTH_ANONYMOUS_ENABLED=true
117+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
118+
- GF_AUTH_DISABLE_LOGIN_FORM=true
119+
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor metricsSummary
120+
- GF_INSTALL_PLUGINS=grafana-lokiexplore-app,grafana-exploretraces-app
121+
# seem to get auth warnings even though we're on anonymous auth
122+
- GF_LOG_LEVEL=error
123+
depends_on:
124+
- loki
125+
- tempo
126+
- prometheus
127+
128+
volumes:
129+
mongo-logs:
130+
mongo-data:
131+
tempo-data:
132+
node-deps:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
5+
6+
/** @type {import('eslint').Linter.Config[]} */
7+
export default [
8+
{files: ["**/*.{js,mjs,cjs,ts}"]},
9+
{languageOptions: { globals: globals.node }},
10+
pluginJs.configs.recommended,
11+
...tseslint.configs.recommended,
12+
];
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"watch": ["src", ".env"],
3+
"ext": "js,ts,json",
4+
"ignore": ["src/**/*.{spec,test}.ts"],
5+
"exec": "ts-node -r tsconfig-paths/register --transpile-only src/server.ts | pino-pretty"
6+
}

0 commit comments

Comments
 (0)