Skip to content

Commit 6ad773b

Browse files
committed
Calculate RED metrics from spans
1 parent c1b1b70 commit 6ad773b

File tree

1 file changed

+87
-12
lines changed

1 file changed

+87
-12
lines changed

config.alloy

Lines changed: 87 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,81 @@
1+
otelcol.receiver.otlp "default" {
2+
grpc { }
3+
4+
output {
5+
metrics = [
6+
otelcol.processor.transform.add_resource_attributes_as_metric_attributes.input,
7+
]
8+
traces = [
9+
// This transforms the traces in metrics, we still have to send traces out
10+
otelcol.connector.spanmetrics.asgi_apm.input,
11+
// This also transforms the traces in metrics, we still have to send traces out
12+
otelcol.connector.host_info.default.input,
13+
// This sends the traces out
14+
otelcol.processor.batch.default.input,
15+
]
16+
logs = [
17+
otelcol.processor.batch.default.input,
18+
]
19+
}
20+
}
21+
22+
otelcol.connector.host_info "default" {
23+
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.connector.host_info/
24+
host_identifiers = ["host.name"]
25+
26+
output {
27+
metrics = [otelcol.processor.batch.default.input]
28+
}
29+
}
30+
31+
otelcol.connector.spanmetrics "asgi_apm" {
32+
dimension {
33+
name = "http.status_code"
34+
}
35+
36+
dimension {
37+
name = "http.method"
38+
}
39+
40+
dimension {
41+
name = "http.route"
42+
}
43+
44+
histogram {
45+
explicit {
46+
buckets = ["2ms", "4ms", "6ms", "8ms", "10ms", "50ms", "100ms", "200ms", "400ms", "800ms", "1s", "1400ms", "2s", "5s", "10s", "15s"]
47+
}
48+
}
49+
50+
output {
51+
metrics = [otelcol.processor.transform.add_resource_attributes_as_metric_attributes.input]
52+
}
53+
}
54+
55+
otelcol.processor.transform "add_resource_attributes_as_metric_attributes" {
56+
error_mode = "ignore"
57+
58+
metric_statements {
59+
context = "datapoint"
60+
statements = [
61+
"set(attributes[\"deployment.environment\"], resource.attributes[\"deployment.environment\"])",
62+
"set(attributes[\"service.version\"], resource.attributes[\"service.version\"])",
63+
]
64+
}
65+
66+
output {
67+
metrics = [otelcol.processor.batch.default.input]
68+
}
69+
}
70+
71+
otelcol.processor.batch "default" {
72+
output {
73+
metrics = [otelcol.exporter.otlphttp.grafanacloud.input]
74+
logs = [otelcol.exporter.otlphttp.grafanacloud.input]
75+
traces = [otelcol.exporter.otlphttp.grafanacloud.input]
76+
}
77+
}
78+
179
otelcol.exporter.otlp "jaeger" {
280
client {
381
endpoint = "jaeger:4317"
@@ -12,18 +90,15 @@ otelcol.exporter.debug "console" {
1290
verbosity = "Detailed"
1391
}
1492

15-
otelcol.processor.batch "default" {
16-
output {
17-
traces = [otelcol.exporter.otlp.jaeger.input]
18-
}
19-
}
2093

21-
otelcol.receiver.otlp "default" {
22-
grpc { }
94+
otelcol.auth.basic "grafanacloud" {
95+
username = sys.env("GC_USERNAME")
96+
password = sys.env("GC_PASSWORD")
97+
}
2398

24-
output {
25-
metrics = [otelcol.exporter.debug.console.input]
26-
logs = [otelcol.exporter.debug.console.input]
27-
traces = [otelcol.processor.batch.default.input]
28-
}
99+
otelcol.exporter.otlphttp "grafanacloud" {
100+
client {
101+
endpoint = sys.env("GC_ENDPOINT")
102+
auth = otelcol.auth.basic.grafanacloud.handler
103+
}
29104
}

0 commit comments

Comments
 (0)