Skip to content

Commit

Permalink
chore: change default config path
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Oct 18, 2023
1 parent 83cabb3 commit 758d5ea
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
15 changes: 6 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# Build the manager binary
FROM golang:1.20.3 as builder

ARG GOPROXY=https://goproxy.cn,direct

WORKDIR /workspace
COPY . .
RUN go work init \
&& go work use . \
&& go mod download \
&& CGO_ENABLED=0 GOOS=linux go build -o emqx-exporter
&& CGO_ENABLED=0 GOOS=linux make build

FROM quay.io/prometheus/busybox:latest
LABEL maintainer="EMQX"

COPY --from=builder /workspace/emqx-exporter /bin/emqx-exporter
COPY config/example/config.yaml /etc/emqx-exporter/config.yaml
WORKDIR /usr/local/emqx-exporter/bin
COPY --from=builder /workspace/bin/. /usr/local/emqx-exporter/bin

EXPOSE 8085
USER nobody
ENTRYPOINT [ "/bin/emqx-exporter" ]
USER nobody:nobody
EXPOSE 8085
ENTRYPOINT [ "/usr/local/emqx-exporter/bin/emqx-exporter" ]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ all: build
.PHONY: build
build:
go build -o $(LOCALBIN)/$(PROJECT_NAME)
@cp $(PROJECT_DIR)/config/example/config.yaml $(LOCALBIN)/config.yaml

.PHONY: test
test: build
Expand Down
6 changes: 3 additions & 3 deletions config/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ metrics:
## EMQX API
target: 127.0.0.1:18083
## EMQX API key
api_key: "76668f8a2003d597"
api_key: "some_api_key"
## EMQX API secret
api_secret: "CRCDB6lxxzN58e5HoD82llBC0Erg1TVZIAUsdTjPU7N"
api_secret: "some_api_secret"
probes:
- target: broker.emqx.io:1883 ## MQTT broker address
- target: 127.0.0.1:1883 ## MQTT broker address
scheme: ## tcp, default is tcp
client_id:
username:
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"path/filepath"
"runtime"

"github.com/alecthomas/kingpin/v2"
Expand All @@ -37,7 +38,7 @@ import (

func main() {
var (
configFile = kingpin.Flag("config.file", "EMQX exporter configuration file.").Default("/etc/emqx-exporter/config.yaml").String()
configFile = kingpin.Flag("config.file", "EMQX exporter configuration file.").Default(filepath.Join(filepath.Dir(os.Args[0]), "config.yaml")).String()
maxProcs = kingpin.Flag("runtime.gomaxprocs", "The target number of CPUs Go will run on (GOMAXPROCS)").Envar("GOMAXPROCS").Default("4").Int()
maxRequests = kingpin.Flag("web.max-requests", "Maximum number of parallel scrape requests. Use 0 to disable.").Default("40").Int()
disableExporterMetrics = kingpin.Flag("web.disable-exporter-metrics", "Exclude metrics about the exporter itself (promhttp_*, process_*, go_*).").Bool()
Expand Down
7 changes: 3 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ import (
)

const (
address = "localhost:19100"
binary = "bin/emqx-exporter"
configFile = "config/example/config.yaml"
address = "localhost:19100"
binary = "bin/emqx-exporter"
)

func TestFileDescriptorLeak(t *testing.T) {
Expand All @@ -46,7 +45,7 @@ func TestFileDescriptorLeak(t *testing.T) {
t.Errorf("unable to read process stats: %s", err)
}

exporter := exec.Command(binary, "--web.listen-address", address, "--config.file", configFile)
exporter := exec.Command(binary, "--web.listen-address", address)
test := func(pid int) error {
if err := queryExporter(address); err != nil {
return err
Expand Down

0 comments on commit 758d5ea

Please sign in to comment.