Skip to content

Commit

Permalink
[TOOLS-1740] - Export all histogram buckets by default for latency me…
Browse files Browse the repository at this point in the history
…trics (#46)

- Exports all histogram buckets by default
- Adds new configuration 'latency_buckets_count' to control number of buckets to be exported
  • Loading branch information
spkesan authored Aug 1, 2021
1 parent 864b8c3 commit 4032730
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 9 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ Packages will be generated under `./pkg/target/` directory.
db_host="localhost"
db_port=3000
```

- Configure timeout (in seconds) for info commands to Aerospike node (optional). Default value is `5` seconds.
```toml
[Aerospike]
# timeout for sending commands to the server node in seconds
timeout=5
```

- Update Aerospike security and TLS configurations (optional),
```toml
[Aerospike]
Expand Down Expand Up @@ -302,4 +310,25 @@ Packages will be generated under `./pkg/target/` directory.
"admin",
"superuser"
]
```
```

- Exporter logs to console by default. To enable file logging, use `log_file` configuration to specify a file path. Use `log_level` configuration to specify a logging level (optional). Default logging level is `info`.
```toml
[Agent]
# Exporter logging configuration
# Log file path (optional, logs to console by default)
# Level can be info|warning,warn|error,err|debug|trace ('info' by default)
log_file = ""
log_level = ""
```

- Use `latency_buckets_count` to specify number of histogram buckets to be exported for latency metrics (optional). Bucket thresholds range from 2<sup>0</sup> to 2<sup>16</sup> (`17` buckets). All threshold buckets are exported by default (`latency_buckets_count=0`).

Example, `latency_buckets_count=5` will export first five buckets i.e. `<=1ms`, `<=2ms`, `<=4ms`, `<=8ms` and `<=16ms`.
```toml
[Aerospike]
# Number of histogram buckets to export for latency metrics. Bucket thresholds range from 2^0 to 2^16 (17 buckets).
# e.g. latency_buckets_count=5 will export first five buckets i.e. <=1ms, <=2ms, <=4ms, <=8ms and <=16ms.
# Default: 0 (export all threshold buckets).
latency_buckets_count=0
```
5 changes: 5 additions & 0 deletions ape.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ auth_mode=""
# timeout for sending commands to the server node in seconds
timeout=5

# Number of histogram buckets to export for latency metrics. Bucket thresholds range from 2^0 to 2^16 (17 buckets).
# e.g. latency_buckets_count=5 will export first five buckets i.e. <=1ms, <=2ms, <=4ms, <=8ms and <=16ms.
# Default: 0 (export all threshold buckets).
latency_buckets_count=0

# Metrics Allowlist - If specified, only these metrics will be scraped. An empty list will exclude all metrics.
# Commenting out the below allowlist configs will disable metrics filtering (i.e. all metrics will be scraped).

Expand Down
5 changes: 5 additions & 0 deletions ape.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ auth_mode="${AS_AUTH_MODE}"
# timeout for sending commands to the server node in seconds
timeout=${TICKER_TIMEOUT}

# Number of histogram buckets to export for latency metrics. Bucket thresholds range from 2^0 to 2^16 (17 buckets).
# e.g. latency_buckets_count=5 will export first five buckets i.e. <=1ms, <=2ms, <=4ms, <=8ms and <=16ms.
# Default: 0 (export all threshold buckets).
latency_buckets_count=${LATENCY_BUCKETS_COUNT}

# Metrics Allowlist - If specified, only these metrics will be scraped. An empty list will exclude all metrics.
# Commenting out the below allowlist configs will disable metrics filtering (i.e. all metrics will be scraped).

Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Config struct {

Timeout uint8 `toml:"timeout"`

LatencyBucketsCount uint8 `toml:"latency_buckets_count"`

UserMetricsUsersAllowlist []string `toml:"user_metrics_users_allowlist"`
UserMetricsUsersBlocklist []string `toml:"user_metrics_users_blocklist"`

Expand Down
1 change: 1 addition & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export AS_AUTH_MODE=${AS_AUTH_MODE:-""}
export AS_AUTH_USER=${AS_AUTH_USER:-""}
export AS_AUTH_PASSWORD=${AS_AUTH_PASSWORD:-""}
export TICKER_TIMEOUT=${TICKER_TIMEOUT:-5}
export LATENCY_BUCKETS_COUNT=${LATENCY_BUCKETS_COUNT:-0}
export NAMESPACE_METRICS_ALLOWLIST=${NAMESPACE_METRICS_ALLOWLIST:-""}
export SET_METRICS_ALLOWLIST=${SET_METRICS_ALLOWLIST:-""}
export NODE_METRICS_ALLOWLIST=${NODE_METRICS_ALLOWLIST:-""}
Expand Down
12 changes: 6 additions & 6 deletions latency_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// error-no-data-yet-or-back-too-small;
// or,
// {test}-write:;
func parseLatencyInfoLegacy(s string) map[string]StatsMap {
func parseLatencyInfoLegacy(s string, latencyBucketsCount int) map[string]StatsMap {
ip := NewInfoParser(s)
res := map[string]StatsMap{}

Expand Down Expand Up @@ -103,8 +103,8 @@ func parseLatencyInfoLegacy(s string) map[string]StatsMap {
bucketLabels = append(bucketLabels, strings.Trim(bLabels[i], "><=ms"))
bucketValuesFloat = append(bucketValuesFloat, v)

// Stop after first zero bucket. No point processing further buckets.
if val == 0 {
if latencyBucketsCount > 0 && i >= latencyBucketsCount {
// latency buckets count limit reached
break
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ func parseLatencyInfoLegacy(s string) map[string]StatsMap {
// Format (with and without latency data)
// {test}-write:msec,4234.9,28.75,7.40,1.63,0.26,0.03,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00;
// {test}-read:;
func parseLatencyInfo(s string) map[string]StatsMap {
func parseLatencyInfo(s string, latencyBucketsCount int) map[string]StatsMap {
ip := NewInfoParser(s)
res := map[string]StatsMap{}

Expand Down Expand Up @@ -215,8 +215,8 @@ func parseLatencyInfo(s string) map[string]StatsMap {
bucketLabels = append(bucketLabels, strconv.Itoa(1<<(i-1)))
bucketValuesFloat = append(bucketValuesFloat, v)

// Stop after first zero bucket. No point processing further buckets.
if val == 0 {
if latencyBucketsCount > 0 && i >= latencyBucketsCount {
// latency buckets count limit reached
break
}
}
Expand Down
4 changes: 2 additions & 2 deletions watcher_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func (lw *LatencyWatcher) refresh(o *Observer, infoKeys []string, rawMetrics map
var latencyStats map[string]StatsMap

if rawMetrics["latencies:"] != "" {
latencyStats = parseLatencyInfo(rawMetrics["latencies:"])
latencyStats = parseLatencyInfo(rawMetrics["latencies:"], int(config.Aerospike.LatencyBucketsCount))
} else {
latencyStats = parseLatencyInfoLegacy(rawMetrics["latency:"])
latencyStats = parseLatencyInfoLegacy(rawMetrics["latency:"], int(config.Aerospike.LatencyBucketsCount))
}

log.Tracef("latency-stats:%+v", latencyStats)
Expand Down

0 comments on commit 4032730

Please sign in to comment.