grafana: alloy and tempo now uses proper configurations

This commit is contained in:
Tigor Hutasuhut 2024-10-29 21:45:05 +07:00
parent abbc79066c
commit 828e7fe174
2 changed files with 38 additions and 7 deletions

View file

@ -8,6 +8,8 @@
let let
cfg = config.profile.services.telemetry.alloy; cfg = config.profile.services.telemetry.alloy;
webguiListenAddress = "0.0.0.0:5319"; webguiListenAddress = "0.0.0.0:5319";
otelcolHTTPListenAddress = "192.168.100.5:4318";
otelcolGRPCListenAddress = "192.168.100.5:4317";
domain = "alloy.tigor.web.id"; domain = "alloy.tigor.web.id";
in in
{ {
@ -32,6 +34,26 @@ in
reverse_proxy ${webguiListenAddress} reverse_proxy ${webguiListenAddress}
''; '';
services.caddy.virtualHosts."otelhttp.tigor.web.id".extraConfig = ''
@require_auth not remote_ip private_ranges
basic_auth @require_auth {
{$AUTH_USERNAME} {$AUTH_PASSWORD}
}
reverse_proxy ${otelcolHTTPListenAddress}
'';
services.caddy.virtualHosts."otelgrpc.tigor.web.id".extraConfig = ''
@require_auth not remote_ip private_ranges
basic_auth @require_auth {
{$AUTH_USERNAME} {$AUTH_PASSWORD}
}
reverse_proxy ${otelcolGRPCListenAddress}
'';
systemd.services.alloy.serviceConfig = { systemd.services.alloy.serviceConfig = {
User = "root"; User = "root";
}; };
@ -39,18 +61,18 @@ in
environment.etc."alloy/config.alloy".text = environment.etc."alloy/config.alloy".text =
let let
lokiConfig = config.services.loki.configuration; lokiConfig = config.services.loki.configuration;
tempoServer = config.services.tempo.settings.server; tempoProtocols = config.services.tempo.settings.distributor.receivers.otlp.protocols;
mimirServer = config.services.mimir.configuration.server; mimirServer = config.services.mimir.configuration.server;
in in
# hcl # hcl
'' ''
otelcol.receiver.otlp "homeserver" { otelcol.receiver.otlp "homeserver" {
grpc { grpc {
endpoint = "0.0.0.0:5317" endpoint = "${otelcolGRPCListenAddress}"
} }
http { http {
endpoint = "0.0.0.0:5318" endpoint = "${otelcolHTTPListenAddress}"
} }
output { output {
@ -133,7 +155,11 @@ in
otelcol.exporter.otlp "tempo" { otelcol.exporter.otlp "tempo" {
client { client {
endpoint = "${tempoServer.http_listen_address}:${toString tempoServer.http_listen_port}" endpoint = "${tempoProtocols.grpc.endpoint}"
tls {
insecure = true
insecure_skip_verify = true
}
} }
} }

View file

@ -17,11 +17,11 @@ in
reverse_proxy ${server.http_listen_address}:3200 reverse_proxy ${server.http_listen_address}:3200
''; '';
services.tempo = { services.tempo = rec {
enable = true; enable = true;
settings = { settings = {
server = { server = {
http_listen_address = "0.0.0.0"; http_listen_address = "192.168.100.3";
http_listen_port = 3200; http_listen_port = 3200;
grpc_listen_port = 9096; grpc_listen_port = 9096;
}; };
@ -29,7 +29,12 @@ in
receivers = { receivers = {
otlp = { otlp = {
protocols = { protocols = {
http = { }; http = {
endpoint = "${settings.server.http_listen_address}:4318";
};
grpc = {
endpoint = "${settings.server.http_listen_address}:4317";
};
}; };
}; };
}; };