Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config #1

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
build/
.vscode/
.idea/
config.yaml
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
VERSION := $(shell git describe --tags)
GIT_HASH := $(shell git rev-parse --short HEAD )

GO_VERSION ?= $(shell go version)
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
LDFLAGS = -ldflags "-X main.Version=${VERSION} -X main.GitHash=${GIT_HASH} -X main.GoVersion=${GO_VERSION_NUMBER}"

.PHONY: build
build:
CGO_ENABLED=0 go build ${LDFLAGS} -v -o target/aci-streamer .

.PHONY: build-release
build-release: build-release-amd64 build-release-arm64

.PHONY: build-release-amd64
build-release-amd64:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o=aci-streamer.linux.amd64 . && \
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o=aci-streamer.windows.amd64.exe . && \
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o=aci-streamer.darwin.amd64 .

.PHONY: build-release-arm64
build-release-arm64:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${LDFLAGS} -o=aci-streamer.linux.arm64 . && \
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${LDFLAGS} -o=aci-streamer.darwin.arm64 .

.PHONY: generate-html-coverage
generate-html-coverage:
go tool cover -html=cover.out -o coverage.html
@printf "Generated coverage html \n"

.PHONY: print-coverage
print-coverage:
@go tool cover -func cover.out

.PHONY: test-unittests
test-unittests:
go test -v -race -coverprofile cover.out ./...

.PHONY: test
test: fmt-check vet test-unittests generate-html-coverage print-coverage
@printf "Successfully run tests \n"

.PHONY: get-dependencies
get-dependencies:
go get -v -t -d ./...

.PHONY: vet
vet:
@go vet ./...
@go mod tidy

test-output:
$(shell echo $$GO_VERSION_NUMBER)

.PHONY: fmt-fix
fmt-fix:
@go mod download golang.org/x/tools
@go run golang.org/x/tools/cmd/goimports -w -l .

.PHONY: fmt-check
fmt-check:
@printf "Check formatting... \n"
@go mod download golang.org/x/tools
@if [[ $$( go run golang.org/x/tools/cmd/goimports -l . ) ]]; then printf "Files not properly formatted. Run 'make fmt-fix' \n"; exit 1; else printf "Check formatting finished \n"; fi
12 changes: 7 additions & 5 deletions aci-connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,25 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"strings"

"github.com/gorilla/websocket"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
"strings"

log4go "github.com/jeanphorn/log4go"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/umisama/go-regexpcache"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
"os"
"time"

log4go "github.com/jeanphorn/log4go"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/umisama/go-regexpcache"
)

// Create a Prometheus counter for number of reads on the websocket
Expand Down
6 changes: 4 additions & 2 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ streams:
regex: "^topology/pod-(?P<podid>[1-9][0-9]*)/node-(?P<nodeid>[1-9][0-9]*)/sys/.*"
message:
name: message
format: "%s [dn: %s]"
format: "%s podid:%s [dn: %s]"
# Names are add to the format in the order they are written
property_names:
- descr
- podid
- dn


Expand All @@ -44,7 +45,8 @@ streams:
timestamp:
property_name: loginTime
drops:
property_name: hashToken
- property_name: hashToken
- property_name: userdom
message:
name: mesg
format: "User %s - status %s IP %s"
Expand Down
9 changes: 5 additions & 4 deletions streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ import (
"context"
"flag"
"fmt"
"net/http"
"os"
"strconv"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/segmentio/ksuid"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"net/http"
"os"
"strconv"
"time"
)

var version = "undefined"
Expand Down
4 changes: 2 additions & 2 deletions streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package main

type Streams map[string]*Stream

type Stream struct {
ClassName string `mapstructure:"class_name"`
QueryParameter string `mapstructure:"query_parameter"`
Expand All @@ -29,12 +30,11 @@ type ConfigLabels struct {
Regex string `mapstructure:"regex"`
}

/*
type Timestamp struct {
PropertyName string `mapstructure:"property_name"`
//Regex string `mapstructure:"regex"`
}
*/

type Property struct {
PropertyName string `mapstructure:"property_name"`
//Regex string `mapstructure:"regex"`
Expand Down