diff --git a/README.md b/README.md index 0dff47ae..f52ae111 100644 --- a/README.md +++ b/README.md @@ -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] @@ -302,4 +310,25 @@ Packages will be generated under `./pkg/target/` directory. "admin", "superuser" ] - ``` \ No newline at end of file + ``` + +- 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 20 to 216 (`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 + ``` diff --git a/ape.toml b/ape.toml index d9eaacfa..1c8880a8 100644 --- a/ape.toml +++ b/ape.toml @@ -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). diff --git a/ape.toml.template b/ape.toml.template index eeb0f2c0..77d1fc5d 100644 --- a/ape.toml.template +++ b/ape.toml.template @@ -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). diff --git a/config.go b/config.go index 92058a93..965f63ba 100644 --- a/config.go +++ b/config.go @@ -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"` diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f6cde538..abae2501 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -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:-""} diff --git a/latency_parser.go b/latency_parser.go index 82e6ff36..e8ad0d71 100644 --- a/latency_parser.go +++ b/latency_parser.go @@ -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{} @@ -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 } } @@ -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{} @@ -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 } } diff --git a/watcher_latency.go b/watcher_latency.go index 04d8423c..b259b588 100644 --- a/watcher_latency.go +++ b/watcher_latency.go @@ -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)