Skip to content

Commit

Permalink
feat: update alloy configs
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjydev committed Jun 19, 2024
1 parent 7f5d6af commit d53ea4c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 30 deletions.
13 changes: 3 additions & 10 deletions modules/mixins/alloy-forwarder/config.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,12 @@ loki.source.api "receive" {
listen_address = "0.0.0.0"
listen_port = 3100
}
forward_to = [
grafana_cloud.stack.receivers.logs,
]
forward_to = [grafana_cloud.stack.receivers.logs]
}

loki.source.journal "read" {
forward_to = [
grafana_cloud.stack.receivers.logs,
]
relabel_rules = concat(
loki.relabel.journal.rules,
loki.relabel.instance.rules,
)
forward_to = [grafana_cloud.stack.receivers.logs]
relabel_rules = loki.relabel.omnibus.rules
labels = {
"job" = "integrations/node_exporter",
}
Expand Down
9 changes: 2 additions & 7 deletions modules/mixins/alloy/base.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ local.file "hostname" {
filename = "/etc/hostname"
}

// Set hostname from /etc
loki.relabel "instance" {
// Loki journal relabeller
loki.relabel "omnibus" {
forward_to = []

rule {
target_label = "instance"
replacement = local.file.hostname.content
}
}

// Loki journal relabeller
loki.relabel "journal" {
forward_to = []

rule {
source_labels = ["__journal__systemd_unit"]
Expand Down
18 changes: 9 additions & 9 deletions modules/mixins/alloy/config.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@ loki.relabel "journal" {
forward_to = []

rule {
source_labels = ["__journal__systemd_unit"]
target_label = "unit"
target_label = "instance"
replacement = local.file.hostname.content
}

rule {
source_labels = ["__journal_container_name"]
target_label = "container_name"
source_labels = ["__journal__systemd_unit"]
target_label = "unit"
}

rule {
source_labels = ["__journal_image_name"]
target_label = "container_image"
source_labels = ["__journal__boot_id"]
target_label = "boot_id"
}

rule {
source_labels = ["__journal_container_id"]
target_label = "container_id"
source_labels = ["__journal__transport"]
target_label = "transport"
}
}

// Fetch journal entries
loki.source.journal "journal" {
forward_to = [otelcol.receiver.loki.default.receiver]
relabel_rules = loki.relabel.journal.rules
relabel_rules = loki.relabel.omnibus.rules
labels = {component = "loki.source.journal"}
}

Expand Down
5 changes: 1 addition & 4 deletions modules/mixins/ecs-agent/config.alloy
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
prometheus.scrape "ecs_agent" {
targets = [
{"__address__" = "127.0.0.1:51680", instance = env("HOSTNAME")},
]

targets = [{"__address__" = "127.0.0.1:51680"}]
forward_to = [prometheus.relabel.instance.receiver]
scrape_interval = "30s"
}
Expand Down

0 comments on commit d53ea4c

Please sign in to comment.