Skip to content

Commit

Permalink
Merge pull request #1 from opsdis/fix_config
Browse files Browse the repository at this point in the history
Fix config
  • Loading branch information
thenodon authored Dec 1, 2023
2 parents 57cb410 + 8d0c1a4 commit 776fc5e
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 13 deletions.
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

0 comments on commit 776fc5e

Please sign in to comment.