diff --git a/kas-pypcc-rpi.yml b/kas-pypcc-rpi.yml index b942a3cae7907ad6f55750dae3e8925e5a3756e3..8338f428c1326e263a23cb6c397f98ef2b1249c4 100644 --- a/kas-pypcc-rpi.yml +++ b/kas-pypcc-rpi.yml @@ -86,7 +86,7 @@ local_conf_header: DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit" VIRTUAL-RUNTIME_init_manager = "systemd" VIRTUAL-RUNTIME_initscripts = "systemd-compat-units" - IMAGE_INSTALL:append = "consul-exporter node-exporter chrony-exporter ntp python3-pypcc python3-halibut-py vcgencmd dtc i2c-tools swupdate swupdate-www libgpiod libgpiod-tools libgpiod-dev kernel-module-i2c-gpio" + IMAGE_INSTALL:append = "alloy consul-exporter node-exporter chrony-exporter ntp python3-pypcc python3-halibut-py vcgencmd dtc i2c-tools swupdate swupdate-www libgpiod libgpiod-tools libgpiod-dev kernel-module-i2c-gpio" IMAGE_FSTYPES = "tar.bz2 ext4 ext4.gz wic.bz2 wic.bmap" SWUPDATE_IMAGES_FSTYPES[core-image-full-cmdline] = ".ubifs" IMAGE_BOOT_FILES:append = "halibut.dtbo;overlays/halibut.dtbo" diff --git a/recipes/alloy_1.9.2.bb b/recipes/alloy_1.9.2.bb new file mode 100644 index 0000000000000000000000000000000000000000..4c696aaf3097fa333bf688fc9f1bfc852e3261d7 --- /dev/null +++ b/recipes/alloy_1.9.2.bb @@ -0,0 +1,49 @@ +SUMMARY = "Open source OpenTelemetry Collector distribution with built-in Prometheus pipelines and support for metrics, logs, traces, and profiles." +HOMEPAGE = "https://github.com/grafana/alloy" + +DEPENDS += "systemd" +RDEPENDS_${PN} = "systemd" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://${S}/../LICENSE;md5=650b869bd8ff2aed59c62bad2a22a821" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" +SRC_URI = " \ + https://github.com/grafana/alloy/releases/download/v1.9.2/alloy-linux-arm64.zip;name=binary \ + https://raw.githubusercontent.com/grafana/alloy/refs/tags/v1.9.2/LICENSE;name=license \ + file://files/alloy.service \ + file://files/alloy.sysconfig \ + file://files/config.alloy \ +" + +SRC_URI[binary.sha256sum] = "235eca6f86bdf3ed0f8ad6d8385c81e029494d7cd375f59668560198499b66ff" +SRC_URI[license.sha256sum] = "7c34d28e784b202aa4998f477fd0aa9773146952d7f6fa5971369fcdda59cf48" + +FILES:${PN} += "\ + ${systemd_unitdir}/system/alloy.service \ + ${systemd_unitdir}/system/multi-user.target.wants/alloy.service \ + ${sysconfdir}/sysconfig/alloy \ + ${sysconfdir}/alloy/config.alloy \ +" + +inherit systemd useradd + +USERADD_PACKAGES = "${PN}" +USERADD_PARAM:${PN} = "--system --no-create-home --user-group --groups adm,systemd-journal --home-dir ${sysconfdir}/${BPN}-1 --shell /bin/nologin alloy" + +SYSTEMD_SERVICE:${PN} = "\ + alloy.service \ +" + +INSANE_SKIP:${PN} += "already-stripped" + +do_install() { + install -Dm755 ${S}/../alloy-linux-arm64 ${D}${bindir}/alloy + + install -Dm644 ${WORKDIR}/files/alloy.service ${D}${systemd_unitdir}/system/alloy.service + + install -Dm644 ${WORKDIR}/files/alloy.sysconfig ${D}${sysconfdir}/sysconfig/alloy + install -Dm644 ${WORKDIR}/files/config.alloy ${D}${sysconfdir}/alloy + + install -d -o alloy ${D}${localstatedir}/lib/alloy/data +} diff --git a/recipes/files/alloy.service b/recipes/files/alloy.service new file mode 100644 index 0000000000000000000000000000000000000000..24151ce08867d5f4f5075675fc46f5ebf989c0af --- /dev/null +++ b/recipes/files/alloy.service @@ -0,0 +1,20 @@ +[Unit] +Description= Vendor-agnostic OpenTelemetry Collector distribution with programmable pipelines +Documentation=https://grafana.com/docs/alloy +Wants=network-online.target +After=network-online.target + +[Service] +Restart=always +User=alloy +Environment=HOSTNAME=%H +#Environment=ALLOY_DEPLOY_MODE=deb +EnvironmentFile=/etc/sysconfig/alloy +WorkingDirectory=/var/lib/alloy +ExecStart=/usr/bin/alloy run $CUSTOM_ARGS --storage.path=/var/lib/alloy/data $CONFIG_FILE +ExecReload=/usr/bin/env kill -HUP $MAINPID +TimeoutStopSec=20s +SendSIGKILL=no + +[Install] +WantedBy=multi-user.target diff --git a/recipes/files/alloy.sysconfig b/recipes/files/alloy.sysconfig new file mode 100644 index 0000000000000000000000000000000000000000..3e453117e1bac75864af1cff6d2532bce924937b --- /dev/null +++ b/recipes/files/alloy.sysconfig @@ -0,0 +1 @@ +CONFIG_FILE=/etc/alloy/config.alloy diff --git a/recipes/files/config.alloy b/recipes/files/config.alloy new file mode 100644 index 0000000000000000000000000000000000000000..78f5f4b19ef3882f0a923a1e883f4c13376944a3 --- /dev/null +++ b/recipes/files/config.alloy @@ -0,0 +1,52 @@ +# see also https://grafana.com/docs/alloy/latest/tutorials/send-logs-to-loki/ + +loki.relabel "journal" { + forward_to = [] + + rule { + source_labels = ["__journal_priority"] + target_label = "level" + } + rule { + source_labels = ["__journal__hostname"] + target_label = "hostname" + } + rule { + source_labels = ["__journal__comm"] + target_label = "comm" + } + rule { + source_labels = ["__journal__systemd_unit"] + target_label = "systemd_unit" + } + rule { + source_labels = ["__journal_unit"] + target_label = "unit" + } +} + +loki.source.journal "journal_scrape" { + forward_to = [loki.process.filter_logs.receiver] + relabel_rules = loki.relabel.journal.rules +} + +loki.process "filter_logs" { + stage.drop { + source = "systemd_unit,unit" + expression = "serial-getty@ttyS0.service" + drop_counter_reason = "ignore ttyS0 errors" + } + forward_to = [loki.write.lcu_loki.receiver, loki.write.central_loki.receiver] +} + +loki.write "lcu_loki" { + endpoint { + url = "http://loki.service.consul:3100/loki/api/v1/push" + } +} + +loki.write "central_loki" { + endpoint { + url = "http://logs.service.lofar-central.consul:3100/loki/api/v1/push" + } +}