From d92f8e5d0c4c1fe934b3a20f3c4d8eb7fd7f509d Mon Sep 17 00:00:00 2001 From: Bernd Ahlers Date: Tue, 26 Jun 2018 15:56:06 +0200 Subject: [PATCH] Rename binaries and paths from collector-sidecar to sidecar (#237) * 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 --- .gitignore | 1 - Makefile | 34 ++++++------ README.md | 68 ++++++++++++------------ collector_sidecar_windows.yml | 25 --------- common/helper.go | 6 +-- common/helper_test.go | 6 +-- context/context.go | 4 +- daemon/daemon.go | 2 +- dist/recipe.nsi | 78 ++++++++++++++-------------- dist/recipe.rb | 18 +++---- dist/recipe32.rb | 20 +++---- logger/hooks/hooks.go | 2 +- main.go | 6 +-- collector_sidecar.yml => sidecar.yml | 10 ++-- sidecar_windows.yml | 25 +++++++++ 15 files changed, 152 insertions(+), 153 deletions(-) delete mode 100644 collector_sidecar_windows.yml rename collector_sidecar.yml => sidecar.yml (52%) create mode 100644 sidecar_windows.yml diff --git a/.gitignore b/.gitignore index 4bbb7a6..0f3c74c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,6 @@ dist/cache dist/pkg dist/tmp-build dist/tmp-dest -dist/graylog_collector_sidecar_installer.exe dist/collectors/ .filebeat diff --git a/Makefile b/Makefile index 3637c9c..719a58d 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -51,14 +51,14 @@ 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 @@ -66,29 +66,29 @@ solaris-sigar-patch: 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 @@ -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}' diff --git a/README.md b/README.md index 07b9315..8827d93 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -32,35 +32,35 @@ 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** @@ -68,20 +68,20 @@ Activate the Sidecar as a system service _**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: @@ -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 | @@ -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** @@ -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** @@ -155,21 +155,21 @@ 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 @@ -177,7 +177,7 @@ Edit `C:\Program Files\graylog\collector-sidecar\collector_sidecar.yml`, you sho 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 @@ -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`. diff --git a/collector_sidecar_windows.yml b/collector_sidecar_windows.yml deleted file mode 100644 index 35b4f6b..0000000 --- a/collector_sidecar_windows.yml +++ /dev/null @@ -1,25 +0,0 @@ -server_url: -update_interval: -tls_skip_verify: -send_status: -list_log_files: -node_id: -collector_id: file:C:\Program Files\graylog\collector-sidecar\collector-id -cache_path: C:\Program Files\graylog\collector-sidecar\cache -log_path: C:\Program Files\graylog\collector-sidecar\logs -log_rotation_time: 86400 -log_max_age: 604800 -tags: -backends: - - name: nxlog - enabled: - binary_path: C:\Program Files (x86)\nxlog\nxlog.exe - configuration_path: C:\Program Files\graylog\collector-sidecar\generated\nxlog.conf - - name: winlogbeat - enabled: - binary_path: C:\Program Files\graylog\collector-sidecar\winlogbeat.exe - configuration_path: C:\Program Files\graylog\collector-sidecar\generated\winlogbeat.yml - - name: filebeat - enabled: - binary_path: C:\Program Files\graylog\collector-sidecar\filebeat.exe - configuration_path: C:\Program Files\graylog\collector-sidecar\generated\filebeat.yml diff --git a/common/helper.go b/common/helper.go index abb1d89..c528e85 100644 --- a/common/helper.go +++ b/common/helper.go @@ -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 } diff --git a/common/helper_test.go b/common/helper_test.go index 3f30dc6..99b5cd2 100644 --- a/common/helper_test.go +++ b/common/helper_test.go @@ -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) } @@ -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 { diff --git a/context/context.go b/context/context.go index 9c1eb1d..5a6d3be 100644 --- a/context/context.go +++ b/context/context.go @@ -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) diff --git a/daemon/daemon.go b/daemon/daemon.go index 49bf937..1eda470 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -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, diff --git a/dist/recipe.nsi b/dist/recipe.nsi index 3096f13..c2b9c7d 100644 --- a/dist/recipe.nsi +++ b/dist/recipe.nsi @@ -1,9 +1,9 @@ ; ------------------------------- ; Start - Name "Graylog Collector Sidecar" + Name "Graylog Sidecar" !define MUI_FILE "savefile" - !define MUI_BRANDINGTEXT "Graylog Collector Sidecar v${VERSION}${VERSION_SUFFIX}" + !define MUI_BRANDINGTEXT "Graylog Sidecar v${VERSION}${VERSION_SUFFIX}" CRCCheck On SetCompressor "bzip2" @@ -20,14 +20,14 @@ VIProductVersion "0.${VERSION}${VERSION_SUFFIX}" VIAddVersionKey "FileVersion" "${VERSION}" - VIAddVersionKey "FileDescription" "Graylog Collector Sidecar" + VIAddVersionKey "FileDescription" "Graylog Sidecar" VIAddVersionKey "LegalCopyright" "Graylog, Inc." ;--------------------------------- ;General !searchreplace SUFFIX '${VERSION_SUFFIX}' "-" "." - OutFile "pkg/collector_sidecar_installer_${VERSION}-${REVISION}${SUFFIX}.exe" + OutFile "pkg/graylog_sidecar_installer_${VERSION}-${REVISION}${SUFFIX}.exe" RequestExecutionLevel admin ;Require admin rights ShowInstDetails "nevershow" ShowUninstDetails "nevershow" @@ -95,7 +95,7 @@ SetRegView 32 Strcpy $GraylogDir "$PROGRAMFILES32\Graylog" ${EndIf} - Strcpy $INSTDIR "$GraylogDir\collector-sidecar" + Strcpy $INSTDIR "$GraylogDir\sidecar" !macroend ;-------------------------------- @@ -121,56 +121,56 @@ Section "Install" ${EndIf} SetOverwrite off - File /oname=collector_sidecar.yml "../collector_sidecar_windows.yml" + File /oname=sidecar.yml "../sidecar_windows.yml" SetOverwrite on - File /oname=collector_sidecar.yml.dist "../collector_sidecar_windows.yml" + File /oname=sidecar.yml.dist "../sidecar_windows.yml" File "../COPYING" File "graylog.ico" ;Stop service to allow binary upgrade - !insertmacro _IfKeyExists HKLM "SYSTEM\CurrentControlSet\Services" "collector-sidecar" + !insertmacro _IfKeyExists HKLM "SYSTEM\CurrentControlSet\Services" "graylog-sidecar" Pop $R0 ${If} $R0 = 1 - ExecWait '"$INSTDIR\graylog-collector-sidecar.exe" -service stop' + ExecWait '"$INSTDIR\graylog-sidecar.exe" -service stop' ${EndIf} ${If} ${RunningX64} - File /oname=Graylog-collector-sidecar.exe "../build/${VERSION}/windows/amd64/graylog-collector-sidecar.exe" + File /oname=Graylog-sidecar.exe "../build/${VERSION}/windows/amd64/graylog-sidecar.exe" ${Else} - File /oname=Graylog-collector-sidecar.exe "../build/${VERSION}/windows/386/graylog-collector-sidecar.exe" + File /oname=Graylog-sidecar.exe "../build/${VERSION}/windows/386/graylog-sidecar.exe" ${EndIf} ;When we stop the Sidecar service we also turn it on again ${If} $R0 = 1 - ExecWait '"$INSTDIR\graylog-collector-sidecar.exe" -service start' + ExecWait '"$INSTDIR\graylog-sidecar.exe" -service start' ${EndIf} WriteUninstaller "$INSTDIR\uninstall.exe" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ - "DisplayName" "Graylog Collector Sidecar" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ + "DisplayName" "Graylog Sidecar" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "DisplayIcon" "$\"$INSTDIR\graylog.ico$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "DisplayVersion" "${VERSION}${VERSION_SUFFIX}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "InstallLocation" "$INSTDIR" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "RegCompany" "Graylog, Inc." - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "Publisher" "Graylog, Inc." - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "HelpLink" "https://www.graylog.org" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "NoModify" "1" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "NoRepair" "1" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" \ + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" \ "EstimatedSize" "25000" @@ -240,7 +240,7 @@ Section "Post" StrCpy $Tags "windows, iis" ${EndIf} ${If} $NodeId == "" - StrCpy $NodeId "graylog-collector-sidecar" + StrCpy $NodeId "graylog-sidecar" ${EndIf} ${If} $UpdateInterval == "" StrCpy $UpdateInterval "10" @@ -261,15 +261,15 @@ Section "Post" StrCpy $WinlogbeatEnabled "true" ${EndIf} - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $ServerUrl - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" `[$Tags]` - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $NodeId - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $UpdateInterval - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $TlsSkipVerify - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $SendStatus - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $NxlogEnabled - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $FilebeatEnabled - !insertmacro _ReplaceInFile "$INSTDIR\collector_sidecar.yml" "" $WinlogbeatEnabled + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $ServerUrl + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" `[$Tags]` + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $NodeId + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $UpdateInterval + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $TlsSkipVerify + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $SendStatus + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $NxlogEnabled + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $FilebeatEnabled + !insertmacro _ReplaceInFile "$INSTDIR\sidecar.yml" "" $WinlogbeatEnabled SectionEnd @@ -278,8 +278,8 @@ SectionEnd Section "Uninstall" ;Uninstall system service - ExecWait '"$INSTDIR\graylog-collector-sidecar.exe" -service stop' - ExecWait '"$INSTDIR\graylog-collector-sidecar.exe" -service uninstall' + ExecWait '"$INSTDIR\graylog-sidecar.exe" -service stop' + ExecWait '"$INSTDIR\graylog-sidecar.exe" -service uninstall' ;Delete Files RMDir /r "$INSTDIR\*.*" @@ -290,7 +290,7 @@ Section "Uninstall" RMDir $GraylogDir ;Remove uninstall entries in the registry - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar" + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogSidecar" SectionEnd @@ -345,7 +345,7 @@ Function nsDialogsPage ${NSD_CreateLabel} 0 100 100% 12u "Enter the name of this instance:" Pop $Label - ${NSD_CreateText} 50 120 75% 12u "graylog-collector-sidecar" + ${NSD_CreateText} 50 120 75% 12u "graylog-sidecar" Pop $InputNodeId nsDialogs::Show diff --git a/dist/recipe.rb b/dist/recipe.rb index cb200af..bea36f2 100644 --- a/dist/recipe.rb +++ b/dist/recipe.rb @@ -3,19 +3,19 @@ class GraylogSidecar < FPM::Cookery::Recipe description 'Graylog collector sidecar' - name 'collector-sidecar' + name 'graylog-sidecar' version data.version revision data.revision homepage 'https://graylog.org' arch 'amd64' - source "file:../../build/#{version}/linux/amd64/graylog-collector-sidecar" + source "file:../../build/#{version}/linux/amd64/graylog-sidecar" maintainer 'Graylog, Inc. ' vendor 'graylog' license 'GPLv3' - config_files '/etc/graylog/collector-sidecar/collector_sidecar.yml' + config_files '/etc/graylog/sidecar/sidecar.yml' fpm_attributes rpm_os: 'linux' @@ -23,12 +23,12 @@ def build end def install - bin.install 'graylog-collector-sidecar' + bin.install 'graylog-sidecar' bin.install '../../collectors/filebeat/linux/x86_64/filebeat' - etc('graylog/collector-sidecar').install '../../../collector_sidecar.yml' - etc('graylog/collector-sidecar/generated').mkdir - var('log/graylog/collector-sidecar').mkdir - var('run/graylog/collector-sidecar').mkdir - var('spool/collector-sidecar/nxlog').mkdir + etc('graylog/sidecar').install '../../../sidecar.yml' + etc('graylog/sidecar/generated').mkdir + var('log/graylog/sidecar').mkdir + var('run/graylog/sidecar').mkdir + var('spool/graylog-sidecar/nxlog').mkdir end end diff --git a/dist/recipe32.rb b/dist/recipe32.rb index fca7933..9e37b8a 100644 --- a/dist/recipe32.rb +++ b/dist/recipe32.rb @@ -1,21 +1,21 @@ require_relative 'tools' class GraylogSidecar < FPM::Cookery::Recipe - description 'Graylog collector sidecar' + description 'Graylog sidecar' - name 'collector-sidecar' + name 'graylog-sidecar' version data.version revision data.revision homepage 'https://graylog.org' arch 'i386' - source "file:../../build/#{version}/linux/386/graylog-collector-sidecar" + source "file:../../build/#{version}/linux/386/graylog-sidecar" maintainer 'Graylog, Inc. ' vendor 'graylog' license 'GPLv3' - config_files '/etc/graylog/collector-sidecar/collector_sidecar.yml' + config_files '/etc/graylog/sidecar/sidecar.yml' fpm_attributes rpm_os: 'linux' @@ -23,12 +23,12 @@ def build end def install - bin.install 'graylog-collector-sidecar' + bin.install 'graylog-sidecar' bin.install '../../collectors/filebeat/linux/x86/filebeat' - etc('graylog/collector-sidecar').install '../../../collector_sidecar.yml' - etc('graylog/collector-sidecar/generated').mkdir - var('log/graylog/collector-sidecar').mkdir - var('run/graylog/collector-sidecar').mkdir - var('spool/collector-sidecar/nxlog').mkdir + etc('graylog/sidecar').install '../../../sidecar.yml' + etc('graylog/sidecar/generated').mkdir + var('log/graylog/sidecar').mkdir + var('run/graylog/sidecar').mkdir + var('spool/graylog-sidecar/nxlog').mkdir end end diff --git a/logger/hooks/hooks.go b/logger/hooks/hooks.go index 297dcc6..fcab1aa 100644 --- a/logger/hooks/hooks.go +++ b/logger/hooks/hooks.go @@ -31,7 +31,7 @@ func AddLogHooks(context *context.Ctx, log *logrus.Logger) { } func filesystemHook(context *context.Ctx, log *logrus.Logger) { - logfile := filepath.Join(context.UserConfig.LogPath, "collector_sidecar.log") + logfile := filepath.Join(context.UserConfig.LogPath, "sidecar.log") err := common.CreatePathToFile(logfile) if err != nil { log.Fatalf("Failed to create directory for log file %s: %s", logfile, err) diff --git a/main.go b/main.go index bc3bb52..c816a5d 100644 --- a/main.go +++ b/main.go @@ -49,9 +49,9 @@ var ( func init() { var configurationPath string if runtime.GOOS == "windows" { - configurationPath = filepath.Join(os.Getenv("SystemDrive")+"\\", "Program Files", "graylog", "collector-sidecar", "collector_sidecar.yml") + configurationPath = filepath.Join(os.Getenv("SystemDrive")+"\\", "Program Files", "graylog", "sidecar", "sidecar.yml") } else { - configurationPath = filepath.Join("/etc", "graylog", "collector-sidecar", "collector_sidecar.yml") + configurationPath = filepath.Join("/etc", "graylog", "sidecar", "sidecar.yml") } serviceParam = flag.String("service", "", "Control the system service [start stop restart install uninstall]") @@ -60,7 +60,7 @@ func init() { debug = flag.Bool("debug", false, "Set log level to debug") flag.Usage = func() { - fmt.Fprint(os.Stderr, "Usage: graylog-collector-sidecar -c [CONFIGURATION FILE]\n") + fmt.Fprint(os.Stderr, "Usage: graylog-sidecar -c [CONFIGURATION FILE]\n") flag.PrintDefaults() } diff --git a/collector_sidecar.yml b/sidecar.yml similarity index 52% rename from collector_sidecar.yml rename to sidecar.yml index 61be059..03346ff 100644 --- a/collector_sidecar.yml +++ b/sidecar.yml @@ -3,9 +3,9 @@ update_interval: 10 tls_skip_verify: false send_status: true list_log_files: -collector_id: file:/etc/graylog/collector-sidecar/collector-id -cache_path: /var/cache/graylog/collector-sidecar -log_path: /var/log/graylog/collector-sidecar +collector_id: file:/etc/graylog/sidecar/node-id +cache_path: /var/cache/graylog/sidecar +log_path: /var/log/graylog/sidecar log_rotation_time: 86400 log_max_age: 604800 tags: @@ -15,8 +15,8 @@ backends: - name: nxlog enabled: false binary_path: /usr/bin/nxlog - configuration_path: /etc/graylog/collector-sidecar/generated/nxlog.conf + configuration_path: /etc/graylog/sidecar/generated/nxlog.conf - name: filebeat enabled: true binary_path: /usr/bin/filebeat - configuration_path: /etc/graylog/collector-sidecar/generated/filebeat.yml + configuration_path: /etc/graylog/sidecar/generated/filebeat.yml diff --git a/sidecar_windows.yml b/sidecar_windows.yml new file mode 100644 index 0000000..234f71d --- /dev/null +++ b/sidecar_windows.yml @@ -0,0 +1,25 @@ +server_url: +update_interval: +tls_skip_verify: +send_status: +list_log_files: +node_id: +collector_id: file:C:\Program Files\graylog\sidecar\node-id +cache_path: C:\Program Files\graylog\sidecar\cache +log_path: C:\Program Files\graylog\sidecar\logs +log_rotation_time: 86400 +log_max_age: 604800 +tags: +backends: + - name: nxlog + enabled: + binary_path: C:\Program Files (x86)\nxlog\nxlog.exe + configuration_path: C:\Program Files\graylog\sidecar\generated\nxlog.conf + - name: winlogbeat + enabled: + binary_path: C:\Program Files\graylog\sidecar\winlogbeat.exe + configuration_path: C:\Program Files\graylog\sidecar\generated\winlogbeat.yml + - name: filebeat + enabled: + binary_path: C:\Program Files\graylog\sidecar\filebeat.exe + configuration_path: C:\Program Files\graylog\sidecar\generated\filebeat.yml