Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunil Sayyaparaju authored and Sunil Sayyaparaju committed Feb 21, 2024
2 parents aa0df10 + c80756e commit b0738b5
Show file tree
Hide file tree
Showing 88 changed files with 11,084 additions and 5,195 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build_release_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ jobs:
run: |
docker run -v ${{ github.workspace }}:/src/ -w /src/ --platform linux/${{ matrix.arch }} aerospike.jfrog.io/devops-containers-prod-local/fpm-${{ matrix.container }} ${{ matrix.cmd }}
- name: Build tar files
id: build-tar-artifact
run: |
make tar GOOS=linux GOARCH=amd64 ARCH=x86_64
make tar GOOS=linux GOARCH=arm64 ARCH=aarch64
- name: gzip tar files
run: |
cd pkg/target
ls -lrt *.tar
echo "GZipping tar files"
gzip aerospike-prometheus-exporter*.tar
echo "gzipped files"
ls -lrt *.gz
- name: Upload Release Asset
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -97,3 +112,66 @@ jobs:
echo
ls -lst pkg/target/*

tar_job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag

- uses: actions/setup-ruby@v1
with:
ruby-version: '3.x'
- run: gem install fpm --no-document

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.2

- name: go mod tidy
run: |
dpkg-architecture -q DEB_BUILD_ARCH
(git describe --tags --always --abbrev=0 | cut -c 1-)
go mod tidy
- name: Build tar files
id: build-tar-artifact
run: |
echo "Current working directory ".$PWD
echo
echo "Build Directory is ".$BUILD_DIR
make tar GOOS=linux GOARCH=amd64 ARCH=x86_64
make tar GOOS=linux GOARCH=arm64 ARCH=aarch64
- name: gzip tar files
run: |
cd pkg/target
ls -lrt *.tar
echo "GZipping tar files"
gzip aerospike-prometheus-exporter*.tar
echo "gzipped files"
ls -lrt *.gz
- name: Upload Release Asset
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: "${{ steps.get-latest-tag.outputs.tag }}"
run: |
# echo "tag_name $TAG_NAME"
echo
files=$(find pkg/target -type f -name "aerospike-prome*" -printf "$(realpath -s %p) ")
for file in $files; do
echo "uploading file === $file to release-tag $TAG_NAME"
gh release upload "$TAG_NAME" "$file"
done

echo
echo "lising of files ... "
echo
ls -lst pkg/target/*
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ ARG VERSION=1.10.0

ADD . $GOPATH/src/github.com/aerospike/aerospike-prometheus-exporter
WORKDIR $GOPATH/src/github.com/aerospike/aerospike-prometheus-exporter
RUN go build -ldflags="-X 'main.version=$VERSION'" -o aerospike-prometheus-exporter . \
RUN go build -ldflags="-X 'main.version=$VERSION'" -o aerospike-prometheus-exporter ./cmd \
&& cp aerospike-prometheus-exporter /aerospike-prometheus-exporter

FROM alpine:latest

COPY --from=builder /aerospike-prometheus-exporter /usr/bin/aerospike-prometheus-exporter
COPY ape.toml.template /etc/aerospike-prometheus-exporter/ape.toml.template
COPY gauge_stats_list.toml /etc/aerospike-prometheus-exporter/gauge_stats_list.toml
COPY configs/ape.toml.template /etc/aerospike-prometheus-exporter/ape.toml.template
COPY configs/gauge_stats_list.toml /etc/aerospike-prometheus-exporter/gauge_stats_list.toml
COPY docker-entrypoint.sh /docker-entrypoint.sh

RUN chmod -R a+rwX /etc/aerospike-prometheus-exporter
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include Makefile.vars
.PHONY: exporter
exporter:
@echo $(GO_FIPS)
$(GO_ENV_VARS) GOEXPERIMENT=$(GO_FIPS) go build -ldflags="-X 'main.version=$(VERSION)'" -o aerospike-prometheus-exporter .
$(GO_ENV_VARS) GOEXPERIMENT=$(GO_FIPS) go build -ldflags="-X 'main.version=$(VERSION)'" -o aerospike-prometheus-exporter ./cmd

.PHONY: fipsparam
fipsparam:
Expand All @@ -31,7 +31,8 @@ lint:

.PHONY: test
test: ## Run all the test-cases defined in this folder.
go test -v ./...
## for verbose mode use go test -v ./...
go test ./...

# Builds RPM, DEB and TAR packages
# Requires FPM package manager
Expand Down
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We appreciate feedback from community members on the [issues](https://github.com

#### Pre Requisites

- Install Go v1.17+
- Install Go v1.20+

#### Steps

Expand Down Expand Up @@ -235,20 +235,45 @@ make release-docker-multi-arch
labels={zone="asia-south1-a", platform="google compute engine"}
```
- Update exporter's cloud_provider to get few cloud details - region, availability-zone or location.
```toml
[Agent]
# supported cloud provider values are - AWS, Azure and GCP
cloud_provider = aws
```

- Update exporter's refresh_system_stats to get few system metrics like open-filefd, memory, network recv/trans packets etc.,
```toml
[Agent]
refresh_system_stats = true
```
- Update exporter's OTel configuration to send metrics to a gRPC end-point (NOTE: only gRPC endpoint is supported for now)
```toml
[Agent]
OPEN_TELEMETRY = true
[Agen.OpenTelemetry]
```

- Use allowlist and blocklist to filter out required metrics (optional). The allowlist and blocklist supports standard wildcards (globbing patterns which include - `? (question mark)`, `* (asterisk)`, `[ ] (square brackets)`, `{ } (curly brackets)`, `[!]` and `\ (backslash)`) for bulk metrics filtering. For example,
```toml
[Aerospike]
# Metrics Allowlist - If specified, only these metrics will be scraped. An empty list will exclude all metrics.
# Metrics Allowlist - If specified, only these metrics will be scraped. An empty list will include all metrics.
# Commenting out the below allowlist configs will disable metrics filtering (i.e. all metrics will be scraped).
# Namespace metrics allowlist
namespace_metrics_allowlist=[
"client_read_[a-z]*",
"stop_writes",
"storage-engine.file.defrag_q",
"storage-engine.file*",
"storage-engine.file\\[*\\].*",
"storage-engine.file*defrag_q",
"client_write_success",
"memory_*_bytes",
"*memory-pct",
"objects",
"*_available_pct"
]
Expand All @@ -275,18 +300,6 @@ make release-docker-multi-arch
"lap_us"
]
# Job (scans/queries) metrics allowlist
job_metrics_allowlist = [
"rps",
"active-threads",
"job-progress",
"run-time",
"recs-throttled",
"recs-succeeded",
"recs-failed",
"net-io-bytes"
]
# Secondary index metrics allowlist
sindex_metrics_allowlist = [
"entries",
Expand Down Expand Up @@ -317,9 +330,6 @@ make release-docker-multi-arch
# XDR metrics blocklist (only for Aerospike versions 5.0 and above)
# xdr_metrics_blocklist=[]
# Job (scans/queries) metrics blocklist
# job_metrics_blocklist = []
# Secondary index metrics blocklist
# sindex_metrics_blocklist = []
```
Expand Down
49 changes: 0 additions & 49 deletions aerospike_stat.go

This file was deleted.

72 changes: 72 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package main

import (
"flag"
"fmt"
"os"

"github.com/aerospike/aerospike-prometheus-exporter/internal/pkg/config"
"github.com/aerospike/aerospike-prometheus-exporter/internal/pkg/executors"

log "github.com/sirupsen/logrus"
)

var (
configFile = flag.String("config", "/etc/aerospike-prometheus-exporter/ape.toml", "Config File")
showUsage = flag.Bool("u", false, "Show usage information")
showVersion = flag.Bool("version", false, "Print version")

version = "v1.9.0"

// Gauge related
//
gaugeStatsFile = flag.String("gauge-list", "/etc/aerospike-prometheus-exporter/gauge_stats_list.toml", "Gauge stats File")
// gaugeStatHandler *GaugeStats
)

func main() {
log.Infof("Welcome to Aerospike Prometheus Exporter %s", version)
parseCommandlineArgs()

// initialize configs and gauge-stats
config.InitConfig(*configFile)
config.InitGaugeStats(*gaugeStatsFile)

if config.Cfg.Agent.PrometheusEnabled {
startExecutor("prometheus")
}
if config.Cfg.Agent.OtelEnabled {
startExecutor("otel")
}

select {}
}

func startExecutor(mode string) {
metric_handlers := executors.GetExecutors()

processor := metric_handlers[mode]
log.Infof("Starting metrics serving mode with '%s'", mode)
if processor != nil {
// start processor in a separate thread
go func() {
err := processor.Initialize()
if err != nil {
fmt.Println("Error while Initializing Processor ", err)
}
}()
}
}

func parseCommandlineArgs() {
flag.Parse()
if *showUsage {
flag.Usage()
os.Exit(0)
}

if *showVersion {
fmt.Println(version)
os.Exit(0)
}
}
Loading

0 comments on commit b0738b5

Please sign in to comment.