chore: some cleaning + logging implementation
This commit is contained in:
15
lib/config/alloy/config.alloy.nix
Normal file
15
lib/config/alloy/config.alloy.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
let
|
||||
infra = import ../../constants.nix;
|
||||
in
|
||||
{
|
||||
out = ''
|
||||
logging {
|
||||
level = "warning"
|
||||
}
|
||||
loki.write "grafana_loki" {
|
||||
endpoint {
|
||||
url = "http://${infra.loki_addr}/loki/api/v1/push"
|
||||
}
|
||||
}
|
||||
'';
|
||||
}
|
||||
47
lib/config/alloy/metrics.alloy.nix
Normal file
47
lib/config/alloy/metrics.alloy.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
{ container_id, ... }:
|
||||
let
|
||||
infra = import ../../constants.nix;
|
||||
in
|
||||
{
|
||||
out = ''
|
||||
prometheus.exporter.unix "default" {
|
||||
include_exporter_metrics = true
|
||||
disable_collectors = ["mdadm"]
|
||||
}
|
||||
|
||||
prometheus.scrape "default" {
|
||||
targets = array.concat(
|
||||
prometheus.exporter.unix.default.targets,
|
||||
[{
|
||||
// Self-collect metrics
|
||||
job = "alloy",
|
||||
__address__ = "127.0.0.1:12345",
|
||||
}],
|
||||
)
|
||||
|
||||
forward_to = [prometheus.relabel.filter_metrics.receiver]
|
||||
scrape_interval = "60s"
|
||||
}
|
||||
|
||||
prometheus.relabel "filter_metrics" {
|
||||
rule {
|
||||
action = "drop"
|
||||
source_labels = [ "env" ]
|
||||
regex = "dev"
|
||||
}
|
||||
rule {
|
||||
action = "replace"
|
||||
regex = "127\\.0\\.0\\.1"
|
||||
target_label = "instance"
|
||||
replacement = "${infra.build_ip container_id}"
|
||||
}
|
||||
forward_to = [prometheus.remote_write.metrics_service.receiver]
|
||||
}
|
||||
|
||||
prometheus.remote_write "metrics_service" {
|
||||
endpoint {
|
||||
url = "http://${infra.prometheus_addr}/api/v1/write"
|
||||
}
|
||||
}
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user