diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9b9d110..7b70129 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - "*" jobs: - release: + docker: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -41,6 +41,18 @@ jobs: repository: "${{ github.repository }}" readme-filepath: ./README.md short-description: "Exporter for EMQX metrics." + + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.20.x + - name: Build + env: + VSN: ${{ github.ref_name }} + run: make build - id: prerelease run: | if echo "${{ github.ref_name }}" |egrep -q "^[0-9].[0-9].[0-9]$"; then @@ -56,3 +68,5 @@ jobs: name: EMQX Exporter ${{ github.ref_name }} Released body_path: RELEASE.md generate_release_notes: true + files: | + emqx-exporter-**.tgz diff --git a/.gitignore b/.gitignore index d15f7de..0a56df8 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ bin __pycache__ env/ +*.tgz cover.* diff --git a/Makefile b/Makefile index d8178d5..5ca0c32 100644 --- a/Makefile +++ b/Makefile @@ -11,12 +11,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +VSN ?= $(shell git describe --tags --always) +OS ?= $(shell go env OS) + all: build .PHONY: build build: - go build -o $(LOCALBIN)/$(PROJECT_NAME) + GOOS=$(OS) go build -o $(LOCALBIN)/$(PROJECT_NAME) @cp $(PROJECT_DIR)/config/example/config.yaml $(LOCALBIN)/config.yaml + @tar -zcvf emqx-exporter-$(OS)-$(VSN).tgz bin .PHONY: test test: diff --git a/README.md b/README.md index da224a6..074a4a0 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ scrape_configs: # fix value, don't modify from: exporter - job_name: 'exporter-probe' - metrics_path: /probes + metrics_path: /probe params: target: # must equal the `probes[$index].taget` in config file diff --git a/collector/client_4.go b/collector/client_4.go index ef0c239..ed83940 100644 --- a/collector/client_4.go +++ b/collector/client_4.go @@ -10,15 +10,10 @@ import ( var _ emqxClientInterface = &client4x{} type client4x struct { - edition edition requester *requester } func (n *client4x) getLicense() (lic *LicenseInfo, err error) { - if n.edition == openSource { - return - } - resp := struct { Data struct { MaxConnections int64 `json:"max_connections"` @@ -137,7 +132,7 @@ func (n *client4x) getRuleEngineMetrics() (metrics []RuleEngine, err error) { } Code int }{} - err = n.requester.callHTTPGetWithResp("/api/v4/rules?_limit=10000", &resp) + err = n.requester.callHTTPGetWithResp("/api/v4/rules", &resp) if err != nil { return } diff --git a/collector/client_5.go b/collector/client_5.go index 4a1b2c2..1498fbe 100644 --- a/collector/client_5.go +++ b/collector/client_5.go @@ -84,9 +84,7 @@ func (n *client5x) getClusterStatus() (cluster ClusterStatus, err error) { } cluster.CPULoads[nodeName] = cpuLoad - if data.Edition == "Opensource" { - n.edition = openSource - } else { + if data.Edition == "Enterprise" { n.edition = enterprise } } diff --git a/examples/docker-compose/docker-compose.yml b/examples/docker-compose/docker-compose.yml index 42ffd7d..37b599d 100644 --- a/examples/docker-compose/docker-compose.yml +++ b/examples/docker-compose/docker-compose.yml @@ -4,6 +4,7 @@ services: image: emqx:5 container_name: emqx-demo ports: + - 18084:18084 - 18083:18083 - 1883:1883 - 8083:8083 @@ -11,10 +12,11 @@ services: - 8883:8883 environment: EMQX_API_KEY__BOOTSTRAP_FILE: '"/opt/emqx/data/bootstrap-api"' + EMQX_DASHBOARD__LISTENERS__HTTPS__BIND: 18084 volumes: - ./bootstrap-api:/opt/emqx/data/bootstrap-api healthcheck: - test: ["CMD", "emqx", "ctl", "status"] + test: ["CMD", "emqx", "ping"] interval: 30s timeout: 10s retries: 3 @@ -22,10 +24,10 @@ services: emqx-exporter: depends_on: - emqx - image: emqx-exporter + image: emqx/emqx-exporter:0.2.3 container_name: exporter-demo - # ports: - # - 8085:8085 + ports: + - 8085:8085 volumes: - ./emqx-exporter.config.yaml:/usr/local/emqx-exporter/bin/config.yaml diff --git a/examples/docker-compose/emqx-exporter.config.yaml b/examples/docker-compose/emqx-exporter.config.yaml index b6a4f04..9f5c29a 100644 --- a/examples/docker-compose/emqx-exporter.config.yaml +++ b/examples/docker-compose/emqx-exporter.config.yaml @@ -1,6 +1,24 @@ metrics: - target: emqx-demo:18083 api_key: some_api_key api_secret: some_api_secret + target: emqx-demo:18084 + scheme: https + tls_config: + insecure_skip_verify: true probes: - target: emqx-demo:1883 + - target: emqx-demo:8883 + scheme: tls + client_id: my_demo + username: my_demo + password: my_demo + topic: my_demo + qos: 1 + tls_config: + insecure_skip_verify: true + - target: emqx-demo:8083/mqtt + scheme: ws + - target: emqx-demo:8084/mqtt + scheme: wss + tls_config: + insecure_skip_verify: true diff --git a/examples/docker-compose/prometheus-emqx5.yaml b/examples/docker-compose/prometheus-emqx5.yaml index 0cfa7ac..605af6b 100644 --- a/examples/docker-compose/prometheus-emqx5.yaml +++ b/examples/docker-compose/prometheus-emqx5.yaml @@ -42,3 +42,42 @@ scrape_configs: cluster: test # fix value, don't modify from: probe + - job_name: 'mqtts-probe' + metrics_path: '/probe' + params: + target: + - "emqx-demo:8883" + scrape_interval: 5s + static_configs: + - targets: [exporter-demo:8085] + labels: + # label the cluster name of where the metrics data from + cluster: test + # fix value, don't modify + from: probe + - job_name: 'ws-probe' + metrics_path: '/probe' + params: + target: + - "emqx-demo:8083/mqtt" + scrape_interval: 5s + static_configs: + - targets: [exporter-demo:8085] + labels: + # label the cluster name of where the metrics data from + cluster: test + # fix value, don't modify + from: probe + - job_name: 'wss-probe' + metrics_path: '/probe' + params: + target: + - "emqx-demo:8084/mqtt" + scrape_interval: 5s + static_configs: + - targets: [exporter-demo:8085] + labels: + # label the cluster name of where the metrics data from + cluster: test + # fix value, don't modify + from: probe