otel fixes

This commit is contained in:
2026-05-05 00:58:27 -04:00
parent 5a788af829
commit 0bad146c8d
+62 -10
View File
@@ -1,5 +1,6 @@
{ {
config, config,
pkgs,
... ...
}: }:
{ {
@@ -8,8 +9,17 @@
services.opentelemetry-collector = { services.opentelemetry-collector = {
enable = true; enable = true;
package = pkgs.opentelemetry-collector-contrib;
settings = { settings = {
receivers = { receivers = {
# Accept OTLP traces/metrics from local services and containers.
otlp = {
protocols = {
grpc.endpoint = "127.0.0.1:4317";
http.endpoint = "127.0.0.1:4318";
};
};
# Host-level system metrics # Host-level system metrics
hostmetrics = { hostmetrics = {
collection_interval = "60s"; collection_interval = "60s";
@@ -70,7 +80,26 @@
}; };
processors = { processors = {
batch = { }; memory_limiter = {
check_interval = "1s";
limit_percentage = 75;
spike_limit_percentage = 15;
};
batch = {
send_batch_size = 8192;
timeout = "5s";
};
attributes = {
actions = [
{
action = "upsert";
key = "deployment.environment";
value = "palatine-hill";
}
];
};
# Attach hostname using the standard resource processor # Attach hostname using the standard resource processor
resource = { resource = {
@@ -85,11 +114,21 @@
}; };
exporters = { exporters = {
"otlp/honeycomb" = { "otlp/honeycomb-metrics" = {
endpoint = "api.honeycomb.io:443"; endpoint = "api.honeycomb.io:443";
compression = "gzip";
headers = { headers = {
# Expanded at runtime from the environment file "x-honeycomb-team" = "\${file:" + config.sops.secrets."honeycomb/api-key".path + "}";
"x-honeycomb-team" = "\${HONEYCOMB_API_KEY}"; "x-honeycomb-dataset" = "palatine-hill-metrics";
};
};
"otlp/honeycomb-traces" = {
endpoint = "api.honeycomb.io:443";
compression = "gzip";
headers = {
"x-honeycomb-team" = "\${file:" + config.sops.secrets."honeycomb/api-key".path + "}";
"x-honeycomb-dataset" = "palatine-hill-traces";
}; };
}; };
}; };
@@ -98,25 +137,38 @@
pipelines = { pipelines = {
metrics = { metrics = {
receivers = [ receivers = [
"otlp"
"hostmetrics" "hostmetrics"
"prometheus" "prometheus"
]; ];
processors = [ processors = [
"memory_limiter"
"resource" "resource"
"attributes"
"batch" "batch"
]; ];
exporters = [ "otlp/honeycomb" ]; exporters = [ "otlp/honeycomb-metrics" ];
};
traces = {
receivers = [ "otlp" ];
processors = [
"memory_limiter"
"resource"
"attributes"
"batch"
];
exporters = [ "otlp/honeycomb-traces" ];
}; };
}; };
}; };
}; };
}; };
# Inject the Honeycomb API key at runtime — never stored in the Nix store
systemd.services.opentelemetry-collector.serviceConfig.EnvironmentFile =
config.sops.secrets."honeycomb/api-key".path;
sops.secrets = { sops.secrets = {
"honeycomb/api-key".owner = "root"; "honeycomb/api-key" = {
owner = "root";
restartUnits = [ "opentelemetry-collector.service" ];
};
}; };
} }