Skip to content

Commit

Permalink
rework collector
Browse files Browse the repository at this point in the history
this is a big refactor, essentially rewriting the custom collector from
scratch, and as such, creating a new dashboard based on the new metrics.

Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
  • Loading branch information
cirocosta committed Aug 2, 2021
1 parent 80fe913 commit debdce3
Show file tree
Hide file tree
Showing 28 changed files with 4,892 additions and 682 deletions.
File renamed without changes
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
7 changes: 0 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ builds:
- 6
- 7

archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64

checksum:
name_template: 'checksums.txt'

Expand Down
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG BUILDER_IMAGE=golang@sha256:4544ae57fc735d7e415603d194d9fb09589b8ad7acd4d66e928eabfb1ed85ff1
ARG RUNTIME_IMAGE=gcr.io/distroless/static@sha256:c9f9b040044cc23e1088772814532d90adadfa1b86dcba17d07cb567db18dc4e


FROM $BUILDER_IMAGE as builder

WORKDIR /workspace

COPY .git .git
COPY go.mod go.mod
COPY go.sum go.sum
COPY pkg/ pkg/
COPY cmd/ cmd/

RUN set -x && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on \
go build -a -v \
-ldflags "-s -w -X main.version=$(git tag) -X main.commit=$(git rev-parse HEAD)" \
-tags osusergo,netgo,static_build \
-trimpath \
-o monero-exporter \
./cmd/monero-exporter


FROM $RUNTIME_IMAGE

WORKDIR /
COPY --from=builder /workspace/monero-exporter .
USER 65532:65532

ENTRYPOINT ["/monero-exporter"]
118 changes: 118 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Install

## Using Go

If you already have [Go] installed, you can use to Go toolchain to build from
source and install it for you (under `$GOPATH/bin`):

```console
$ GO111MODULE=on go get github.com/cirocosta/monero-exporter/cmd/monero-exporter
go: downloading github.com/cirocosta/monero-exporter v0.0.3

$ monero-exporter --help
Prometheus exporter for monero metrics

Usage:
monero-exporter [flags]
...
```

Note that this will install the latest tagged release (not necessarily the
latest code).


## From releases

In the [releases page] you'll find the pre-compiled releases for each platform.


### "yeah yeah, I trust the interwebs" mode

```bash
export VERSION=0.0.3

curl -SL -o- https://github.com/cirocosta/monero-exporter/releases/download/v$VERSION/monero-exporter_$VERSION_Linux_x86_64.tar.gz | \
tar xvzf monero
mv ./monero-exporter /usr/local/bin
```


### "trust, but verify" mode


1. fetch my public key and make sure it matches the expected fingerprint

```console
$ curl -SOL https://utxo.com.br/pgp/public-key.txt
```

now, using `gpg`, derive the fingerprint. it should match the one advertised by
me: `9CD1 1313 8578 59CC 0FAD E93B 6B93 177A 62D0 1DB8` (should be the same as
you can find under my personal account on Twitter: http://twitter.com/cirowrc).


```console
$ gpg --keyid-format long --with-fingerprint ./public-key.txt
pub rsa3072/6B93177A62D01DB8 2021-07-19 [SC] [expires: 2023-07-19]
Key fingerprint = 9CD1 1313 8578 59CC 0FAD E93B 6B93 177A 62D0 1DB8
```

then, import into the key to the keyring so it can be used to validate that I
indeed signed the content advertised.

```console
$ gpg --import ./public-key.txt
gpg: key 6B93177A62D01DB8: public key "..." imported
gpg: Total number processed: 1
gpg: imported: 1
```


2. download the archive for your platform as well as the checksums

```console
$ curl -SOL https://github.com/cirocosta/monero-exporter/releases/download/v0.0.3/monero-exporter_0.0.3_Linux_x86_64.tar.gz
$ curl -SOL https://github.com/cirocosta/monero-exporter/releases/download/v0.0.3/checksums.txt.asc
```


3. verify that you can trust the checksums (that it has been generated and
not tampered with), and then verify that the assets you downloaded are what
they supposed to be

```console
$ gpg --verify ./checksums.txt.asc
gpg: Signature made Mon 19 Jul 2021 02:10:42 PM EDT
gpg: using RSA key 9CD11313857859CC0FADE93B6B93177A62D01DB8
gpg: Good signature from "Ciro ...
```


4. verify that the tarball is what it should be

compute the digest of the tarball

```console
$ sha256sum ./monero-exporter_0.0.3_Linux_x86_64.tar.gz
e2b2214c9371fe3c0333cca7feff3554c56d8d0f377180e39ff50d332639c22d ./monero-exporter_0.0.3_Linux_x86_64.tar.gz


see that it matches what you found in the signed checksums file

$ cat ./checksums.txt.asc | grep e2b2214c9371fe3c0333cca7feff3554c56d8d0f377180e39ff50d332639c22d
e2b2214c9371fe3c0333cca7feff3554c56d8d0f377180e39ff50d332639c22d monero-exporter_0.0.3_Linux_x86_64.tar.gz
```

5. install

```console
$ tar xvzf ./monero-exporter_0.0.3_Linux_x86_64.tar.gz monero
$ mv monero /usr/local/bin

$ monero-exporter version
0.0.3 ...
```


[Go]: https://golang.org/dl/
[releases page]: https://github.com/cirocosta/monero-exporter/releases
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
install:
go install -v ./cmd/monero-exporter

run:
monero-exporter \
--monero-addr=http://localhost:18081 \
--bind-addr=:9000 \
--geoip-filepath=./hack/geoip.mmdb

test:
go test ./...

lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint run --config=.golangci.yaml
go run github.com/golangci/golangci-lint/cmd/golangci-lint run \
--config=.golangci.yaml


table-of-contents:
doctoc --notitle ./README.md
Loading

0 comments on commit debdce3

Please sign in to comment.