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 github.com/grafana/loki/pkg/build.Branch= -X github.com/grafana/loki/pkg/build.Version= -X github.com/grafana/loki/pkg/build.Revision= -X github.com/grafana/loki/pkg/build.BuildUser=root@3618c4eb3a99 -X github.com/grafana/loki/pkg/build.BuildDate=2021-07-01T13:30:12Z" -tags netgo -mod=vendor -o cmd/promtail/promtail ./cmd/promtail
# github.com/coreos/go-systemd/sdjournal
vendor/github.com/coreos/go-systemd/sdjournal/journal.go:27:11: 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