From 183520a203b0ac9f2606ed56077dfc27b89b3e5a Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Mon, 25 Mar 2024 12:45:20 -0400 Subject: [PATCH] misc: rename binaries to Alloy This also removes the `grafana-` prefix where present, so that `grafana-agent` becomes `alloy`. The `grafana-` prefix was originally added due to the ambiguity of the term "agent," but as Alloy is a much more unique identity the prefix is no longer needed and is removed for the sake of brevity. --- .drone/drone.yml | 56 ++--- .drone/pipelines/check_containers.jsonnet | 4 +- .drone/pipelines/crosscompile.jsonnet | 2 +- .drone/pipelines/publish.jsonnet | 10 +- .drone/pipelines/test_packages.jsonnet | 2 +- .github/workflows/check_docs.yml | 4 +- .../publish-documentation-next.yml.disabled | 8 +- ...blish-documentation-versioned.yml.disabled | 8 +- .github/workflows/trivy.yml | 4 +- .github/workflows/update-make-docs.yml | 2 +- Makefile | 54 ++--- build-image/Dockerfile | 1 - .../config_windows.go | 20 +- cmd/alloy-service/doc.go | 3 + .../logger_windows.go | 0 .../main_windows.go | 8 +- .../service.go | 0 .../service_test.go | 0 .../testdata/example_service.go | 0 cmd/{grafana-agent => alloy}/Dockerfile | 32 +-- .../Dockerfile.windows | 18 +- .../example-config.river | 0 cmd/{grafana-agent => alloy}/main.go | 0 cmd/grafana-agent-service/doc.go | 3 - docs/developer/contributing.md | 12 +- internal/cmd/integration-tests/README.md | 6 +- internal/cmd/integration-tests/main.go | 4 +- internal/cmd/integration-tests/utils.go | 24 +- .../agent_linux_packages_test.go | 10 +- .../grafana-agent.river => alloy/alloy.river} | 6 +- packaging/alloy/deb/alloy.service | 20 ++ packaging/alloy/deb/control/postinst | 41 ++++ .../deb/control/prerm | 4 +- packaging/alloy/environment-file | 16 ++ packaging/alloy/rpm/alloy.service | 20 ++ packaging/alloy/rpm/control/postinst | 45 ++++ packaging/alloy/rpm/control/prerm | 20 ++ .../{grafana-agent => alloy}/rpm/gpg-sign.sh | 0 .../windows/config.river | 0 .../windows/install_script.nsis | 28 +-- .../{grafana-agent => alloy}/windows/logo.ico | Bin .../windows/macros.nsis | 0 packaging/grafana-agent/deb/control/postinst | 41 ---- .../grafana-agent/deb/grafana-agent.service | 20 -- packaging/grafana-agent/environment-file | 16 -- packaging/grafana-agent/rpm/control/postinst | 49 ---- packaging/grafana-agent/rpm/control/prerm | 20 -- .../grafana-agent/rpm/grafana-agent.service | 20 -- tools/ci/docker-containers | 20 +- tools/ci/docker-containers-windows | 42 ++-- tools/make/build-container.mk | 4 +- tools/make/packaging.mk | 214 +++++++++--------- 52 files changed, 460 insertions(+), 481 deletions(-) rename cmd/{grafana-agent-service => alloy-service}/config_windows.go (70%) create mode 100644 cmd/alloy-service/doc.go rename cmd/{grafana-agent-service => alloy-service}/logger_windows.go (100%) rename cmd/{grafana-agent-service => alloy-service}/main_windows.go (92%) rename cmd/{grafana-agent-service => alloy-service}/service.go (100%) rename cmd/{grafana-agent-service => alloy-service}/service_test.go (100%) rename cmd/{grafana-agent-service => alloy-service}/testdata/example_service.go (100%) rename cmd/{grafana-agent => alloy}/Dockerfile (62%) rename cmd/{grafana-agent => alloy}/Dockerfile.windows (57%) rename cmd/{grafana-agent => alloy}/example-config.river (100%) rename cmd/{grafana-agent => alloy}/main.go (100%) delete mode 100644 cmd/grafana-agent-service/doc.go rename packaging/{grafana-agent/grafana-agent.river => alloy/alloy.river} (87%) create mode 100644 packaging/alloy/deb/alloy.service create mode 100644 packaging/alloy/deb/control/postinst rename packaging/{grafana-agent => alloy}/deb/control/prerm (50%) create mode 100644 packaging/alloy/environment-file create mode 100644 packaging/alloy/rpm/alloy.service create mode 100644 packaging/alloy/rpm/control/postinst create mode 100644 packaging/alloy/rpm/control/prerm rename packaging/{grafana-agent => alloy}/rpm/gpg-sign.sh (100%) rename packaging/{grafana-agent => alloy}/windows/config.river (100%) rename packaging/{grafana-agent => alloy}/windows/install_script.nsis (88%) rename packaging/{grafana-agent => alloy}/windows/logo.ico (100%) rename packaging/{grafana-agent => alloy}/windows/macros.nsis (100%) delete mode 100644 packaging/grafana-agent/deb/control/postinst delete mode 100644 packaging/grafana-agent/deb/grafana-agent.service delete mode 100644 packaging/grafana-agent/environment-file delete mode 100644 packaging/grafana-agent/rpm/control/postinst delete mode 100644 packaging/grafana-agent/rpm/control/prerm delete mode 100644 packaging/grafana-agent/rpm/grafana-agent.service diff --git a/.drone/drone.yml b/.drone/drone.yml index a8a40627e9..ce1dd8a68c 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -69,13 +69,13 @@ trigger: type: docker --- kind: pipeline -name: Check Linux container (grafana/agent) +name: Check Linux container (grafana/alloy) platform: arch: amd64 os: linux steps: - commands: - - make agent-image + - make alloy-image image: grafana/agent-build-image:0.40.2 name: Build container volumes: @@ -83,7 +83,7 @@ steps: path: /var/run/docker.sock trigger: paths: - - cmd/grafana-agent/Dockerfile + - cmd/alloy/Dockerfile - tools/ci/docker-containers ref: - refs/heads/main @@ -94,14 +94,14 @@ volumes: name: docker --- kind: pipeline -name: Check Windows container (grafana/agent) +name: Check Windows container (grafana/alloy) platform: arch: amd64 os: windows version: "1809" steps: - commands: - - '& "C:/Program Files/git/bin/bash.exe" ./tools/ci/docker-containers-windows agent' + - '& "C:/Program Files/git/bin/bash.exe" ./tools/ci/docker-containers-windows alloy' image: grafana/agent-build-image:0.40.2-windows name: Build container volumes: @@ -109,7 +109,7 @@ steps: path: //./pipe/docker_engine/ trigger: paths: - - cmd/grafana-agent/Dockerfile.windows + - cmd/alloy/Dockerfile.windows - tools/ci/docker-containers-windows ref: - refs/heads/main @@ -120,7 +120,7 @@ volumes: name: docker --- kind: pipeline -name: Build agent (Linux amd64) +name: Build alloy (Linux amd64) platform: arch: amd64 os: linux @@ -128,7 +128,7 @@ steps: - commands: - make generate-ui - GO_TAGS="builtinassets promtail_journal_enabled" GOOS=linux GOARCH=amd64 GOARM= - make agent + make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -137,7 +137,7 @@ trigger: type: docker --- kind: pipeline -name: Build agent (Linux arm64) +name: Build alloy (Linux arm64) platform: arch: amd64 os: linux @@ -145,7 +145,7 @@ steps: - commands: - make generate-ui - GO_TAGS="builtinassets promtail_journal_enabled" GOOS=linux GOARCH=arm64 GOARM= - make agent + make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -154,7 +154,7 @@ trigger: type: docker --- kind: pipeline -name: Build agent (Linux ppc64le) +name: Build alloy (Linux ppc64le) platform: arch: amd64 os: linux @@ -162,7 +162,7 @@ steps: - commands: - make generate-ui - GO_TAGS="builtinassets promtail_journal_enabled" GOOS=linux GOARCH=ppc64le GOARM= - make agent + make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -171,7 +171,7 @@ trigger: type: docker --- kind: pipeline -name: Build agent (Linux s390x) +name: Build alloy (Linux s390x) platform: arch: amd64 os: linux @@ -179,7 +179,7 @@ steps: - commands: - make generate-ui - GO_TAGS="builtinassets promtail_journal_enabled" GOOS=linux GOARCH=s390x GOARM= - make agent + make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -188,14 +188,14 @@ trigger: type: docker --- kind: pipeline -name: Build agent (macOS Intel) +name: Build alloy (macOS Intel) platform: arch: amd64 os: linux steps: - commands: - make generate-ui - - GO_TAGS="builtinassets" GOOS=darwin GOARCH=amd64 GOARM= make agent + - GO_TAGS="builtinassets" GOOS=darwin GOARCH=amd64 GOARM= make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -204,14 +204,14 @@ trigger: type: docker --- kind: pipeline -name: Build agent (macOS Apple Silicon) +name: Build alloy (macOS Apple Silicon) platform: arch: amd64 os: linux steps: - commands: - make generate-ui - - GO_TAGS="builtinassets" GOOS=darwin GOARCH=arm64 GOARM= make agent + - GO_TAGS="builtinassets" GOOS=darwin GOARCH=arm64 GOARM= make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -220,14 +220,14 @@ trigger: type: docker --- kind: pipeline -name: Build agent (Windows amd64) +name: Build alloy (Windows amd64) platform: arch: amd64 os: linux steps: - commands: - make generate-ui - - GO_TAGS="builtinassets" GOOS=windows GOARCH=amd64 GOARM= make agent + - GO_TAGS="builtinassets" GOOS=windows GOARCH=amd64 GOARM= make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -236,14 +236,14 @@ trigger: type: docker --- kind: pipeline -name: Build agent (FreeBSD amd64) +name: Build alloy (FreeBSD amd64) platform: arch: amd64 os: linux steps: - commands: - make generate-ui - - GO_TAGS="builtinassets" GOOS=freebsd GOARCH=amd64 GOARM= make agent + - GO_TAGS="builtinassets" GOOS=freebsd GOARCH=amd64 GOARM= make alloy image: grafana/agent-build-image:0.40.2 name: Build trigger: @@ -252,7 +252,7 @@ trigger: type: docker --- kind: pipeline -name: Publish development Linux agent container +name: Publish development Linux alloy container platform: arch: amd64 os: linux @@ -269,10 +269,10 @@ steps: - mkdir -p $HOME/.docker - printenv GCR_CREDS > $HOME/.docker/config.json - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - - docker buildx create --name multiarch-agent-agent-${DRONE_COMMIT_SHA} --driver + - docker buildx create --name multiarch-alloy-alloy-${DRONE_COMMIT_SHA} --driver docker-container --use - - DEVELOPMENT=1 ./tools/ci/docker-containers agent - - docker buildx rm multiarch-agent-agent-${DRONE_COMMIT_SHA} + - DEVELOPMENT=1 ./tools/ci/docker-containers alloy + - docker buildx rm multiarch-alloy-alloy-${DRONE_COMMIT_SHA} environment: DOCKER_LOGIN: from_secret: docker_login @@ -301,7 +301,7 @@ platform: os: linux steps: - commands: - - DOCKER_OPTS="" make dist/grafana-agent-linux-amd64 + - DOCKER_OPTS="" make dist/alloy-linux-amd64 - DOCKER_OPTS="" make test-packages image: grafana/agent-build-image:0.40.2 name: Test Linux system packages @@ -399,6 +399,6 @@ kind: secret name: updater_private_key --- kind: signature -hmac: 2088d828b5aeec4f38008f932b1402a03745e941ba06c6c4d72a96d42dfb7f01 +hmac: ba4497becf94a0f6f8dead2d99f8636683fbfba81eb869723c0a71ce4f7dcc09 ... diff --git a/.drone/pipelines/check_containers.jsonnet b/.drone/pipelines/check_containers.jsonnet index 28f4362310..5c5f2e5284 100644 --- a/.drone/pipelines/check_containers.jsonnet +++ b/.drone/pipelines/check_containers.jsonnet @@ -2,11 +2,11 @@ local build_image = import '../util/build_image.jsonnet'; local pipelines = import '../util/pipelines.jsonnet'; local linux_containers = [ - { name: 'grafana/agent', make: 'make agent-image', path: 'cmd/grafana-agent/Dockerfile' }, + { name: 'grafana/alloy', make: 'make alloy-image', path: 'cmd/alloy/Dockerfile' }, ]; local windows_containers = [ - { name: 'grafana/agent', argument: 'agent', path: 'cmd/grafana-agent/Dockerfile.windows' }, + { name: 'grafana/alloy', argument: 'alloy', path: 'cmd/alloy/Dockerfile.windows' }, ]; ( diff --git a/.drone/pipelines/crosscompile.jsonnet b/.drone/pipelines/crosscompile.jsonnet index b516ffcb79..cb00270e5a 100644 --- a/.drone/pipelines/crosscompile.jsonnet +++ b/.drone/pipelines/crosscompile.jsonnet @@ -29,7 +29,7 @@ local os_arch_tuples = [ local targets = [ - 'agent', + 'alloy', ]; local build_environments(targets, tuples, image) = std.flatMap(function(target) ( diff --git a/.drone/pipelines/publish.jsonnet b/.drone/pipelines/publish.jsonnet index e81d4386de..e78b634813 100644 --- a/.drone/pipelines/publish.jsonnet +++ b/.drone/pipelines/publish.jsonnet @@ -6,7 +6,7 @@ local ghTokenFilename = '/drone/src/gh-token.txt'; // job_names gets the list of job names for use in depends_on. local job_names = function(jobs) std.map(function(job) job.name, jobs); -local linux_containers = ['agent']; +local linux_containers = ['alloy']; local linux_containers_dev_jobs = std.map(function(container) ( pipelines.linux('Publish development Linux %s container' % container) { @@ -46,11 +46,11 @@ local linux_containers_dev_jobs = std.map(function(container) ( 'docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD', // Create a buildx worker for our cross platform builds. - 'docker buildx create --name multiarch-agent-%s-${DRONE_COMMIT_SHA} --driver docker-container --use' % container, + 'docker buildx create --name multiarch-alloy-%s-${DRONE_COMMIT_SHA} --driver docker-container --use' % container, 'DEVELOPMENT=1 ./tools/ci/docker-containers %s' % container, - 'docker buildx rm multiarch-agent-%s-${DRONE_COMMIT_SHA}' % container, + 'docker buildx rm multiarch-alloy-%s-${DRONE_COMMIT_SHA}' % container, ], }], volumes: [{ @@ -100,11 +100,11 @@ local linux_containers_jobs = std.map(function(container) ( 'docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD', // Create a buildx worker for our cross platform builds. - 'docker buildx create --name multiarch-agent-%s-${DRONE_COMMIT_SHA} --driver docker-container --use' % container, + 'docker buildx create --name multiarch-alloy-%s-${DRONE_COMMIT_SHA} --driver docker-container --use' % container, './tools/ci/docker-containers %s' % container, - 'docker buildx rm multiarch-agent-%s-${DRONE_COMMIT_SHA}' % container, + 'docker buildx rm multiarch-alloy-%s-${DRONE_COMMIT_SHA}' % container, ], }], volumes: [{ diff --git a/.drone/pipelines/test_packages.jsonnet b/.drone/pipelines/test_packages.jsonnet index b1b7d20715..42fca63679 100644 --- a/.drone/pipelines/test_packages.jsonnet +++ b/.drone/pipelines/test_packages.jsonnet @@ -18,7 +18,7 @@ local pipelines = import '../util/pipelines.jsonnet'; path: '/var/run/docker.sock', }], commands: [ - 'DOCKER_OPTS="" make dist/grafana-agent-linux-amd64', + 'DOCKER_OPTS="" make dist/alloy-linux-amd64', 'DOCKER_OPTS="" make test-packages', ], }], diff --git a/.github/workflows/check_docs.yml b/.github/workflows/check_docs.yml index 8cb45a3280..0ca919e1bd 100644 --- a/.github/workflows/check_docs.yml +++ b/.github/workflows/check_docs.yml @@ -9,7 +9,7 @@ jobs: - name: "Build technical documentation" run: > docker run - --volume "${PWD}/docs/sources:/hugo/content/docs/agent/latest" + --volume "${PWD}/docs/sources:/hugo/content/docs/alloy/latest" --env HUGO_REFLINKSERRORLEVEL=ERROR --rm grafana/docs-base:latest - /bin/bash -c 'echo -e "---\\nredirectURL: /docs/agent/latest/\\ntype: redirect\\nversioned: true\\n---\\n" > /hugo/content/docs/agent/_index.md && make hugo' + /bin/bash -c 'echo -e "---\\nredirectURL: /docs/alloy/latest/\\ntype: redirect\\nversioned: true\\n---\\n" > /hugo/content/docs/alloy/_index.md && make hugo' diff --git a/.github/workflows/publish-documentation-next.yml.disabled b/.github/workflows/publish-documentation-next.yml.disabled index 18146cb44e..bda9606b88 100644 --- a/.github/workflows/publish-documentation-next.yml.disabled +++ b/.github/workflows/publish-documentation-next.yml.disabled @@ -17,17 +17,17 @@ jobs: - name: "Build technical documentation" run: > docker run - --volume "${PWD}/docs/sources:/hugo/content/docs/agent/latest" + --volume "${PWD}/docs/sources:/hugo/content/docs/alloy/latest" --env HUGO_REFLINKSERRORLEVEL=ERROR --rm grafana/docs-base:latest - /bin/bash -c 'echo -e "---\\nredirectURL: /docs/agent/latest/\\ntype: redirect\\nversioned: true\\n---\\n" > /hugo/content/docs/agent/_index.md && make hugo' + /bin/bash -c 'echo -e "---\\nredirectURL: /docs/alloy/latest/\\ntype: redirect\\nversioned: true\\n---\\n" > /hugo/content/docs/alloy/_index.md && make hugo' sync: runs-on: ubuntu-latest needs: test steps: - - name: "Checkout Agent repo" + - name: "Checkout Alloy repo" uses: actions/checkout@v4 - name: "Clone website-sync Action" @@ -50,7 +50,7 @@ jobs: # The IT helpdesk can update the organization secret. github_pat: "grafanabot:${{ secrets.PUBLISH_TO_WEBSITE_TOKEN }}" source_folder: docs/sources - target_folder: 'content/docs/agent/next' + target_folder: 'content/docs/alloy/next' allow_no_changes: true - shell: bash run: | diff --git a/.github/workflows/publish-documentation-versioned.yml.disabled b/.github/workflows/publish-documentation-versioned.yml.disabled index 3339bf59b2..728d54ef06 100644 --- a/.github/workflows/publish-documentation-versioned.yml.disabled +++ b/.github/workflows/publish-documentation-versioned.yml.disabled @@ -19,17 +19,17 @@ jobs: - name: "Build technical documentation" run: > docker run - --volume "${PWD}/docs/sources:/hugo/content/docs/agent/latest" + --volume "${PWD}/docs/sources:/hugo/content/docs/alloy/latest" --env HUGO_REFLINKSERRORLEVEL=ERROR --rm grafana/docs-base:latest - /bin/bash -c 'echo -e "---\\nredirectURL: /docs/agent/latest/\\ntype: redirect\\nversioned: true\\n---\\n" > /hugo/content/docs/agent/_index.md && make hugo' + /bin/bash -c 'echo -e "---\\nredirectURL: /docs/alloy/latest/\\ntype: redirect\\nversioned: true\\n---\\n" > /hugo/content/docs/alloy/_index.md && make hugo' sync: runs-on: ubuntu-latest needs: test steps: - - name: "Checkout Agent repo" + - name: "Checkout Alloy repo" uses: actions/checkout@v4 with: fetch-depth: 0 @@ -80,7 +80,7 @@ jobs: # The IT helpdesk can update the organization secret. github_pat: "grafanabot:${{ secrets.PUBLISH_TO_WEBSITE_TOKEN }}" source_folder: docs/sources - target_folder: 'content/docs/agent/${{ steps.target.outputs.target }}' + target_folder: 'content/docs/alloy/${{ steps.target.outputs.target }}' allow_no_changes: true - shell: bash if: "steps.has-matching-release-tag.outputs.bool == 'true'" diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index ceea4dbcbe..b0351a97b3 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -28,7 +28,7 @@ jobs: - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@062f2592684a31eb3aa050cc61e7ca1451cecd3d with: - image-ref: 'grafana/agent:main' + image-ref: 'grafana/alloy:main' format: 'template' template: '@/contrib/sarif.tpl' output: 'trivy-results.sarif' @@ -37,4 +37,4 @@ jobs: - name: Upload Trivy scan results to GitHub Security tab uses: github/codeql-action/upload-sarif@v3 with: - sarif_file: 'trivy-results.sarif' \ No newline at end of file + sarif_file: 'trivy-results.sarif' diff --git a/.github/workflows/update-make-docs.yml b/.github/workflows/update-make-docs.yml index 188fd6bd80..ff8787ab9e 100644 --- a/.github/workflows/update-make-docs.yml +++ b/.github/workflows/update-make-docs.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: jobs: main: - if: github.repository == 'grafana/agent' + if: github.repository == 'grafana/alloy' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 5fd875edc9..848f60077c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -## Build, test, and generate code for various parts of Grafana Agent. +## Build, test, and generate code for various parts of Alloy. ## ## At least Go 1.19, git, and a moderately recent version of Docker is required ## to be able to use the Makefile. This list isn't exhaustive and there are other @@ -22,20 +22,20 @@ ## Targets for building binaries: ## ## binaries Compiles all binaries. -## agent Compiles cmd/grafana-agent to $(AGENT_BINARY) -## agent-service Compiles cmd/grafana-agent-service to $(SERVICE_BINARY) +## alloy Compiles cmd/alloy to $(ALLOY_BINARY) +## alloy-service Compiles cmd/alloy-service to $(SERVICE_BINARY) ## ## Targets for building Docker images: ## ## images Builds all Docker images. -## agent-image Builds agent Docker image. +## alloy-image Builds alloy Docker image. ## ## Targets for packaging: ## ## dist Produce release assets for everything. -## dist-agent-binaries Produce release-ready agent binaries. +## dist-alloy-binaries Produce release-ready Alloy binaries. ## dist-packages Produce release-ready DEB and RPM packages. -## dist-agent-installer Produce a Windows installer for Grafana Agent. +## dist-alloy-installer Produce a Windows installer for Alloy. ## ## Targets for generating assets: ## @@ -58,10 +58,10 @@ ## Environment variables: ## ## USE_CONTAINER Set to 1 to enable proxying commands to build container -## AGENT_IMAGE Image name:tag built by `make agent-image` +## ALLOY_IMAGE Image name:tag built by `make alloy-image` ## BUILD_IMAGE Image name:tag used by USE_CONTAINER=1 -## AGENT_BINARY Output path of `make agent` (default build/grafana-agent) -## SERVICE_BINARY Output path of `make agent-service` (default build/grafana-agent-service) +## ALLOY_BINARY Output path of `make alloy` (default build/alloy) +## SERVICE_BINARY Output path of `make alloy-service` (default build/alloy-service) ## GOOS Override OS to build binaries for ## GOARCH Override target architecture to build binaries for ## GOARM Override ARM version (6 or 7) when GOARCH=arm @@ -74,9 +74,9 @@ include tools/make/*.mk -AGENT_IMAGE ?= grafana/agent:latest -AGENT_BINARY ?= build/grafana-agent -SERVICE_BINARY ?= build/grafana-agent-service +ALLOY_IMAGE ?= grafana/alloy:latest +ALLOY_BINARY ?= build/alloy +SERVICE_BINARY ?= build/alloy-service AGENTLINT_BINARY ?= build/agentlint GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) @@ -88,9 +88,9 @@ GOEXPERIMENT ?= $(shell go env GOEXPERIMENT) # List of all environment variables which will propagate to the build # container. USE_CONTAINER must _not_ be included to avoid infinite recursion. PROPAGATE_VARS := \ - AGENT_IMAGE \ + ALLOY_IMAGE \ BUILD_IMAGE GOOS GOARCH GOARM CGO_ENABLED RELEASE_BUILD \ - AGENT_BINARY \ + ALLOY_BINARY \ VERSION GO_TAGS GOEXPERIMENT # @@ -151,22 +151,22 @@ integration-test: # Targets for building binaries # -.PHONY: binaries agent -binaries: agent +.PHONY: binaries alloy +binaries: alloy -agent: +alloy: ifeq ($(USE_CONTAINER),1) $(RERUN_IN_CONTAINER) else - $(GO_ENV) go build $(GO_FLAGS) -o $(AGENT_BINARY) ./cmd/grafana-agent + $(GO_ENV) go build $(GO_FLAGS) -o $(ALLOY_BINARY) ./cmd/alloy endif -# agent-service is not included in binaries since it's Windows-only. -agent-service: +# alloy-service is not included in binaries since it's Windows-only. +alloy-service: ifeq ($(USE_CONTAINER),1) $(RERUN_IN_CONTAINER) else - $(GO_ENV) go build $(GO_FLAGS) -o $(SERVICE_BINARY) ./cmd/grafana-agent-service + $(GO_ENV) go build $(GO_FLAGS) -o $(SERVICE_BINARY) ./cmd/alloy-service endif agentlint: @@ -186,11 +186,11 @@ ifneq ($(DOCKER_PLATFORM),) DOCKER_FLAGS += --platform=$(DOCKER_PLATFORM) endif -.PHONY: images agent-image -images: agent-image +.PHONY: images alloy-image +images: alloy-image -agent-image: - DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) -t $(AGENT_IMAGE) -f cmd/grafana-agent/Dockerfile . +alloy-image: + DOCKER_BUILDKIT=1 docker build $(DOCKER_FLAGS) -t $(ALLOY_IMAGE) -f cmd/alloy/Dockerfile . # # Targets for generating assets @@ -258,9 +258,9 @@ clean: clean-dist clean-build-container-cache .PHONY: info info: @printf "USE_CONTAINER = $(USE_CONTAINER)\n" - @printf "AGENT_IMAGE = $(AGENT_IMAGE)\n" + @printf "ALLOY_IMAGE = $(ALLOY_IMAGE)\n" @printf "BUILD_IMAGE = $(BUILD_IMAGE)\n" - @printf "AGENT_BINARY = $(AGENT_BINARY)\n" + @printf "ALLOY_BINARY = $(ALLOY_BINARY)\n" @printf "GOOS = $(GOOS)\n" @printf "GOARCH = $(GOARCH)\n" @printf "GOARM = $(GOARM)\n" diff --git a/build-image/Dockerfile b/build-image/Dockerfile index 4e8ae49b39..4b4f891974 100644 --- a/build-image/Dockerfile +++ b/build-image/Dockerfile @@ -36,7 +36,6 @@ RUN wget -nv https://nsis.sourceforge.io/mediawiki/images/4/4a/AccessControl.zip # Dependency: Go and Go dependencies FROM ${GO_RUNTIME} as golang -# Keep in sync with cmd/grafana-agent-operator/DEVELOPERS.md ENV CONTROLLER_GEN_VERSION v0.9.2 RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@$CONTROLLER_GEN_VERSION \ diff --git a/cmd/grafana-agent-service/config_windows.go b/cmd/alloy-service/config_windows.go similarity index 70% rename from cmd/grafana-agent-service/config_windows.go rename to cmd/alloy-service/config_windows.go index 90e0de4480..fb2a72122e 100644 --- a/cmd/grafana-agent-service/config_windows.go +++ b/cmd/alloy-service/config_windows.go @@ -9,20 +9,20 @@ import ( // config holds configuration options to run the service. type config struct { - // ServicePath points to the path of the managed Grafana Agent binary. + // ServicePath points to the path of the managed Alloy binary. ServicePath string - // Args holds arguments to pass to the Grafana Agent binary. os.Args[0] is - // not included. + // Args holds arguments to pass to the Alloy binary. os.Args[0] is not + // included. Args []string - // Environment holds environment variables for the Grafana Agent service. + // Environment holds environment variables for the Alloy service. // Each item represents an environment variable in form "key=value". // All environments variables from the current process with be merged into Environment Environment []string - // WorkingDirectory points to the working directory to run the Grafana Agent - // binary from. + // WorkingDirectory points to the working directory to run the Alloy binary + // from. WorkingDirectory string } @@ -32,22 +32,22 @@ func loadConfig() (*config, error) { // able to either migrate from the old key to the new key or supporting // both the old and the new key at the same time. - agentKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `Software\Grafana\Grafana Agent`, registry.READ) + alloyKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `Software\Grafana\Alloy`, registry.READ) if err != nil { return nil, fmt.Errorf("failed to open registry: %w", err) } - servicePath, _, err := agentKey.GetStringValue("") + servicePath, _, err := alloyKey.GetStringValue("") if err != nil { return nil, fmt.Errorf("failed to retrieve key (Default): %w", err) } - args, _, err := agentKey.GetStringsValue("Arguments") + args, _, err := alloyKey.GetStringsValue("Arguments") if err != nil { return nil, fmt.Errorf("failed to retrieve key Arguments: %w", err) } - env, _, err := agentKey.GetStringsValue("Environment") + env, _, err := alloyKey.GetStringsValue("Environment") if err != nil { return nil, fmt.Errorf("failed to retrieve key Environment: %w", err) } diff --git a/cmd/alloy-service/doc.go b/cmd/alloy-service/doc.go new file mode 100644 index 0000000000..04be971702 --- /dev/null +++ b/cmd/alloy-service/doc.go @@ -0,0 +1,3 @@ +// Command alloy-service is a Windows binary which manages Alloy as a Windows +// service. +package main diff --git a/cmd/grafana-agent-service/logger_windows.go b/cmd/alloy-service/logger_windows.go similarity index 100% rename from cmd/grafana-agent-service/logger_windows.go rename to cmd/alloy-service/logger_windows.go diff --git a/cmd/grafana-agent-service/main_windows.go b/cmd/alloy-service/main_windows.go similarity index 92% rename from cmd/grafana-agent-service/main_windows.go rename to cmd/alloy-service/main_windows.go index f37cb6f5d8..ea86ce234f 100644 --- a/cmd/grafana-agent-service/main_windows.go +++ b/cmd/alloy-service/main_windows.go @@ -11,7 +11,7 @@ import ( "golang.org/x/sys/windows/svc" ) -const serviceName = "Grafana Agent" +const serviceName = "Grafana Alloy" func main() { logger, err := newLogger() @@ -39,21 +39,21 @@ func main() { Stderr: logger, } - as := &agentService{logger: logger, cfg: cfg} + as := &alloyService{logger: logger, cfg: cfg} if err := svc.Run(serviceName, as); err != nil { level.Error(logger).Log("msg", "failed to run service", "err", err) os.Exit(1) } } -type agentService struct { +type alloyService struct { logger log.Logger cfg serviceManagerConfig } const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown -func (as *agentService) Execute(args []string, r <-chan svc.ChangeRequest, s chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) { +func (as *alloyService) Execute(args []string, r <-chan svc.ChangeRequest, s chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) { defer func() { s <- svc.Status{State: svc.Stopped} }() diff --git a/cmd/grafana-agent-service/service.go b/cmd/alloy-service/service.go similarity index 100% rename from cmd/grafana-agent-service/service.go rename to cmd/alloy-service/service.go diff --git a/cmd/grafana-agent-service/service_test.go b/cmd/alloy-service/service_test.go similarity index 100% rename from cmd/grafana-agent-service/service_test.go rename to cmd/alloy-service/service_test.go diff --git a/cmd/grafana-agent-service/testdata/example_service.go b/cmd/alloy-service/testdata/example_service.go similarity index 100% rename from cmd/grafana-agent-service/testdata/example_service.go rename to cmd/alloy-service/testdata/example_service.go diff --git a/cmd/grafana-agent/Dockerfile b/cmd/alloy/Dockerfile similarity index 62% rename from cmd/grafana-agent/Dockerfile rename to cmd/alloy/Dockerfile index e7cf42a67f..7b15b82548 100644 --- a/cmd/grafana-agent/Dockerfile +++ b/cmd/alloy/Dockerfile @@ -14,12 +14,12 @@ ARG RELEASE_BUILD=1 ARG VERSION ARG GOEXPERIMENT -COPY . /src/agent -WORKDIR /src/agent +COPY . /src/alloy +WORKDIR /src/alloy -# Build the UI before building the agent, which will then bake the final UI -# into the binary. -RUN --mount=type=cache,target=/src/agent/web/ui/node_modules,sharing=locked \ +# Build the UI before building Alloy, which will then bake the final UI into +# the binary. +RUN --mount=type=cache,target=/src/alloy/web/ui/node_modules,sharing=locked \ make generate-ui RUN --mount=type=cache,target=/root/.cache/go-build \ @@ -28,15 +28,15 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \ GO_TAGS="netgo builtinassets promtail_journal_enabled" \ GOEXPERIMENT=${GOEXPERIMENT} \ - make agent + make alloy FROM public.ecr.aws/ubuntu/ubuntu:mantic -#Username and uid for grafana-agent user +# Username and uid for alloy user ARG UID=473 -ARG USERNAME="grafana-agent" +ARG USERNAME="alloy" -LABEL org.opencontainers.image.source="https://github.com/grafana/agent" +LABEL org.opencontainers.image.source="https://github.com/grafana/alloy" # Install dependencies needed at runtime. RUN < +go build ./cmd/alloy/ +./alloy -config.file= # For testing: make lint test # Make sure all the tests pass before you commit and push :) @@ -62,8 +62,8 @@ To build Grafana Agent from source code, please install the following tools: You can directly use the go tool to download and install the agent binary into your GOPATH: - $ GO111MODULE=on go install github.com/grafana/agent/cmd/grafana-agent - $ grafana-agent -config.file=your_config.yml + $ GO111MODULE=on go install github.com/grafana/agent/cmd/alloy + $ alloy run your_config.river An example of the above configuration file can be found [here][example-config]. @@ -74,7 +74,7 @@ You can also clone the repository yourself and build using `make agent`: $ git clone https://github.com/grafana/agent.git $ cd agent $ make agent - $ ./build/grafana-agent -config.file=your_config.yml + $ ./build/alloy run your_config.river The Makefile provides several targets: @@ -205,5 +205,5 @@ a hard fork (i.e., creating a new Go module with the same source). [CLA]: https://cla-assistant.io/grafana/agent [good-first-issue]: https://github.com/grafana/agent/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 [community-slack]: https://slack.grafana.com/ -[example-config]: ../../cmd/grafana-agent/agent-local-config.yaml +[example-config]: ../../cmd/alloy/example-config.river [go-modules]: https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more diff --git a/internal/cmd/integration-tests/README.md b/internal/cmd/integration-tests/README.md index 353c439d44..e4df4c257b 100644 --- a/internal/cmd/integration-tests/README.md +++ b/internal/cmd/integration-tests/README.md @@ -2,7 +2,7 @@ This document provides an outline of how to run and add new integration tests to the project. -The purpose of these tests is to verify simple, happy-path pipelines to catch issues between the agent and external dependencies. +The purpose of these tests is to verify simple, happy-path pipelines to catch issues between Alloy and external dependencies. The external dependencies are launched as Docker containers. @@ -16,7 +16,7 @@ Execute the integration tests using the following command: ### Flags -* `--skip-build`: Run the integration tests without building the agent (default: `false`) +* `--skip-build`: Run the integration tests without building Alloy (default: `false`) * `--test`: Specifies a particular directory within the tests directory to run (default: runs all tests) ## Adding new tests @@ -28,4 +28,4 @@ Follow these steps to add a new integration test to the project: 3. Within the new test directory, create a file named `config.river` to hold the pipeline configuration you want to test. 4. Create a `_test.go` file within the new test directory. This file should contain the Go code necessary to run the test and verify the data processing through the pipeline. - _NOTE_: The tests run concurrently. Each agent must tag its data with a label that corresponds to its specific configuration. This ensures the correct data verification during the Go testing process. + _NOTE_: The tests run concurrently. Each Alloy instance must tag its data with a label that corresponds to its specific configuration. This ensures the correct data verification during the Go testing process. diff --git a/internal/cmd/integration-tests/main.go b/internal/cmd/integration-tests/main.go index 7b48d21576..b21340ff34 100644 --- a/internal/cmd/integration-tests/main.go +++ b/internal/cmd/integration-tests/main.go @@ -20,7 +20,7 @@ func main() { } rootCmd.PersistentFlags().StringVar(&specificTest, "test", "", "Specific test directory to run") - rootCmd.PersistentFlags().BoolVar(&skipBuild, "skip-build", false, "Skip building the agent") + rootCmd.PersistentFlags().BoolVar(&skipBuild, "skip-build", false, "Skip building Alloy") if err := rootCmd.Execute(); err != nil { fmt.Println(err) @@ -33,7 +33,7 @@ func runIntegrationTests(cmd *cobra.Command, args []string) { defer cleanUpEnvironment() if !skipBuild { - buildAgent() + buildAlloy() } setupEnvironment() diff --git a/internal/cmd/integration-tests/utils.go b/internal/cmd/integration-tests/utils.go index 4b4291f3a2..baeeccb980 100644 --- a/internal/cmd/integration-tests/utils.go +++ b/internal/cmd/integration-tests/utils.go @@ -12,12 +12,12 @@ import ( ) const ( - agentBinaryPath = "../../../../../build/grafana-agent" + alloyBinaryPath = "../../../../../build/alloy" ) type TestLog struct { TestDir string - AgentLog string + AlloyLog string TestOutput string } @@ -33,8 +33,8 @@ func executeCommand(command string, args []string, taskDescription string) { } } -func buildAgent() { - executeCommand("make", []string{"-C", "../../..", "agent"}, "Building agent") +func buildAlloy() { + executeCommand("make", []string{"-C", "../../..", "alloy"}, "Building Alloy") } func setupEnvironment() { @@ -52,16 +52,16 @@ func runSingleTest(testDir string, port int) { dirName := filepath.Base(testDir) - var agentLogBuffer bytes.Buffer - cmd := exec.Command(agentBinaryPath, "run", "config.river", "--server.http.listen-addr", fmt.Sprintf("0.0.0.0:%d", port)) + var alloyLogBuffer bytes.Buffer + cmd := exec.Command(alloyBinaryPath, "run", "config.river", "--server.http.listen-addr", fmt.Sprintf("0.0.0.0:%d", port)) cmd.Dir = testDir - cmd.Stdout = &agentLogBuffer - cmd.Stderr = &agentLogBuffer + cmd.Stdout = &alloyLogBuffer + cmd.Stderr = &alloyLogBuffer if err := cmd.Start(); err != nil { logChan <- TestLog{ TestDir: dirName, - AgentLog: fmt.Sprintf("Failed to start agent: %v", err), + AlloyLog: fmt.Sprintf("Failed to start Alloy: %v", err), } return } @@ -75,12 +75,12 @@ func runSingleTest(testDir string, port int) { panic(err) } - agentLog := agentLogBuffer.String() + alloyLog := alloyLogBuffer.String() if errTest != nil { logChan <- TestLog{ TestDir: dirName, - AgentLog: agentLog, + AlloyLog: alloyLog, TestOutput: string(testOutput), } } @@ -129,7 +129,7 @@ func reportResults() { } fmt.Printf("Failure detected in %s:\n", log.TestDir) fmt.Println("Test output:", log.TestOutput) - fmt.Println("Agent logs:", log.AgentLog) + fmt.Println("Alloy logs:", log.AlloyLog) testsFailed++ } diff --git a/internal/tools/packaging_test/agent_linux_packages_test.go b/internal/tools/packaging_test/agent_linux_packages_test.go index 448daa698b..9bee704566 100644 --- a/internal/tools/packaging_test/agent_linux_packages_test.go +++ b/internal/tools/packaging_test/agent_linux_packages_test.go @@ -15,12 +15,12 @@ import ( "github.com/stretchr/testify/require" ) -// TestAgentLinuxPackages runs the entire test suite for the Linux packages. -func TestAgentLinuxPackages(t *testing.T) { - packageName := "grafana-agent" +// TestAlloyLinuxPackages runs the entire test suite for the Linux packages. +func TestAlloyLinuxPackages(t *testing.T) { + packageName := "alloy" fmt.Println("Building packages (this may take a while...)") - buildAgentPackages(t) + buildAlloyPackages(t) dockerPool, err := dockertest.NewPool("") require.NoError(t, err) @@ -53,7 +53,7 @@ func TestAgentLinuxPackages(t *testing.T) { } } -func buildAgentPackages(t *testing.T) { +func buildAlloyPackages(t *testing.T) { t.Helper() wd, err := os.Getwd() diff --git a/packaging/grafana-agent/grafana-agent.river b/packaging/alloy/alloy.river similarity index 87% rename from packaging/grafana-agent/grafana-agent.river rename to packaging/alloy/alloy.river index 56a8ea5b4a..34f6d0abe3 100644 --- a/packaging/grafana-agent/grafana-agent.river +++ b/packaging/alloy/alloy.river @@ -1,6 +1,6 @@ -// Sample config for Grafana Agent. +// Sample config for Alloy. // -// For a full configuration reference, see https://grafana.com/docs/agent +// For a full configuration reference, see https://grafana.com/docs/alloy logging { level = "warn" } @@ -15,7 +15,7 @@ prometheus.scrape "default" { prometheus.exporter.unix.default.targets, [{ // Self-collect metrics - job = "agent", + job = "alloy", __address__ = "127.0.0.1:12345", }], ) diff --git a/packaging/alloy/deb/alloy.service b/packaging/alloy/deb/alloy.service new file mode 100644 index 0000000000..d525e159e5 --- /dev/null +++ b/packaging/alloy/deb/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=AGENT_DEPLOY_MODE=deb +EnvironmentFile=/etc/default/alloy +WorkingDirectory=/var/lib/alloy +ExecStart=/usr/bin/alloy run $CUSTOM_ARGS --storage.path=/var/lib/alloy $CONFIG_FILE +ExecReload=/usr/bin/env kill -HUP $MAINPID +TimeoutStopSec=20s +SendSIGKILL=no + +[Install] +WantedBy=multi-user.target diff --git a/packaging/alloy/deb/control/postinst b/packaging/alloy/deb/control/postinst new file mode 100644 index 0000000000..79631bec0c --- /dev/null +++ b/packaging/alloy/deb/control/postinst @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +# shellcheck disable=SC1091 +[ -f /etc/default/alloy ] && . /etc/default/alloy + +# Initial installation: $1 == configure +# Upgrade: $1 == configure, $2 == old version +case "$1" in + configure) + [ -z "$ALLOY_USER" ] && ALLOY_USER="alloy" + [ -z "$ALLOY_GROUP" ] && ALLOY_GROUP="alloy" + if ! getent group "$ALLOY_GROUP" > /dev/null 2>&1 ; then + groupadd -r "$ALLOY_GROUP" + fi + if ! getent passwd "$ALLOY_USER" > /dev/null 2>&1 ; then + useradd -m -r -g "$ALLOY_GROUP" -d /var/lib/alloy -s /sbin/nologin -c "alloy user" "$ALLOY_USER" + fi + + # Add Alloy user to groups used for reading logs. + if getent group adm > /dev/null 2>&1 ; then + usermod -a -G adm "$ALLOY_USER" + fi + if getent group systemd-journal > /dev/null 2>&1 ; then + usermod -a -G systemd-journal "$ALLOY_USER" + fi + + chown $ALLOY_USER:$ALLOY_GROUP /var/lib/alloy + chmod 770 /var/lib/alloy + + chmod 640 /etc/alloy.river + chown root:$ALLOY_GROUP /etc/alloy.river + + if [ -z ${2+x} ] && [ "$RESTART_ON_UPGRADE" = "true" ]; then + if command -v systemctl 2>/dev/null; then + systemctl daemon-reload + systemctl restart alloy + fi + fi +esac diff --git a/packaging/grafana-agent/deb/control/prerm b/packaging/alloy/deb/control/prerm similarity index 50% rename from packaging/grafana-agent/deb/control/prerm rename to packaging/alloy/deb/control/prerm index 1641bcc1b3..9730285248 100644 --- a/packaging/grafana-agent/deb/control/prerm +++ b/packaging/alloy/deb/control/prerm @@ -3,10 +3,10 @@ set -e # shellcheck disable=SC1091 -[ -f /etc/default/grafana-agent ] && . /etc/default/grafana-agent +[ -f /etc/default/alloy ] && . /etc/default/alloy if [ "$1" = "remove" ]; then if command -v systemctl 2>/dev/null; then - systemctl stop grafana-agent.service > /dev/null 2>&1 || : + systemctl stop alloy.service > /dev/null 2>&1 || : fi fi diff --git a/packaging/alloy/environment-file b/packaging/alloy/environment-file new file mode 100644 index 0000000000..2f2f7826f6 --- /dev/null +++ b/packaging/alloy/environment-file @@ -0,0 +1,16 @@ +## Path: +## Description: Grafana Alloy settings +## Type: string +## Default: "" +## ServiceRestart: alloy +# +# Command line options for Alloy. +# +# The configuration file holding the Alloy config. +CONFIG_FILE="/etc/alloy.river" + +# User-defined arguments to pass to the run command. +CUSTOM_ARGS="" + +# Restart on system upgrade. Defaults to true. +RESTART_ON_UPGRADE=true diff --git a/packaging/alloy/rpm/alloy.service b/packaging/alloy/rpm/alloy.service new file mode 100644 index 0000000000..c42dcb6a6a --- /dev/null +++ b/packaging/alloy/rpm/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=AGENT_DEPLOY_MODE=rpm +EnvironmentFile=/etc/sysconfig/alloy +WorkingDirectory=/var/lib/alloy +ExecStart=/usr/bin/alloy run $CUSTOM_ARGS --storage.path=/var/lib/alloy $CONFIG_FILE +ExecReload=/usr/bin/env kill -HUP $MAINPID +TimeoutStopSec=20s +SendSIGKILL=no + +[Install] +WantedBy=multi-user.target diff --git a/packaging/alloy/rpm/control/postinst b/packaging/alloy/rpm/control/postinst new file mode 100644 index 0000000000..963664c935 --- /dev/null +++ b/packaging/alloy/rpm/control/postinst @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +# shellcheck disable=SC1091 +[ -f /etc/sysconfig/alloy ] && . /etc/sysconfig/alloy +[ -z "$ALLOY_USER" ] && ALLOY_USER="alloy" +[ -z "$ALLOY_GROUP" ] && ALLOY_GROUP="alloy" + +add_to_logging_groups() { + # Add Alloy user to groups used for reading logs. + if getent group adm > /dev/null 2>&1 ; then + usermod -a -G adm "$ALLOY_USER" + fi + if getent group systemd-journal > /dev/null 2>&1 ; then + usermod -a -G systemd-journal "$ALLOY_USER" + fi +} + +# Initial installation: $1 == 1 +# Upgrade: $1 == 2, and configured to restart on upgrade +if [ "$1" -eq 1 ] ; then + if ! getent group "$ALLOY_GROUP" > /dev/null 2>&1 ; then + groupadd -r "$ALLOY_GROUP" + fi + if ! getent passwd "$ALLOY_USER" > /dev/null 2>&1 ; then + useradd -r -m -g "$ALLOY_GROUP" -d /var/lib/alloy -s /sbin/nologin -c "alloy user" "$ALLOY_USER" + fi + + add_to_logging_groups + + chown $ALLOY_USER:$ALLOY_GROUP /var/lib/alloy + chmod 770 /var/lib/alloy + + chmod 640 /etc/alloy.river + chown root:$ALLOY_GROUP /etc/alloy.river + +elif [ "$1" -ge 2 ] ; then + add_to_logging_groups + + if [ "$RESTART_ON_UPGRADE" = "true" ]; then + systemctl daemon-reload + systemctl restart alloy + fi +fi diff --git a/packaging/alloy/rpm/control/prerm b/packaging/alloy/rpm/control/prerm new file mode 100644 index 0000000000..adc876ab40 --- /dev/null +++ b/packaging/alloy/rpm/control/prerm @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +# shellcheck disable=SC1091 +[ -f /etc/sysconfig/alloy ] && . /etc/sysconfig/alloy + +# final uninstallation $1=0 +# If other copies of this RPM are installed, then $1>0 + +if [ "$1" -eq 0 ] ; then + if [ -x /bin/systemctl ] ; then + /bin/systemctl stop alloy.service > /dev/null 2>&1 || : + elif [ -x /etc/init.d/alloy ] ; then + /etc/init.d/alloy stop + elif [ -x /etc/rc.d/init.d/alloy ] ; then + /etc/rc.d/init.d/alloy stop + fi +fi +exit 0 diff --git a/packaging/grafana-agent/rpm/gpg-sign.sh b/packaging/alloy/rpm/gpg-sign.sh similarity index 100% rename from packaging/grafana-agent/rpm/gpg-sign.sh rename to packaging/alloy/rpm/gpg-sign.sh diff --git a/packaging/grafana-agent/windows/config.river b/packaging/alloy/windows/config.river similarity index 100% rename from packaging/grafana-agent/windows/config.river rename to packaging/alloy/windows/config.river diff --git a/packaging/grafana-agent/windows/install_script.nsis b/packaging/alloy/windows/install_script.nsis similarity index 88% rename from packaging/grafana-agent/windows/install_script.nsis rename to packaging/alloy/windows/install_script.nsis index f4b1aa19c3..099eace2d3 100644 --- a/packaging/grafana-agent/windows/install_script.nsis +++ b/packaging/alloy/windows/install_script.nsis @@ -1,6 +1,6 @@ # This script does the following: # -# 1. Installs grafana-agent-windows-amd64.exe, grafana-agent-service-amd64.exe, and logo.ico. +# 1. Installs alloy-windows-amd64.exe, alloy-service-amd64.exe, and logo.ico. # 2. Creates a Start Menu shortcut. # 3. Builds an uninstaller. # 4. Adds uninstall information to the registry for Add/Remove Programs. @@ -12,7 +12,7 @@ Unicode true !include FileFunc.nsh !include .\macros.nsis -!define APPNAME "Grafana Agent" +!define APPNAME "Grafana Alloy" !define HELPURL "https://grafana.com/docs/alloy/latest" !define UPDATEURL "https://github.com/grafana/alloy/releases" !define ABOUTURL "https://github.com/grafana/alloy" @@ -59,7 +59,7 @@ Section "install" # stack, and must be popped after calling. # Preemptively stop the existing service if it's running. - nsExec::ExecToLog 'sc stop "Grafana Agent"' + nsExec::ExecToLog 'sc stop "Grafana Alloy"' Pop $0 # Configure the out path and copy files to it. @@ -70,8 +70,8 @@ Section "install" Exists: SetOutPath "$INSTDIR" - File "..\..\..\dist.temp\grafana-agent-windows-amd64.exe" - File "..\..\..\dist.temp\grafana-agent-service-windows-amd64.exe" + File "..\..\..\dist.temp\alloy-windows-amd64.exe" + File "..\..\..\dist.temp\alloy-service-windows-amd64.exe" File "logo.ico" # Create an uninstaller at the same pathFunctionEnd @@ -97,15 +97,15 @@ Section "install" Call InitializeRegistry # Create the service. - nsExec::ExecToLog 'sc create "Grafana Agent" start= delayed-auto binpath= "$INSTDIR\grafana-agent-service-windows-amd64.exe"' + nsExec::ExecToLog 'sc create "Grafana Alloy" start= delayed-auto binpath= "$INSTDIR\alloy-service-windows-amd64.exe"' Pop $0 # Start the service. - nsExec::ExecToLog 'sc start "Grafana Agent"' + nsExec::ExecToLog 'sc start "Grafana Alloy"' Pop $0 - # Auto-restart agent on failure. Reset failure counter after 60 seconds without failure - nsExec::ExecToLog `sc failure "Grafana Agent" reset= 60 actions= restart/5000 reboot= "Grafana Agent has failed. Restarting in 5 seconds"` + # Auto-restart Alloy on failure. Reset failure counter after 60 seconds without failure + nsExec::ExecToLog `sc failure "Grafana Alloy" reset= 60 actions= restart/5000 reboot= "Grafana Alloy has failed. Restarting in 5 seconds"` Pop $0 SectionEnd @@ -129,13 +129,13 @@ FunctionEnd # InitializeRegistry initializes the keys in the registry that the service # runner uses. If the registry values already exist, they are not overwritten. Function InitializeRegistry - !define REGKEY "HKLM\Software\Grafana\Grafana Agent" + !define REGKEY "HKLM\Software\Grafana\Alloy" # Define the default key, which points to the service. nsExec::ExecToLog 'Reg.exe query "${REGKEY}" /reg:64 /ve' Pop $0 ${If} $0 == 1 - nsExec::ExecToLog 'Reg.exe add "${REGKEY}" /reg:64 /ve /d "$INSTDIR\grafana-agent-windows-amd64.exe"' + nsExec::ExecToLog 'Reg.exe add "${REGKEY}" /reg:64 /ve /d "$INSTDIR\alloy-windows-amd64.exe"' Pop $0 # Ignore return result ${EndIf} @@ -209,9 +209,9 @@ Section "uninstall" DetailPrint "Starting uninstaller." # Stop and remove service. - nsExec::ExecToLog 'sc stop "Grafana Agent"' + nsExec::ExecToLog 'sc stop "Grafana Alloy"' Pop $0 - nsExec::ExecToLog 'sc delete "Grafana Agent"' + nsExec::ExecToLog 'sc delete "Grafana Alloy"' Pop $0 RMDir /r "$SMPROGRAMS\${APPNAME}" # Start Menu folder. @@ -219,7 +219,7 @@ Section "uninstall" RMDir /r "$APPDATA\${APPNAME}" # Application data. # Remove service and uninstaller information from the registry. - nsExec::ExecToLog 'Reg.exe delete "HKLM\SOFTWARE\Grafana\Grafana Agent" /reg:64 /f' + nsExec::ExecToLog 'Reg.exe delete "HKLM\SOFTWARE\Grafana\Alloy" /reg:64 /f' Pop $0 nsExec::ExecToLog 'Reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" /reg:64 /f' Pop $0 diff --git a/packaging/grafana-agent/windows/logo.ico b/packaging/alloy/windows/logo.ico similarity index 100% rename from packaging/grafana-agent/windows/logo.ico rename to packaging/alloy/windows/logo.ico diff --git a/packaging/grafana-agent/windows/macros.nsis b/packaging/alloy/windows/macros.nsis similarity index 100% rename from packaging/grafana-agent/windows/macros.nsis rename to packaging/alloy/windows/macros.nsis diff --git a/packaging/grafana-agent/deb/control/postinst b/packaging/grafana-agent/deb/control/postinst deleted file mode 100644 index a06af7a86f..0000000000 --- a/packaging/grafana-agent/deb/control/postinst +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -set -e - -# shellcheck disable=SC1091 -[ -f /etc/default/grafana-agent ] && . /etc/default/grafana-agent - -# Initial installation: $1 == configure -# Upgrade: $1 == configure, $2 == old version -case "$1" in - configure) - [ -z "$GRAFANA_AGENT_USER" ] && GRAFANA_AGENT_USER="grafana-agent" - [ -z "$GRAFANA_AGENT_GROUP" ] && GRAFANA_AGENT_GROUP="grafana-agent" - if ! getent group "$GRAFANA_AGENT_GROUP" > /dev/null 2>&1 ; then - groupadd -r "$GRAFANA_AGENT_GROUP" - fi - if ! getent passwd "$GRAFANA_AGENT_USER" > /dev/null 2>&1 ; then - useradd -m -r -g "$GRAFANA_AGENT_GROUP" -d /var/lib/grafana-agent -s /sbin/nologin -c "grafana-agent user" "$GRAFANA_AGENT_USER" - fi - - # Add grafana agent user to groups used for reading logs. - if getent group adm > /dev/null 2>&1 ; then - usermod -a -G adm "$GRAFANA_AGENT_USER" - fi - if getent group systemd-journal > /dev/null 2>&1 ; then - usermod -a -G systemd-journal "$GRAFANA_AGENT_USER" - fi - - chown $GRAFANA_AGENT_USER:$GRAFANA_AGENT_GROUP /var/lib/grafana-agent - chmod 770 /var/lib/grafana-agent - - chmod 640 /etc/grafana-agent.river - chown root:$GRAFANA_AGENT_GROUP /etc/grafana-agent.river - - if [ -z ${2+x} ] && [ "$RESTART_ON_UPGRADE" = "true" ]; then - if command -v systemctl 2>/dev/null; then - systemctl daemon-reload - systemctl restart grafana-agent - fi - fi -esac diff --git a/packaging/grafana-agent/deb/grafana-agent.service b/packaging/grafana-agent/deb/grafana-agent.service deleted file mode 100644 index 7177972b45..0000000000 --- a/packaging/grafana-agent/deb/grafana-agent.service +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Description=Vendor-neutral programmable observability pipelines. -Documentation=https://grafana.com/docs/agent -Wants=network-online.target -After=network-online.target - -[Service] -Restart=always -User=grafana-agent -Environment=HOSTNAME=%H -Environment=AGENT_DEPLOY_MODE=deb -EnvironmentFile=/etc/default/grafana-agent -WorkingDirectory=/var/lib/grafana-agent -ExecStart=/usr/bin/grafana-agent run $CUSTOM_ARGS --storage.path=/var/lib/grafana-agent $CONFIG_FILE -ExecReload=/usr/bin/env kill -HUP $MAINPID -TimeoutStopSec=20s -SendSIGKILL=no - -[Install] -WantedBy=multi-user.target diff --git a/packaging/grafana-agent/environment-file b/packaging/grafana-agent/environment-file deleted file mode 100644 index e8b15ea74a..0000000000 --- a/packaging/grafana-agent/environment-file +++ /dev/null @@ -1,16 +0,0 @@ -## Path: -## Description: Grafana Agent settings -## Type: string -## Default: "" -## ServiceRestart: grafana-agent -# -# Command line options for grafana-agent -# -# The configuration file holding the agent config. -CONFIG_FILE="/etc/grafana-agent.river" - -# User-defined arguments to pass to the run command. -CUSTOM_ARGS="" - -# Restart on system upgrade. Defaults to true. -RESTART_ON_UPGRADE=true diff --git a/packaging/grafana-agent/rpm/control/postinst b/packaging/grafana-agent/rpm/control/postinst deleted file mode 100644 index e908923dc2..0000000000 --- a/packaging/grafana-agent/rpm/control/postinst +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -set -e - -# NOTE: the grafana-agent group is shared with the grafana-agent package to -# make it easier to migrate between the two. A unique user is still used to -# give them different home directories. - -# shellcheck disable=SC1091 -[ -f /etc/sysconfig/grafana-agent ] && . /etc/sysconfig/grafana-agent -[ -z "$AGENT_USER" ] && AGENT_USER="grafana-agent" -[ -z "$AGENT_GROUP" ] && AGENT_GROUP="grafana-agent" - -add_to_logging_groups() { - # Add grafana agent user to groups used for reading logs. - if getent group adm > /dev/null 2>&1 ; then - usermod -a -G adm "$AGENT_USER" - fi - if getent group systemd-journal > /dev/null 2>&1 ; then - usermod -a -G systemd-journal "$AGENT_USER" - fi -} - -# Initial installation: $1 == 1 -# Upgrade: $1 == 2, and configured to restart on upgrade -if [ "$1" -eq 1 ] ; then - if ! getent group "$AGENT_GROUP" > /dev/null 2>&1 ; then - groupadd -r "$AGENT_GROUP" - fi - if ! getent passwd "$AGENT_USER" > /dev/null 2>&1 ; then - useradd -r -m -g "$AGENT_GROUP" -d /var/lib/grafana-agent -s /sbin/nologin -c "grafana-agent user" "$AGENT_USER" - fi - - add_to_logging_groups - - chown $AGENT_USER:$AGENT_GROUP /var/lib/grafana-agent - chmod 770 /var/lib/grafana-agent - - chmod 640 /etc/grafana-agent.river - chown root:$AGENT_GROUP /etc/grafana-agent.river - -elif [ "$1" -ge 2 ] ; then - add_to_logging_groups - - if [ "$RESTART_ON_UPGRADE" = "true" ]; then - systemctl daemon-reload - systemctl restart grafana-agent - fi -fi diff --git a/packaging/grafana-agent/rpm/control/prerm b/packaging/grafana-agent/rpm/control/prerm deleted file mode 100644 index 7acc646efe..0000000000 --- a/packaging/grafana-agent/rpm/control/prerm +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -# shellcheck disable=SC1091 -[ -f /etc/sysconfig/grafana-agent ] && . /etc/sysconfig/grafana-agent - -# final uninstallation $1=0 -# If other copies of this RPM are installed, then $1>0 - -if [ "$1" -eq 0 ] ; then - if [ -x /bin/systemctl ] ; then - /bin/systemctl stop grafana-agent.service > /dev/null 2>&1 || : - elif [ -x /etc/init.d/grafana-agent ] ; then - /etc/init.d/grafana-agent stop - elif [ -x /etc/rc.d/init.d/grafana-agent ] ; then - /etc/rc.d/init.d/grafana-agent stop - fi -fi -exit 0 diff --git a/packaging/grafana-agent/rpm/grafana-agent.service b/packaging/grafana-agent/rpm/grafana-agent.service deleted file mode 100644 index ea3165626d..0000000000 --- a/packaging/grafana-agent/rpm/grafana-agent.service +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Description=Vendor-neutral programmable observability pipelines. -Documentation=https://grafana.com/docs/agent -Wants=network-online.target -After=network-online.target - -[Service] -Restart=always -User=grafana-agent -Environment=HOSTNAME=%H -Environment=AGENT_DEPLOY_MODE=rpm -EnvironmentFile=/etc/sysconfig/grafana-agent -WorkingDirectory=/var/lib/grafana-agent -ExecStart=/usr/bin/grafana-agent run $CUSTOM_ARGS --storage.path=/var/lib/grafana-agent $CONFIG_FILE -ExecReload=/usr/bin/env kill -HUP $MAINPID -TimeoutStopSec=20s -SendSIGKILL=no - -[Install] -WantedBy=multi-user.target diff --git a/tools/ci/docker-containers b/tools/ci/docker-containers index a712dba8cc..cbd9d7430e 100755 --- a/tools/ci/docker-containers +++ b/tools/ci/docker-containers @@ -7,10 +7,10 @@ # from a Drone trigger. set -euxo pipefail -RELEASE_AGENT_IMAGE=grafana/agent -DEVELOPMENT_AGENT_IMAGE=us-docker.pkg.dev/grafanalabs-dev/docker-alloy-dev/alloy +RELEASE_ALLOY_IMAGE=grafana/alloy +DEVELOPMENT_ALLOY_IMAGE=us-docker.pkg.dev/grafanalabs-dev/docker-alloy-dev/alloy -DEFAULT_AGENT_IMAGE=${RELEASE_AGENT_IMAGE} +DEFAULT_ALLOY_IMAGE=${RELEASE_ALLOY_IMAGE} # Environment variables used throughout this script. These must be set # otherwise bash will fail with an "unbound variable" error because of the `set @@ -23,10 +23,10 @@ export DRONE_TAG=${DRONE_TAG:-} export DEVELOPMENT=${DEVELOPMENT:-} if [ -n "$DEVELOPMENT" ]; then - DEFAULT_AGENT_IMAGE=${DEVELOPMENT_AGENT_IMAGE} + DEFAULT_ALLOY_IMAGE=${DEVELOPMENT_ALLOY_IMAGE} fi -export AGENT_IMAGE=${DEFAULT_AGENT_IMAGE} +export ALLOY_IMAGE=${DEFAULT_ALLOY_IMAGE} # We need to determine what version to assign to built binaries. If containers # are being built from a Drone tag trigger, we force the version to come from the @@ -62,19 +62,19 @@ fi export BUILD_PLATFORMS=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x case "$TARGET_CONTAINER" in - agent) + alloy) docker buildx build --push \ --platform $BUILD_PLATFORMS \ --build-arg RELEASE_BUILD=1 \ --build-arg VERSION="$VERSION" \ - -t "$AGENT_IMAGE:$TAG_VERSION" \ - -t "$AGENT_IMAGE:$BRANCH_TAG" \ - -f cmd/grafana-agent/Dockerfile \ + -t "$ALLOY_IMAGE:$TAG_VERSION" \ + -t "$ALLOY_IMAGE:$BRANCH_TAG" \ + -f cmd/alloy/Dockerfile \ . ;; *) - echo "Usage: $0 agent" + echo "Usage: $0 alloy" exit 1 ;; esac diff --git a/tools/ci/docker-containers-windows b/tools/ci/docker-containers-windows index e1b9f3eaed..f43db76536 100644 --- a/tools/ci/docker-containers-windows +++ b/tools/ci/docker-containers-windows @@ -22,8 +22,7 @@ export DRONE_BRANCH=${DRONE_BRANCH:-} export DOCKER_LOGIN=${DOCKER_LOGIN:-} export DOCKER_PASSWORD=${DOCKER_PASSWORD:-} -export AGENT_IMAGE=grafana/agent -export AGENTCTL_IMAGE=grafana/agentctl +export ALLOY_IMAGE=grafana/alloy if [ -n "$DRONE_TAG" ]; then VERSION=$DRONE_TAG @@ -50,28 +49,18 @@ else fi case "$TARGET_CONTAINER" in - agent) - docker build \ - -t "$AGENT_IMAGE:$VERSION_TAG" \ - -t "$AGENT_IMAGE:$BRANCH_TAG" \ - --build-arg VERSION="$VERSION" \ - --build-arg RELEASE_BUILD=1 \ - -f ./cmd/grafana-agent/Dockerfile.windows \ - . - ;; - - agentctl) - docker build \ - -t "$AGENTCTL_IMAGE:$VERSION_TAG" \ - -t "$AGENTCTL_IMAGE:$BRANCH_TAG" \ - --build-arg VERSION="$VERSION" \ - --build-arg RELEASE_BUILD=1 \ - -f ./cmd/grafana-agentctl/Dockerfile.windows \ + alloy) + docker build \ + -t "$ALLOY_IMAGE:$VERSION_TAG" \ + -t "$ALLOY_IMAGE:$BRANCH_TAG" \ + --build-arg VERSION="$VERSION" \ + --build-arg RELEASE_BUILD=1 \ + -f ./cmd/alloy/Dockerfile.windows \ . ;; *) - echo "Usage: $0 agent|agentctl" + echo "Usage: $0 alloy" exit 1 ;; esac @@ -81,18 +70,13 @@ if [ -n "$DOCKER_LOGIN" ] && [ -n "$DOCKER_PASSWORD" ]; then docker login -u "$DOCKER_LOGIN" -p "$DOCKER_PASSWORD" case "$TARGET_CONTAINER" in - agent) - docker push "$AGENT_IMAGE:$VERSION_TAG" - docker push "$AGENT_IMAGE:$BRANCH_TAG" - ;; - - agentctl) - docker push "$AGENTCTL_IMAGE:$VERSION_TAG" - docker push "$AGENTCTL_IMAGE:$BRANCH_TAG" + alloy) + docker push "$ALLOY_IMAGE:$VERSION_TAG" + docker push "$ALLOY_IMAGE:$BRANCH_TAG" ;; *) - echo "Usage: $0 agent|agentctl" + echo "Usage: $0 alloy" exit 1 ;; esac diff --git a/tools/make/build-container.mk b/tools/make/build-container.mk index 0daf5becb0..58d23e00b0 100644 --- a/tools/make/build-container.mk +++ b/tools/make/build-container.mk @@ -47,8 +47,8 @@ DOCKER_OPTS ?= -it # DOCKER_OPTS if they do. # -GO_CACHE_VOLUME := grafana-agent-build-container-gocache -GO_MODCACHE_VOLUME := grafana-agent-build-container-gomodcache +GO_CACHE_VOLUME := alloy-build-container-gocache +GO_MODCACHE_VOLUME := alloy-build-container-gomodcache define volume_exists $(shell docker volume inspect $(1) >/dev/null 2>&1 && echo 1 || echo "") diff --git a/tools/make/packaging.mk b/tools/make/packaging.mk index bd372f8165..dc24661f8a 100644 --- a/tools/make/packaging.mk +++ b/tools/make/packaging.mk @@ -3,7 +3,7 @@ PARENT_MAKEFILE := $(firstword $(MAKEFILE_LIST)) .PHONY: dist clean-dist -dist: dist-agent-binaries dist-agent-packages dist-agent-installer +dist: dist-alloy-binaries dist-alloy-packages dist-alloy-installer clean-dist: rm -rf ./dist/* ./dist.temp/* @@ -17,179 +17,179 @@ clean-dist: PACKAGING_VARS = RELEASE_BUILD=1 GO_TAGS="$(GO_TAGS)" GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) GOEXPERIMENT=$(GOEXPERIMENT) # -# agent release binaries +# Alloy release binaries # -dist-agent-binaries: dist/grafana-agent-linux-amd64 \ - dist/grafana-agent-linux-arm64 \ - dist/grafana-agent-linux-ppc64le \ - dist/grafana-agent-linux-s390x \ - dist/grafana-agent-darwin-amd64 \ - dist/grafana-agent-darwin-arm64 \ - dist/grafana-agent-windows-amd64.exe \ - dist/grafana-agent-freebsd-amd64 - -dist/grafana-agent-linux-amd64: GO_TAGS += netgo builtinassets promtail_journal_enabled -dist/grafana-agent-linux-amd64: GOOS := linux -dist/grafana-agent-linux-amd64: GOARCH := amd64 -dist/grafana-agent-linux-amd64: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent - -dist/grafana-agent-linux-arm64: GO_TAGS += netgo builtinassets promtail_journal_enabled -dist/grafana-agent-linux-arm64: GOOS := linux -dist/grafana-agent-linux-arm64: GOARCH := arm64 -dist/grafana-agent-linux-arm64: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent - -dist/grafana-agent-linux-ppc64le: GO_TAGS += netgo builtinassets promtail_journal_enabled -dist/grafana-agent-linux-ppc64le: GOOS := linux -dist/grafana-agent-linux-ppc64le: GOARCH := ppc64le -dist/grafana-agent-linux-ppc64le: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent - -dist/grafana-agent-linux-s390x: GO_TAGS += netgo builtinassets promtail_journal_enabled -dist/grafana-agent-linux-s390x: GOOS := linux -dist/grafana-agent-linux-s390x: GOARCH := s390x -dist/grafana-agent-linux-s390x: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent - -dist/grafana-agent-darwin-amd64: GO_TAGS += netgo builtinassets -dist/grafana-agent-darwin-amd64: GOOS := darwin -dist/grafana-agent-darwin-amd64: GOARCH := amd64 -dist/grafana-agent-darwin-amd64: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent - -dist/grafana-agent-darwin-arm64: GO_TAGS += netgo builtinassets -dist/grafana-agent-darwin-arm64: GOOS := darwin -dist/grafana-agent-darwin-arm64: GOARCH := arm64 -dist/grafana-agent-darwin-arm64: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent +dist-alloy-binaries: dist/alloy-linux-amd64 \ + dist/alloy-linux-arm64 \ + dist/alloy-linux-ppc64le \ + dist/alloy-linux-s390x \ + dist/alloy-darwin-amd64 \ + dist/alloy-darwin-arm64 \ + dist/alloy-windows-amd64.exe \ + dist/alloy-freebsd-amd64 + +dist/alloy-linux-amd64: GO_TAGS += netgo builtinassets promtail_journal_enabled +dist/alloy-linux-amd64: GOOS := linux +dist/alloy-linux-amd64: GOARCH := amd64 +dist/alloy-linux-amd64: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy + +dist/alloy-linux-arm64: GO_TAGS += netgo builtinassets promtail_journal_enabled +dist/alloy-linux-arm64: GOOS := linux +dist/alloy-linux-arm64: GOARCH := arm64 +dist/alloy-linux-arm64: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy + +dist/alloy-linux-ppc64le: GO_TAGS += netgo builtinassets promtail_journal_enabled +dist/alloy-linux-ppc64le: GOOS := linux +dist/alloy-linux-ppc64le: GOARCH := ppc64le +dist/alloy-linux-ppc64le: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy + +dist/alloy-linux-s390x: GO_TAGS += netgo builtinassets promtail_journal_enabled +dist/alloy-linux-s390x: GOOS := linux +dist/alloy-linux-s390x: GOARCH := s390x +dist/alloy-linux-s390x: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy + +dist/alloy-darwin-amd64: GO_TAGS += netgo builtinassets +dist/alloy-darwin-amd64: GOOS := darwin +dist/alloy-darwin-amd64: GOARCH := amd64 +dist/alloy-darwin-amd64: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy + +dist/alloy-darwin-arm64: GO_TAGS += netgo builtinassets +dist/alloy-darwin-arm64: GOOS := darwin +dist/alloy-darwin-arm64: GOARCH := arm64 +dist/alloy-darwin-arm64: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy # NOTE(rfratto): do not use netgo when building Windows binaries, which # prevents DNS short names from being resovable. See grafana/agent#4665. # # TODO(rfratto): add netgo back to Windows builds if a version of Go is # released which natively supports resolving DNS short names on Windows. -dist/grafana-agent-windows-amd64.exe: GO_TAGS += builtinassets -dist/grafana-agent-windows-amd64.exe: GOOS := windows -dist/grafana-agent-windows-amd64.exe: GOARCH := amd64 -dist/grafana-agent-windows-amd64.exe: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent +dist/alloy-windows-amd64.exe: GO_TAGS += builtinassets +dist/alloy-windows-amd64.exe: GOOS := windows +dist/alloy-windows-amd64.exe: GOARCH := amd64 +dist/alloy-windows-amd64.exe: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy # NOTE(rfratto): do not use netgo when building Windows binaries, which # prevents DNS short names from being resovable. See grafana/agent#4665. # # TODO(rfratto): add netgo back to Windows builds if a version of Go is # released which natively supports resolving DNS short names on Windows. -dist/grafana-agent-freebsd-amd64: GO_TAGS += netgo builtinassets -dist/grafana-agent-freebsd-amd64: GOOS := freebsd -dist/grafana-agent-freebsd-amd64: GOARCH := amd64 -dist/grafana-agent-freebsd-amd64: generate-ui - $(PACKAGING_VARS) AGENT_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent +dist/alloy-freebsd-amd64: GO_TAGS += netgo builtinassets +dist/alloy-freebsd-amd64: GOOS := freebsd +dist/alloy-freebsd-amd64: GOARCH := amd64 +dist/alloy-freebsd-amd64: generate-ui + $(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy # -# agent-service release binaries. +# alloy-service release binaries. # -# agent-service release binaries are intermediate build assets used for +# alloy-service release binaries are intermediate build assets used for # producing Windows system packages. As such, they are built in a dist.temp # directory instead of the normal dist directory. # # Only targets needed for system packages are used here. # -dist-agent-service-binaries: dist.temp/grafana-agent-service-windows-amd64.exe +dist-alloy-service-binaries: dist.temp/alloy-service-windows-amd64.exe -dist.temp/grafana-agent-service-windows-amd64.exe: GO_TAGS += builtinassets -dist.temp/grafana-agent-service-windows-amd64.exe: GOOS := windows -dist.temp/grafana-agent-service-windows-amd64.exe: GOARCH := amd64 -dist.temp/grafana-agent-service-windows-amd64.exe: generate-ui - $(PACKAGING_VARS) SERVICE_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) agent-service +dist.temp/alloy-service-windows-amd64.exe: GO_TAGS += builtinassets +dist.temp/alloy-service-windows-amd64.exe: GOOS := windows +dist.temp/alloy-service-windows-amd64.exe: GOARCH := amd64 +dist.temp/alloy-service-windows-amd64.exe: generate-ui + $(PACKAGING_VARS) SERVICE_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy-service # -# DEB and RPM grafana-agent packages. +# DEB and RPM alloy packages. # -AGENT_ENVIRONMENT_FILE_rpm := /etc/sysconfig/grafana-agent -AGENT_ENVIRONMENT_FILE_deb := /etc/default/grafana-agent +ALLOY_ENVIRONMENT_FILE_rpm := /etc/sysconfig/alloy +ALLOY_ENVIRONMENT_FILE_deb := /etc/default/alloy -# generate_agent_fpm(deb|rpm, package arch, agent arch, output file) -define generate_agent_fpm = - fpm -s dir -v $(AGENT_PACKAGE_VERSION) -a $(2) \ - -n grafana-agent --iteration $(AGENT_PACKAGE_RELEASE) -f \ +# generate_alloy_fpm(deb|rpm, package arch, Alloy arch, output file) +define generate_alloy_fpm = + fpm -s dir -v $(ALLOY_PACKAGE_VERSION) -a $(2) \ + -n alloy --iteration $(ALLOY_PACKAGE_RELEASE) -f \ --log error \ --license "Apache 2.0" \ --vendor "Grafana Labs" \ - --url "https://github.com/grafana/agent" \ + --url "https://github.com/grafana/alloy" \ --rpm-digest sha256 \ -t $(1) \ - --after-install packaging/grafana-agent/$(1)/control/postinst \ - --before-remove packaging/grafana-agent/$(1)/control/prerm \ - --config-files /etc/grafana-agent.river \ - --config-files $(AGENT_ENVIRONMENT_FILE_$(1)) \ + --after-install packaging/alloy/$(1)/control/postinst \ + --before-remove packaging/alloy/$(1)/control/prerm \ + --config-files /etc/alloy.river \ + --config-files $(ALLOY_ENVIRONMENT_FILE_$(1)) \ --rpm-rpmbuild-define "_build_id_links none" \ --package $(4) \ - dist/grafana-agent-linux-$(3)=/usr/bin/grafana-agent \ - packaging/grafana-agent-/grafana-agent.river=/etc/grafana-agent.river \ - packaging/grafana-agent-/environment-file=$(AGENT_ENVIRONMENT_FILE_$(1)) \ - packaging/grafana-agent-/$(1)/grafana-agent.service=/usr/lib/systemd/system/grafana-agent.service + dist/alloy-linux-$(3)=/usr/bin/alloy \ + packaging/alloy/alloy.river=/etc/alloy.river \ + packaging/alloy/environment-file=$(ALLOY_ENVIRONMENT_FILE_$(1)) \ + packaging/alloy/$(1)/alloy.service=/usr/lib/systemd/system/alloy.service endef -AGENT_PACKAGE_VERSION := $(patsubst v%,%,$(VERSION)) -AGENT_PACKAGE_RELEASE := 1 -AGENT_PACKAGE_PREFIX := dist/grafana-agent-$(AGENT_PACKAGE_VERSION)-$(AGENT_PACKAGE_RELEASE) +ALLOY_PACKAGE_VERSION := $(patsubst v%,%,$(VERSION)) +ALLOY_PACKAGE_RELEASE := 1 +ALLOY_PACKAGE_PREFIX := dist/alloy-$(ALLOY_PACKAGE_VERSION)-$(ALLOY_PACKAGE_RELEASE) -.PHONY: dist-agent-packages -dist-agent-packages: dist-agent-packages-amd64 \ - dist-agent-packages-arm64 \ - dist-agent-packages-ppc64le \ - dist-agent-packages-s390x +.PHONY: dist-alloy-packages +dist-alloy-packages: dist-alloy-packages-amd64 \ + dist-alloy-packages-arm64 \ + dist-alloy-packages-ppc64le \ + dist-alloy-packages-s390x -.PHONY: dist-agent-packages-amd64 -dist-agent-packages-amd64: dist/grafana-agent-linux-amd64 +.PHONY: dist-alloy-packages-amd64 +dist-alloy-packages-amd64: dist/grafana-alloy-linux-amd64 ifeq ($(USE_CONTAINER),1) $(RERUN_IN_CONTAINER) else - $(call generate_agent_fpm,deb,amd64,amd64,$(AGENT_PACKAGE_PREFIX).amd64.deb) - $(call generate_agent_fpm,rpm,x86_64,amd64,$(AGENT_PACKAGE_PREFIX).amd64.rpm) + $(call generate_alloy_fpm,deb,amd64,amd64,$(ALLOY_PACKAGE_PREFIX).amd64.deb) + $(call generate_alloy_fpm,rpm,x86_64,amd64,$(ALLOY_PACKAGE_PREFIX).amd64.rpm) endif -.PHONY: dist-agent-packages-arm64 -dist-agent-packages-arm64: dist/grafana-agent-linux-arm64 +.PHONY: dist-alloy-packages-arm64 +dist-alloy-packages-arm64: dist/grafana-alloy-linux-arm64 ifeq ($(USE_CONTAINER),1) $(RERUN_IN_CONTAINER) else - $(call generate_agent_fpm,deb,arm64,arm64,$(AGENT_PACKAGE_PREFIX).arm64.deb) - $(call generate_agent_fpm,rpm,aarch64,arm64,$(AGENT_PACKAGE_PREFIX).arm64.rpm) + $(call generate_alloy_fpm,deb,arm64,arm64,$(ALLOY_PACKAGE_PREFIX).arm64.deb) + $(call generate_alloy_fpm,rpm,aarch64,arm64,$(ALLOY_PACKAGE_PREFIX).arm64.rpm) endif -.PHONY: dist-agent-packages-ppc64le -dist-agent-packages-ppc64le: dist/grafana-agent-linux-ppc64le +.PHONY: dist-alloy-packages-ppc64le +dist-alloy-packages-ppc64le: dist/alloy-linux-ppc64le ifeq ($(USE_CONTAINER),1) $(RERUN_IN_CONTAINER) else - $(call generate_agent_fpm,deb,ppc64el,ppc64le,$(AGENT_PACKAGE_PREFIX).ppc64el.deb) - $(call generate_agent_fpm,rpm,ppc64le,ppc64le,$(AGENT_PACKAGE_PREFIX).ppc64le.rpm) + $(call generate_alloy_fpm,deb,ppc64el,ppc64le,$(ALLOY_PACKAGE_PREFIX).ppc64el.deb) + $(call generate_alloy_fpm,rpm,ppc64le,ppc64le,$(ALLOY_PACKAGE_PREFIX).ppc64le.rpm) endif -.PHONY: dist-agent-packages-s390x -dist-agent-packages-s390x: dist/grafana-agent-linux-s390x +.PHONY: dist-alloy-packages-s390x +dist-alloy-packages-s390x: dist/alloy-linux-s390x ifeq ($(USE_CONTAINER),1) $(RERUN_IN_CONTAINER) else - $(call generate_agent_fpm,deb,s390x,s390x,$(AGENT_PACKAGE_PREFIX).s390x.deb) - $(call generate_agent_fpm,rpm,s390x,s390x,$(AGENT_PACKAGE_PREFIX).s390x.rpm) + $(call generate_alloy_fpm,deb,s390x,s390x,$(ALLOY_PACKAGE_PREFIX).s390x.deb) + $(call generate_alloy_fpm,rpm,s390x,s390x,$(ALLOY_PACKAGE_PREFIX).s390x.rpm) endif # # Windows installer # -.PHONY: dist-agent-installer -dist-agent-installer: dist/grafana-agent-windows-amd64.exe dist.temp/grafana-agent-service-windows-amd64.exe +.PHONY: dist-alloy-installer +dist-alloy-installer: dist/alloy-windows-amd64.exe dist.temp/alloy-service-windows-amd64.exe ifeq ($(USE_CONTAINER),1) $(RERUN_IN_CONTAINER) else # quotes around mkdir are mandatory. ref: https://github.com/grafana/agent/pull/5664#discussion_r1378796371 "mkdir" -p dist - makensis -V4 -DVERSION=$(VERSION) -DOUT="../../../dist/grafana-agent-installer.exe" ./packaging/grafana-agent/windows/install_script.nsis + makensis -V4 -DVERSION=$(VERSION) -DOUT="../../../dist/alloy-installer.exe" ./packaging/alloy/windows/install_script.nsis endif