Skip to content

Commit

Permalink
Add example prometheus configuration (#41)
Browse files Browse the repository at this point in the history
Signed-off-by: Oluwole Fadeyi <[email protected]>
  • Loading branch information
tfadeyi authored Apr 13, 2023
1 parent 1f93752 commit 50afa68
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
go-version: '1.19'
- uses: actions/checkout@v3
- name: Install tools
run: make install-tools
run: make install-ci-tools
- name: Go Fmt
run: diff -u <(echo -n) <(gofmt -d ./)
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: git fetch --prune --unshallow

- name: Install tools
run: make install-tools
run: make install-ci-tools

- name: Install cosign
uses: sigstore/[email protected]
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
fetch-depth: 0

- name: Install tools
run: make install-tools
run: make install-ci-tools

- name: Install Go
uses: actions/setup-go@v4
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ export KO_DOCKER_REPO=$KO_DOCKER_REPO
# include files with the `// +build mock` annotation
TEST_TAGS:=-tags mock -coverprofile cover.out

.PHONY: build generate docs test build-all-platforms clean install-tools licenses docker-build
.PHONY: build generate docs test build-all-platforms clean install-tools licenses lint

install-tools:
install-ci-tools:
go install github.com/swaggo/swag/cmd/[email protected]
go install github.com/matryer/[email protected]
go install github.com/google/go-licenses@c781b427440f8ea100841eefdd308e660d26d121
go install github.com/norwoodj/helm-docs/cmd/[email protected]

install-local-tools: install-ci-tools
go install https://github.com/goreleaser/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]

build:
cd $(ROOT_DIR) && $(GO_BUILD) -o builds/$(BIN_NAME) .

Expand Down Expand Up @@ -53,6 +57,9 @@ clean:
rm -rf ./builds && \
rm -rf kodata

lint:
golangci-lint run

# generates the licenses used by the tool
licenses:
rm -rf kodata
Expand Down
68 changes: 53 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,39 @@ This Prometheus exporter aims to simplify this, making it easier to expose tenan
* *(Optional)* Auth0 tenant management API [static token](https://auth0.com/docs/secure/tokens/access-tokens/management-api-access-tokens).

## TL;DR
Run exporter's container with TLS disabled.

The quickest way to install the exporter is through Helm, make sure you have your Auth0 credentials at hand.

```shell
export TOKEN="< auth0 management API static static token >"
export DOMAIN="< auth0 tenant domain >"

curl -LJO https://github.com/tfadeyi/auth0-simple-exporter/releases/download/v0.0.1/auth0-simple-exporter-linux-amd64.tar.gz && \
tar -xzvf auth0-simple-exporter-linux-amd64.tar.gz && \
cd auth0-simple-exporter-linux-amd64

./auth0-simple-exporter export --tls.disabled
```
```shell
# Installing by passing in secret directly
helm repo add auth0-exporter https://tfadeyi.github.io/auth0-simple-exporter
helm upgrade --install --create-namespace -n auth0-exporter auth0-exporter/auth0-exporter \
--set auth0.domain="$DOMAIN" --set auth0.token="$TOKEN" \
--set exporter.tls.disabled=true
```
This will install the exporter running with TLS disabled.

## Installation

* ### Download Binaries
* ### Download Pre-built Binaries

Binaries can be downloaded from [Releases](https://github.com/tfadeyi/auth0-simple-exporter/releases) page.
* Download and run exporter's binary with TLS disabled.

```shell
export TOKEN="< auth0 management API static static token >"
export DOMAIN="< auth0 tenant domain >"

curl -LJO https://github.com/tfadeyi/auth0-simple-exporter/releases/download/v0.0.2/auth0-simple-exporter-linux-amd64.tar.gz && \
tar -xzvf auth0-simple-exporter-linux-amd64.tar.gz && \
cd auth0-simple-exporter-linux-amd64

./auth0-simple-exporter export --tls.disabled
```
* ### Docker
The recommended way to get the Docker Image is to pull the prebuilt image from the project's Github Container Registry.
```shell
Expand All @@ -75,6 +89,13 @@ cd auth0-simple-exporter-linux-amd64
More info on the helm deployment can be found [here](deploy/charts/auth0-exporter/README.md).
* ### Build from source
From the repository root directory run:
```shell
make build
# or for multiple systems
make build-all-platforms
```
## Usage
```
Expand Down Expand Up @@ -149,13 +170,30 @@ Monitor the number current logged-in users for a client application in Auth0 ten
## Known Issues
### API Rate Limits
When the Prometheus scraping job interval is too frequent the exporter might encounter api-rate limit from Auth0.
To mitigate this try increasing the scraping interval for the job.
### Not all logs/events are available
Currently, not all logs/events from Auth0 are exposed, if a metric is not exposed, feel free to open a feature request.
* ### API Rate Limits
When the Prometheus scraping job interval is too frequent the exporter might encounter api-rate limit from Auth0.
To mitigate this try increasing the scraping interval for the job.
* ### Not all logs/events are available
Currently, not all logs/events from Auth0 are exposed, if a metric is not exposed, feel free to open a feature request.
## Prometheus
Example Prometheus configuration for the exporter. Replace `AUTH0-EXPORTER-HOSTNAME` with your instance's hostname.
```yaml
scrape_configs:
- job_name: auth0_exporter
metrics_path: /metrics
static_configs:
- targets: ['<<AUTH0-EXPORTER-HOSTNAME>>:9301']
relabel_configs:
- source_labels: [ __address__ ]
target_label: __param_target
- source_labels: [ __param_target ]
target_label: instance
- target_label: __address__
replacement: <<AUTH0-EXPORTER-HOSTNAME>>:9301
```
## Development
Expand Down
4 changes: 2 additions & 2 deletions cmd/options/exporter/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (o *Options) addAppFlags(fs *pflag.FlagSet) {
fs.IntVar(
&o.HostPort,
"web.listen-address",
8080,
9301,
"Port where the exporter webserver will listen on.",
)
fs.StringVar(
Expand All @@ -198,7 +198,7 @@ func (o *Options) addAppFlags(fs *pflag.FlagSet) {
fs.IntVar(
&o.ProbePort,
"probe.listen-address",
8081,
9302,
"Port where the probe webserver will listen on.",
)
fs.StringVar(
Expand Down
2 changes: 1 addition & 1 deletion dev/devshell.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ startup.kill.text = "alias done='pkill -f tmux'"
startup.sessions.text = "alias sessions='tmux list-session'"
# Profiling & Testing
startup.heap.text = "alias heap='go tool pprof'"
startup.testing.text = "alias test='make test && golangci-lint run && KO_DOCKER_REPO=ghcr.io/tfadeyi/auth0-exporter goreleaser check'"
startup.testing.text = "alias test='make test && make lint && KO_DOCKER_REPO=ghcr.io/tfadeyi/auth0-exporter goreleaser check'"

# Exporter
startup.exporter.text = "tmux new -s exporter -d 'air -c $ROOT_DIR/dev/.air-exporter.toml'"
Expand Down
17 changes: 17 additions & 0 deletions examples/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# my global config
global:
scrape_interval: 5s # Set the scrape interval to every 5 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.

scrape_configs:
- job_name: auth0_exporter
metrics_path: /metrics
static_configs:
- targets: ['localhost:9301']
relabel_configs:
- source_labels: [ __address__ ]
target_label: __param_target
- source_labels: [ __param_target ]
target_label: instance
- target_label: __address__
replacement: localhost:9301

0 comments on commit 50afa68

Please sign in to comment.