Commit b1fd980e authored by Your Name's avatar Your Name

loki param

parent 8bfc1b29
...@@ -3,6 +3,13 @@ FROM golang:1.21.7-alpine3.18 AS build ...@@ -3,6 +3,13 @@ FROM golang:1.21.7-alpine3.18 AS build
#FROM golang:1.21.3 AS base #FROM golang:1.21.3 AS base
#FROM golang:1.20.6-alpine3.18 AS build #FROM golang:1.20.6-alpine3.18 AS build
# Set up dependencies
ENV PACKAGES git build-base
# Install dependencies
RUN apk add --update $PACKAGES
WORKDIR /go/src/github.com/odysseus/ WORKDIR /go/src/github.com/odysseus/
ENV https_proxy 'http://192.168.1.180:1080' ENV https_proxy 'http://192.168.1.180:1080'
...@@ -19,7 +26,9 @@ COPY ./service-registry ./service-registry ...@@ -19,7 +26,9 @@ COPY ./service-registry ./service-registry
# RUN go mod tidy # RUN go mod tidy
#RUN go build -o /go-kafka #RUN go build -o /go-kafka
RUN cd go-kafka && go mod tidy && go build -o /ai-api-mgr RUN cd go-kafka && go mod tidy && make build-docker-ouput
#go build -o /ai-api-mgr
FROM alpine FROM alpine
......
...@@ -19,6 +19,7 @@ import ( ...@@ -19,6 +19,7 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
gogoPbProto "github.com/gogo/protobuf/proto" gogoPbProto "github.com/gogo/protobuf/proto"
"github.com/odysseus/go-kafka/version"
pbUpstream "github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1" pbUpstream "github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1"
qdb "github.com/questdb/go-questdb-client/v2" qdb "github.com/questdb/go-questdb-client/v2"
...@@ -496,7 +497,7 @@ func main() { ...@@ -496,7 +497,7 @@ func main() {
flag.StringVar(&mysqlUser, "mysqlUser", "liuxuzhong", "connect to mysql user") flag.StringVar(&mysqlUser, "mysqlUser", "liuxuzhong", "connect to mysql user")
flag.StringVar(&mysqlPassWd, "mysqlPassWd", "12345678", "mysql user password") flag.StringVar(&mysqlPassWd, "mysqlPassWd", "12345678", "mysql user password")
flag.StringVar(&logserver, "logserver", "http://124.193.167.71:3100", "LOKI log server") flag.StringVar(&logserver, "logserver", "http://172.31.12.187:3100", "LOKI log server")
flag.StringVar(&callbackAddrP, "callbackIpAddr", "localhost:6001", "ip:port") flag.StringVar(&callbackAddrP, "callbackIpAddr", "localhost:6001", "ip:port")
flag.StringVar(&listenIpPort, "listenIpPort", "0.0.0.0:6001", "api listen on ip:port") flag.StringVar(&listenIpPort, "listenIpPort", "0.0.0.0:6001", "api listen on ip:port")
...@@ -524,12 +525,16 @@ func main() { ...@@ -524,12 +525,16 @@ func main() {
config.TenantID = "api" config.TenantID = "api"
client, _ := loki.New(config) client, _ := loki.New(config)
slog.SetDefault(slog.New(slogloki.Option{Level: levelVar, Client: client}.NewLokiHandler())) //fmt.Println("Version", version.VERSION)
slog.SetDefault(slog.New(slogloki.Option{Level: levelVar, Client: client}.NewLokiHandler()).With("api", version.VERSION))
//slog.SetDefault(slog.New(slogloki.Option{Level: levelVar, Client: client}.NewLokiHandler()).With("api", "v0.0.15"))
//logger := slog.New(slogloki.Option{Level: slog.LevelDebug, Client: client}.NewLokiHandler()) //logger := slog.New(slogloki.Option{Level: slog.LevelDebug, Client: client}.NewLokiHandler())
// logger = logger.With("release", "v1.0.0") // logger = logger.With("release", "v1.0.0")
// for i := 0; i < 10000; i++ { // for i := 0; i < 10000; i++ {
// logger.Debug("debug log server", "i", i) // //logger.Debug("debug log server", "i", i)
// slog.Debug("debug log server", "i", i) // slog.Debug("debug log server", "i", i)
// time.Sleep(time.Second) // time.Sleep(time.Second)
// } // }
......
...@@ -2,7 +2,25 @@ ...@@ -2,7 +2,25 @@
VERSION := $(shell echo $(shell git describe --tags)) VERSION := $(shell echo $(shell git describe --tags))
COMMIT_HASH := $(shell git rev-parse --short HEAD)
COMMIT_SHA1=`git rev-parse HEAD`
BUILD_FLAGS = -tags netgo -ldflags " -X github.com/odysseus/go-kafka/version.VERSION=${VERSION} -X github.com/odysseus/go-kafka/main.COMMIT_SHA1=${COMMIT_SHA1} -X 'github.com/odysseus/go-kafka/main.BUILD_TIME=`date`' -X 'github.com/odysseus/go-kafka/main.GIT_BRANCH=`git symbolic-ref --short -q HEAD`' "
docker: docker:
docker build -t caduceus/ai-api-mgr:${VERSION} . docker build -t caduceus/ai-api-mgr:${VERSION} .
build: go.sum
go build -mod=readonly $(BUILD_FLAGS) -o ai-api-mgr
build-docker-ouput: go.sum # build 的目录在docker image 里不能上下复制,不清楚原因;
go build -mod=readonly $(BUILD_FLAGS) -o /ai-api-mgr
...@@ -90,6 +90,10 @@ The global counter `counter` is used to keep track of the messages sent to the K ...@@ -90,6 +90,10 @@ The global counter `counter` is used to keep track of the messages sent to the K
````bash
make build
./ai-api-mgr -mysqlUser=root -mysqlAddr=192.168.1.211 -kafkaBroker=192.168.1.10:9092 -withbilldb=false -questAddr=192.168.1.10:9009 -loglevel=-4
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment