2026-05-03 12:34:42 -04:00
|
|
|
{
|
|
|
|
|
config,
|
2026-05-05 00:58:27 -04:00
|
|
|
pkgs,
|
2026-05-03 12:34:42 -04:00
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
{
|
|
|
|
|
# node_exporter (port 9002) and Prometheus (port 9001) are already configured
|
|
|
|
|
# in hydra.nix — we just scrape the existing exporter here.
|
|
|
|
|
|
|
|
|
|
services.opentelemetry-collector = {
|
|
|
|
|
enable = true;
|
2026-05-05 00:58:27 -04:00
|
|
|
package = pkgs.opentelemetry-collector-contrib;
|
2026-05-03 12:34:42 -04:00
|
|
|
settings = {
|
|
|
|
|
receivers = {
|
2026-05-05 00:58:27 -04:00
|
|
|
# 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";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-03 12:34:42 -04:00
|
|
|
# Host-level system metrics
|
|
|
|
|
hostmetrics = {
|
|
|
|
|
collection_interval = "60s";
|
|
|
|
|
scrapers = {
|
|
|
|
|
cpu = { };
|
|
|
|
|
memory = { };
|
|
|
|
|
disk = { };
|
|
|
|
|
filesystem = { };
|
|
|
|
|
network = { };
|
|
|
|
|
load = { };
|
|
|
|
|
processes = { };
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Scrape node_exporter for per-systemd-unit service state
|
|
|
|
|
prometheus = {
|
|
|
|
|
config = {
|
|
|
|
|
scrape_configs = [
|
|
|
|
|
{
|
|
|
|
|
job_name = "node-exporter";
|
|
|
|
|
scrape_interval = "60s";
|
|
|
|
|
static_configs = [
|
|
|
|
|
{
|
|
|
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
|
|
|
|
|
labels = {
|
|
|
|
|
host = "palatine-hill";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
job_name = "postgres-exporter";
|
|
|
|
|
scrape_interval = "60s";
|
|
|
|
|
static_configs = [
|
|
|
|
|
{
|
|
|
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.postgres.port}" ];
|
|
|
|
|
labels = {
|
|
|
|
|
host = "palatine-hill";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
job_name = "zfs-exporter";
|
|
|
|
|
scrape_interval = "60s";
|
|
|
|
|
static_configs = [
|
|
|
|
|
{
|
|
|
|
|
targets = [ "localhost:${toString config.services.prometheus.exporters.zfs.port}" ];
|
|
|
|
|
labels = {
|
|
|
|
|
host = "palatine-hill";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processors = {
|
2026-05-05 00:58:27 -04:00
|
|
|
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";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
2026-05-03 12:34:42 -04:00
|
|
|
|
2026-05-05 00:36:35 -04:00
|
|
|
# Attach hostname using the standard resource processor
|
|
|
|
|
resource = {
|
|
|
|
|
attributes = [
|
|
|
|
|
{
|
|
|
|
|
action = "upsert";
|
|
|
|
|
key = "host.name";
|
|
|
|
|
value = "palatine-hill";
|
|
|
|
|
}
|
|
|
|
|
];
|
2026-05-03 12:34:42 -04:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exporters = {
|
2026-05-05 00:58:27 -04:00
|
|
|
"otlp/honeycomb-metrics" = {
|
2026-05-03 12:34:42 -04:00
|
|
|
endpoint = "api.honeycomb.io:443";
|
2026-05-05 00:58:27 -04:00
|
|
|
compression = "gzip";
|
2026-05-03 12:34:42 -04:00
|
|
|
headers = {
|
2026-05-05 00:58:27 -04:00
|
|
|
"x-honeycomb-team" = "\${file:" + config.sops.secrets."honeycomb/api-key".path + "}";
|
|
|
|
|
"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";
|
2026-05-03 12:34:42 -04:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
service = {
|
|
|
|
|
pipelines = {
|
|
|
|
|
metrics = {
|
|
|
|
|
receivers = [
|
2026-05-05 00:58:27 -04:00
|
|
|
"otlp"
|
2026-05-03 12:34:42 -04:00
|
|
|
"hostmetrics"
|
|
|
|
|
"prometheus"
|
|
|
|
|
];
|
|
|
|
|
processors = [
|
2026-05-05 00:58:27 -04:00
|
|
|
"memory_limiter"
|
2026-05-05 00:36:35 -04:00
|
|
|
"resource"
|
2026-05-05 00:58:27 -04:00
|
|
|
"attributes"
|
2026-05-03 12:34:42 -04:00
|
|
|
"batch"
|
|
|
|
|
];
|
2026-05-05 00:58:27 -04:00
|
|
|
exporters = [ "otlp/honeycomb-metrics" ];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
traces = {
|
|
|
|
|
receivers = [ "otlp" ];
|
|
|
|
|
processors = [
|
|
|
|
|
"memory_limiter"
|
|
|
|
|
"resource"
|
|
|
|
|
"attributes"
|
|
|
|
|
"batch"
|
|
|
|
|
];
|
|
|
|
|
exporters = [ "otlp/honeycomb-traces" ];
|
2026-05-03 12:34:42 -04:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sops.secrets = {
|
2026-05-05 00:58:27 -04:00
|
|
|
"honeycomb/api-key" = {
|
|
|
|
|
owner = "root";
|
|
|
|
|
restartUnits = [ "opentelemetry-collector.service" ];
|
|
|
|
|
};
|
2026-05-03 12:34:42 -04:00
|
|
|
};
|
|
|
|
|
}
|