Skip to content

Commit

Permalink
Rename binaries and paths from collector-sidecar to sidecar (#237)
Browse files Browse the repository at this point in the history
* Rename binaries and paths from collector-sidecar to sidecar

This fits the new naming scheme and also makes it possible to install
the old and the new implementation in parallel to simplify the
migration.

* Rename collector-id to node-id
  • Loading branch information
bernd authored and Marius Sturm committed Jun 26, 2018
1 parent 7164452 commit d92f8e5
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 153 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dist/cache
dist/pkg
dist/tmp-build
dist/tmp-dest
dist/graylog_collector_sidecar_installer.exe
dist/collectors/

.filebeat
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST_SUITE = \

all: clean misc build

misc: ## Build NXMock for testing collector-sidecar
misc: ## Build NXMock for testing sidecar
$(GO) build -o misc/nxmock/nxlog misc/nxmock/main.go

fmt: ## Run gofmt
Expand Down Expand Up @@ -51,44 +51,44 @@ endif
test: ## Run tests
$(GO) test -v $(TEST_SUITE)

build: ## Build collector-sidecar binary for local target system
$(GO) build $(BUILD_OPTS) -v -i -o graylog-collector-sidecar
build: ## Build sidecar binary for local target system
$(GO) build $(BUILD_OPTS) -v -i -o graylog-sidecar

build-all: build-linux build-linux32 build-darwin build-windows build-windows32

build-linux: ## Build collector-sidecar binary for Linux
build-linux: ## Build sidecar binary for Linux
@mkdir -p build/$(COLLECTOR_VERSION)/linux/amd64
GOOS=linux GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/linux/amd64/graylog-collector-sidecar
GOOS=linux GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/linux/amd64/graylog-sidecar

solaris-sigar-patch:
# https://github.com/cloudfoundry/gosigar/pull/28
@if [ ! -e vendor/github.com/cloudfoundry/gosigar/sigar_solaris.go ]; then \
wget -O vendor/github.com/cloudfoundry/gosigar/sigar_solaris.go https://raw.githubusercontent.com/amitkris/gosigar/9fc0903125acd1a0dc7635f8670088339865bcd5/sigar_solaris.go; \
fi

build-solaris: solaris-sigar-patch ## Build collector-sidecar binary for Solaris/OmniOS/Illumos
build-solaris: solaris-sigar-patch ## Build sidecar binary for Solaris/OmniOS/Illumos
@mkdir -p build/$(COLLECTOR_VERSION)/solaris/amd64
GOOS=solaris GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/solaris/amd64/graylog-collector-sidecar
GOOS=solaris GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/solaris/amd64/graylog-sidecar

build-linux32: ## Build collector-sidecar binary for Linux 32bit
build-linux32: ## Build sidecar binary for Linux 32bit
@mkdir -p build/$(COLLECTOR_VERSION)/linux/386
GOOS=linux GOARCH=386 $(GO) build $(BUILD_OPTS) -pkgdir $(GOPATH)/go_linux32 -v -i -o build/$(COLLECTOR_VERSION)/linux/386/graylog-collector-sidecar
GOOS=linux GOARCH=386 $(GO) build $(BUILD_OPTS) -pkgdir $(GOPATH)/go_linux32 -v -i -o build/$(COLLECTOR_VERSION)/linux/386/graylog-sidecar

build-darwin: ## Build collector-sidecar binary for OSX
build-darwin: ## Build sidecar binary for OSX
@mkdir -p build/$(COLLECTOR_VERSION)/darwin/amd64
GOOS=darwin GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/darwin/amd64/graylog-collector-sidecar
GOOS=darwin GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/darwin/amd64/graylog-sidecar

build-freebsd:
@mkdir -p build/$(COLLECTOR_VERSION)/freebsd/amd64
GOOS=freebsd GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/freebsd/amd64/graylog-collector-sidecar
GOOS=freebsd GOARCH=amd64 $(GO) build $(BUILD_OPTS) -v -i -o build/$(COLLECTOR_VERSION)/freebsd/amd64/graylog-sidecar

build-windows: ## Build collector-sidecar binary for Windows
build-windows: ## Build sidecar binary for Windows
@mkdir -p build/$(COLLECTOR_VERSION)/windows/amd64
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc $(GO) build $(BUILD_OPTS) -pkgdir $(GOPATH)/go_win -v -i -o build/$(COLLECTOR_VERSION)/windows/amd64/graylog-collector-sidecar.exe
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc $(GO) build $(BUILD_OPTS) -pkgdir $(GOPATH)/go_win -v -i -o build/$(COLLECTOR_VERSION)/windows/amd64/graylog-sidecar.exe

build-windows32: ## Build collector-sidecar binary for Windows 32bit
build-windows32: ## Build sidecar binary for Windows 32bit
@mkdir -p build/$(COLLECTOR_VERSION)/windows/386
GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc $(GO) build $(BUILD_OPTS) -pkgdir $(GOPATH)/go_win32 -v -i -o build/$(COLLECTOR_VERSION)/windows/386/graylog-collector-sidecar.exe
GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc $(GO) build $(BUILD_OPTS) -pkgdir $(GOPATH)/go_win32 -v -i -o build/$(COLLECTOR_VERSION)/windows/386/graylog-sidecar.exe

package-all: prepare-package package-linux package-linux32 package-windows package-tar

Expand All @@ -113,7 +113,7 @@ package-windows: ## Create Windows installer

package-tar: ## Create tar archive for all platforms
@mkdir -p dist/pkg
@tar --transform="s|/build|/collector-sidecar|" -Pczf dist/pkg/collector-sidecar-$(COLLECTOR_VERSION)$(COLLECTOR_VERSION_SUFFIX).tar.gz ./build
@tar --transform="s|/build|/graylog-sidecar|" -Pczf dist/pkg/graylog-sidecar-$(COLLECTOR_VERSION)$(COLLECTOR_VERSION_SUFFIX).tar.gz ./build

help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | $(AWK) 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Graylog Collector Sidecar
# Graylog Sidecar

[![Build Status](https://travis-ci.org/Graylog2/collector-sidecar.svg?branch=master)](https://travis-ci.org/Graylog2/collector-sidecar) [![Go Report Card](https://goreportcard.com/badge/github.com/graylog2/collector-sidecar)](https://goreportcard.com/report/github.com/graylog2/collector-sidecar)

Expand All @@ -8,7 +8,7 @@ The master branch is tracking the upcoming 1.0 version of the sidecar. Please se

**Required Graylog version:** 3.0 and later.

The Graylog Collector Sidecar is a supervisor process for 3rd party log collectors like NXLog and filebeat. The Sidecar program is able to fetch and validate configuration files from a Graylog server for various log collectors. You can think of it like a centralized configuration and process management system for your log collectors.
The Graylog Sidecar is a supervisor process for 3rd party log collectors like NXLog and filebeat. The Sidecar program is able to fetch and validate configuration files from a Graylog server for various log collectors. You can think of it like a centralized configuration and process management system for your log collectors.

## Documentation

Expand All @@ -32,56 +32,56 @@ Especially the [Step-by-Step](http://docs.graylog.org/en/2.4/pages/collector_sid
The Beats binaries (Filebeat and Winlogeventbeat) are included in the Sidecar package. So installation is just one command.

```
$ sudo dpkg -i collector-sidecar_1.0.0-1_amd64.deb
$ sudo dpkg -i graylog-sidecar_1.0.0-1_amd64.deb
```

Edit `/etc/graylog/collector-sidecar/collector_sidecar.yml`, you should set at least the correct URL to your Graylog server and proper tags.
Edit `/etc/graylog/sidecar/sidecar.yml`, you should set at least the correct URL to your Graylog server and proper tags.
The tags are used to define which configurations the host should receive.

Create a system service and start it

```
$ sudo graylog-collector-sidecar -service install
$ sudo graylog-sidecar -service install
[Ubuntu 14.04 with Upstart]
$ sudo start collector-sidecar
$ sudo start graylog-sidecar
[Ubuntu 16.04 with Systemd]
$ sudo systemctl start collector-sidecar
$ sudo systemctl start graylog-sidecar
```

**CentOS**

```
$ sudo rpm -i collector-sidecar-1.0.0-1.x86_64.rpm
$ sudo rpm -i graylog-sidecar-1.0.0-1.x86_64.rpm
```

Activate the Sidecar as a system service

```
$ sudo graylog-collector-sidecar -service install
$ sudo systemctl start collector-sidecar
$ sudo graylog-sidecar -service install
$ sudo systemctl start graylog-sidecar
```

**Windows**

_**The Windows installation path changed to `C:\Program Files` with version 0.0.9, please stop and uninstall former installations before doing the update**_

```
$ collector_sidecar_installer.exe
$ graylog_sidecar_installer.exe
```

It's also possible to run the installer in silent mode with

```
$ collector_sidecar_installer.exe /S -SERVERURL=http://10.0.2.2:9000/api -TAGS="windows,iis"
$ graylog_sidecar_installer.exe /S -SERVERURL=http://10.0.2.2:9000/api -TAGS="windows,iis"
```

Edit `C:\Program Files\graylog\collector-sidecar\collector_sidecar.yml`.
Edit `C:\Program Files\graylog\sidecar\sidecar.yml`.

```
$ C:\Program Files\graylog\collector-sidecar\graylog-collector-sidecar.exe -service install
$ C:\Program Files\graylog\collector-sidecar\graylog-collector-sidecar.exe -service start
$ C:\Program Files\graylog\sidecar\graylog-sidecar.exe -service install
$ C:\Program Files\graylog\sidecar\graylog-sidecar.exe -service start
```

All installer options:
Expand All @@ -90,7 +90,7 @@ All installer options:
|-----------------------|---------------------------------------|---------------------------|
| `-SERVERURL` | URL to the Graylog API | http://127.0.0.1:9000/api |
| `-TAGS` | List of tags | "windows, iis" |
| `-NODEID` | Name of the instance | graylog-collector-sidecar |
| `-NODEID` | Name of the instance | graylog-sidecar |
| `-UPDATE_INTERVAL` | seconds between configuration updates | 10 |
| `-TLS_SKIP_VERIFY` | ignore self-signed API certificates | false |
| `-SEND_STATUS` | send host metrics back to Graylog | true |
Expand All @@ -109,20 +109,20 @@ Install the NXLog package from the offical download [page](https://nxlog.org/pro
$ sudo update-rc.d -f nxlog remove
$ sudo gpasswd -a nxlog adm
$ sudo dpkg -i collector-sidecar_1.0.0-1_amd64.deb
$ sudo chown -R nxlog.nxlog /var/spool/collector-sidecar/nxlog
$ sudo dpkg -i graylog-sidecar_1.0.0-1_amd64.deb
$ sudo chown -R nxlog.nxlog /var/spool/graylog-sidecar/nxlog
```

Edit `/etc/graylog/collector-sidecar/collector_sidecar.yml`accordingly.
Edit `/etc/graylog/sidecar/sidecar.yml`accordingly.

```
$ sudo graylog-collector-sidecar -service install
$ sudo graylog-sidecar -service install
[Ubuntu 14.04 with Upstart]
$ sudo start collector-sidecar
$ sudo start graylog-sidecar
[Ubuntu 16.04 with Systemd]
$ sudo systemctl start collector-sidecar
$ sudo systemctl start graylog-sidecar
```

**CentOS**
Expand All @@ -131,16 +131,16 @@ Edit `/etc/graylog/collector-sidecar/collector_sidecar.yml`accordingly.
$ sudo service nxlog stop
$ sudo chkconfig --del nxlog
$ sudo gpasswd -a nxlog root
$ sudo chown -R nxlog.nxlog /var/spool/collector-sidecar/nxlog
$ sudo chown -R nxlog.nxlog /var/spool/graylog-sidecar/nxlog
$ sudo rpm -i collector-sidecar-1.0.0-1.x86_64.rpm
$ sudo rpm -i graylog-sidecar-1.0.0-1.x86_64.rpm
```

Activate the Sidecar as a system service

```
$ sudo graylog-collector-sidecar -service install
$ sudo systemctl start collector-sidecar
$ sudo graylog-sidecar -service install
$ sudo systemctl start graylog-sidecar
```

**Windows**
Expand All @@ -155,29 +155,29 @@ system service. We just need the binaries installed on that host.
```
$ C:\Program Files (x86)\nxlog\nxlog -u
$ collector_sidecar_installer.exe
$ graylog_sidecar_installer.exe
```

Edit `C:\Program Files\graylog\collector-sidecar\collector_sidecar.yml`, you should set at least the correct URL to your Graylog server and proper tags.
Edit `C:\Program Files\graylog\sidecar\sidecar.yml`, you should set at least the correct URL to your Graylog server and proper tags.

```
$ C:\Program Files\graylog\collector-sidecar\graylog-collector-sidecar.exe -service install
$ C:\Program Files\graylog\collector-sidecar\graylog-collector-sidecar.exe -service start
$ C:\Program Files\graylog\sidecar\graylog-sidecar.exe -service install
$ C:\Program Files\graylog\sidecar\graylog-sidecar.exe -service start
```

## Uninstall on Windows

```
$ C:\Program Files\graylog\collector-sidecar\graylog-collector-sidecar.exe -service stop
$ C:\Program Files\graylog\collector-sidecar\graylog-collector-sidecar.exe -service uninstall
$ C:\Program Files\graylog\sidecar\graylog-sidecar.exe -service stop
$ C:\Program Files\graylog\sidecar\graylog-sidecar.exe -service uninstall
```

## Debugging

Run the Sidecar in foreground mode for debugging purposes. Simply call it like this and look out for error messages:

```
$ graylog-collector-sidecar -debug -c /etc/graylog/collector-sidecar/collector_sidecar.yml
$ graylog-sidecar -debug -c /etc/graylog/sidecar/sidecar.yml
```

## Configuration
Expand Down Expand Up @@ -208,5 +208,5 @@ There are a couple of configuration settings for the Sidecar:

## Development

There is a collector mock program in order to use the collector-sidecar without actually running a collector like NXLog. Simply build it with
There is a collector mock program in order to use the sidecar without actually running a collector like NXLog. Simply build it with
`make misc` und use the option `binary_path: misc/nxmock/nxlog`.
25 changes: 0 additions & 25 deletions collector_sidecar_windows.yml

This file was deleted.

6 changes: 3 additions & 3 deletions common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ func GetCollectorId(collectorId string) string {
filePath := strings.SplitAfterN(collectorId, ":", 2)[1]
err := FileExists(filePath)
if err != nil {
log.Info("collector-id file doesn't exist, generating a new one")
log.Info("node-id file doesn't exist, generating a new one")
CreatePathToFile(filePath)
ioutil.WriteFile(filePath, []byte(RandomUuid()), 0644)
}
file, err := ioutil.ReadFile(filePath)
if err != nil {
log.Fatal("Can not read collector-id file: ", err)
log.Fatal("Can not read node-id file: ", err)
}
id = strings.Trim(string(file), " \n")
}

if id != "" && !cfgfile.ValidateConfig() {
log.Info("Using collector-id: ", id)
log.Info("Using node-id: ", id)
}
return id
}
Expand Down
6 changes: 3 additions & 3 deletions common/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

func TestGetCollectorIdFromExistingFile(t *testing.T) {
content := []byte(" 2135792e-8556-4bf0-8aef-503f29890b09 \n")
tmpfile, err := ioutil.TempFile("", "test-collector-id")
tmpfile, err := ioutil.TempFile("", "test-node-id")
if err != nil {
t.Fatal(err)
}
Expand All @@ -45,13 +45,13 @@ func TestGetCollectorIdFromExistingFile(t *testing.T) {
}

func TestGetCollectorIdFromNonExistingFile(t *testing.T) {
dir, err := ioutil.TempDir("", "test-collector-id")
dir, err := ioutil.TempDir("", "test-node-id")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)

tmpfile := filepath.Join(dir, "collector-id")
tmpfile := filepath.Join(dir, "node-id")
result := GetCollectorId("file:/" + tmpfile)
match, err := regexp.Match("^[0-9a-f]{8}-", []byte(result))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func (ctx *Ctx) LoadConfig(path *string) error {
if ctx.UserConfig.CachePath == "" {
var cachePath string
if runtime.GOOS == "windows" {
cachePath = filepath.Join(os.Getenv("SystemDrive")+"\\", "Program Files", "graylog", "collector-sidecar", "cache")
cachePath = filepath.Join(os.Getenv("SystemDrive")+"\\", "Program Files", "graylog", "sidecar", "cache")
} else {
cachePath = filepath.Join("/var", "cache", "graylog", "collector-sidecar")
cachePath = filepath.Join("/var", "cache", "graylog", "sidecar")
}
ctx.UserConfig.CachePath = cachePath
log.Errorf("No cache directory was configured. Using default: %s", cachePath)
Expand Down
2 changes: 1 addition & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewConfig() *DaemonConfig {
}

dc := &DaemonConfig{
Name: "collector-sidecar",
Name: "graylog-sidecar",
DisplayName: "Graylog collector sidecar",
Description: "Wrapper service for Graylog controlled collector",
Dir: rootDir,
Expand Down
Loading

0 comments on commit d92f8e5

Please sign in to comment.