Skip to content

Commit

Permalink
misc: rename binaries to Alloy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rfratto committed Mar 25, 2024
1 parent 77fba86 commit 6ddf401
Show file tree
Hide file tree
Showing 47 changed files with 410 additions and 431 deletions.
4 changes: 2 additions & 2 deletions .drone/pipelines/check_containers.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
];

(
Expand Down
2 changes: 1 addition & 1 deletion .drone/pipelines/crosscompile.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local os_arch_tuples = [


local targets = [
'agent',
'alloy',
];

local build_environments(targets, tuples, image) = std.flatMap(function(target) (
Expand Down
10 changes: 5 additions & 5 deletions .drone/pipelines/publish.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: [{
Expand Down Expand Up @@ -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: [{
Expand Down
2 changes: 1 addition & 1 deletion .drone/pipelines/test_packages.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
}],
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 4 additions & 4 deletions .github/workflows/publish-documentation-next.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
sarif_file: 'trivy-results.sarif'
2 changes: 1 addition & 1 deletion .github/workflows/update-make-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 27 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
##
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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

#
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/alloy-service/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Command alloy-service is a Windows binary which manages Alloy as a Windows
// service.
package main
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"golang.org/x/sys/windows/svc"
)

const serviceName = "Grafana Agent"
const serviceName = "Grafana Alloy"

func main() {
logger, err := newLogger()
Expand Down Expand Up @@ -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}
}()
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6ddf401

Please sign in to comment.