diff --git a/.github/assets/image.png b/.github/assets/image.png new file mode 100644 index 0000000..b064bee Binary files /dev/null and b/.github/assets/image.png differ diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 798920b..3624c77 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,31 +1,88 @@ --- - name: ci - on: - - push - jobs: - lint: - name: lint - runs-on: ubuntu-latest - steps: +name: ci +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' +jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.58 + test: + name: test + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/setup-go@v4 with: - go-version: '1.22' - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + go-version: 1.22 + - run: go test -v ./... -covermode=atomic -coverprofile=coverage.out + - uses: codecov/codecov-action@v4.0.1 with: - version: v1.58 - test: - name: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version: 1.22 - - run: go test -v ./... -covermode=atomic -coverprofile=coverage.out - - uses: codecov/codecov-action@v4.0.1 - with: - files: coverage.out - token: ${{ secrets.CODECOV_TOKEN }} - slug: snapp-incubator/nats-blackbox-exporter \ No newline at end of file + files: coverage.out + token: ${{ secrets.CODECOV_TOKEN }} + slug: snapp-incubator/nats-blackbox-exporter + build-push: + name: Build & Push + runs-on: ubuntu-latest + needs: + - lint + - test + strategy: + matrix: + command: [janus, ion-sfu] + env: + REGISTRY: ghcr.io + USERNAME: ${{ github.repository_owner }} + REPOSITORY: ${{ github.event.repository.name }} + steps: + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: 1.22.x + + - name: Checks out our project source code + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.USERNAME }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v3 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.REPOSITORY }}-${{ matrix.command }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - uses: docker/build-push-action@v2 + with: + file: "build/Dockerfile" + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..5539198 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,28 @@ +--- +name: release +on: + push: + tags: + - '*' +jobs: + goreleaser: + name: release + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v4 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: '~> v1' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3f7c05a..6039a56 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ # config config.yaml -.DS_Store \ No newline at end of file +.DS_Store +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..14aa7de --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,25 @@ +--- +project_name: nats-blackbox-exporter + +release: + github: + owner: snapp-incubator + name: nats-blackbox-exporter + +checksum: {} + +builds: + - binary: gosimac + goos: + - linux + - darwin + - windows + goarch: + - amd64 + main: ./cmd/nats-blackbox-exporter/main.go + +archives: + - id: binary + format: binary + - id: default + format: tar.gz \ No newline at end of file diff --git a/README.md b/README.md index 4e1b074..8fe7f20 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -# nats-blackbox-exporter \ No newline at end of file +

NATS Blackbox Exporter

+ +

+ +

+ +

+ GitHub Workflow Status + Codecov + GitHub repo size + GitHub tag (with filter) + GitHub go.mod Go version (subdirectory of monorepo) +

+ +## Introduction + +Each probe publishes a message over Jetstream NATS and then waits to receive it through a subscription. By measuring the time taken for this process, you can monitor the status of your NATS cluster. At Snapp!, we use this to detect the status of our NATS clusters from the client perspective. + +You can track the following metrics: +- **Connection**: A `prometheus.CounterVec` that counts disconnections and connections. +- **Latency**: A `prometheus.Histogram` that measures the latency between publishing and subscribing. +- **SuccessCounter**: A `prometheus.CounterVec` that counts successful publishes and consumes. + +This setup helps ensure that your NATS clusters are functioning optimally and provides insights into any issues from the client side. diff --git a/build/package/Dockerfile b/build/Dockerfile similarity index 100% rename from build/package/Dockerfile rename to build/Dockerfile