Build promtail without systemd support

I’d like to build promtail on alpine, which has no systemd. Loki builds fine, but promtail complains:

CGO_ENABLED=1 go build -ldflags "-s -w -X -X -X -X -X" -tags netgo -mod=vendor -o cmd/promtail/promtail ./cmd/promtail
vendor/ fatal error: systemd/sd-journal.h: No such file or directory
   27 | // #include <systemd/sd-journal.h>
      |           ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

How do I build promtail without systemd support? I don’t need it on alpine.

Thanks for any help with this :wink:

Hi @gruelingmonorail . May I know what your use case exactly?

Promtail fails because it has target manager to scrape logs from Systemd-journel.

I see, it has build tags +build linux, cgo. I’m not an expert in CGO, but have to tried to build without CGO? (may be CGO_ENABLED=0)

My use case is compiling and running it on Alpine Linux (which has no systemd, so there is no way to scrape journald on it anyway).
Thanks, I’ll look into those build tags and try whether I can change them.

This should be relevant to all distributions that don’t have journald. It would be great if promtail could be used on those distros too…

this seems to be the “problem”. maybe it can be solved :wink: Support building promtail without systemd/journald support (disabling cgo) · Issue #3933 · grafana/loki · GitHub

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.