Skip to content

Commit

Permalink
Merge pull request #210 from oliver006/oh_bring_back_persistence_metrics
Browse files Browse the repository at this point in the history
bring back some accidentally dropped commits
  • Loading branch information
oliver006 committed Dec 20, 2018
2 parents 19af8eb + da4f07c commit 46c1470
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace | Namespace for the metrics, defaults to `redis`.
web.listen-address | Address to listen on for web interface and telemetry, defaults to `0.0.0.0:9121`.
web.telemetry-path | Path under which to expose metrics, defaults to `metrics`.
use-cf-bindings | Enable usage of Cloud Foundry service bindings. Defaults to `false`
separator | Separator used to split redis.addr, redis.password and redis.alias into several elements. Defaults to `,`

Redis node addresses can be tcp addresses like `redis://localhost:6379`, `redis.example.com:6379` or unix socket addresses like `unix:///tmp/redis.sock`. <br>
SSL is supported by using the `rediss://` schema, for example: `rediss://azure-ssl-enabled-host.redis.cache.windows.net:6380` (note that the port is required when connecting to a non-standard 6379 port, e.g. with Azure Redis instances).
Expand Down
6 changes: 3 additions & 3 deletions contrib/grafana_prometheus_redis_dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
"show": true
},
"targets": [
{
"expr": "redis_uptime_in_seconds{addr=\"$addr\"}",
"expr": "max(max_over_time(redis_uptime_in_seconds{addr=\"$addr\"}[$__interval]))",
"intervalFactor": 2,
"legendFormat": "",
"metric": "",
Expand All @@ -131,7 +131,7 @@
"value": "null"
}
],
"valueName": "avg"
"valueName": "current"
},
{
"cacheTimeout": null,
Expand Down
6 changes: 3 additions & 3 deletions contrib/grafana_prometheus_redis_dashboard_alias.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
"show": true
},
"targets": [
{
"expr": "redis_uptime_in_seconds{instance=\"$host\",alias=\"$alias\"}",
"expr": "max(max_over_time(redis_uptime_in_seconds{instance=\"$host\",alias=\"$alias\"}[$__interval]))",
"intervalFactor": 2,
"legendFormat": "",
"metric": "",
Expand All @@ -127,7 +127,7 @@
"value": "null"
}
],
"valueName": "avg"
"valueName": "current"
},
{
"cacheTimeout": null,
Expand Down
12 changes: 9 additions & 3 deletions exporter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,27 @@ var (

// # Persistence
"rdb_changes_since_last_save": "rdb_changes_since_last_save",
"rdb_bgsave_in_progress": "rdb_bgsave_in_progress",
"rdb_last_save_time": "rdb_last_save_timestamp_seconds",
"rdb_last_bgsave_status": "rdb_last_bgsave_status",
"rdb_last_bgsave_time_sec": "rdb_last_bgsave_duration_sec",
"rdb_current_bgsave_time_sec": "rdb_current_bgsave_duration_sec",
"rdb_last_cow_size": "rdb_last_cow_size_bytes",
"aof_enabled": "aof_enabled",
"aof_rewrite_in_progress": "aof_rewrite_in_progress",
"aof_rewrite_scheduled": "aof_rewrite_scheduled",
"aof_last_rewrite_time_sec": "aof_last_rewrite_duration_sec",
"aof_current_rewrite_time_sec": "aof_current_rewrite_duration_sec",
"aof_last_cow_size": "aof_last_cow_size",
"aof_current_size": "aof_current_size",
"aof_base_size": "aof_base_size",
"aof_last_cow_size": "aof_last_cow_size_bytes",
"aof_current_size": "aof_current_size_bytes",
"aof_base_size": "aof_base_size_bytes",
"aof_pending_rewrite": "aof_pending_rewrite",
"aof_buffer_length": "aof_buffer_length",
"aof_rewrite_buffer_length": "aof_rewrite_buffer_length",
"aof_pending_bio_fsync": "aof_pending_bio_fsync",
"aof_delayed_fsync": "aof_delayed_fsync",
"aof_last_bgrewrite_status": "aof_last_bgrewrite_status",
"aof_last_write_status": "aof_last_write_status",

// # Stats
"total_connections_received": "connections_received_total",
Expand Down
30 changes: 19 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"os"
"runtime"
"strconv"

"github.com/oliver006/redis_exporter/exporter"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -18,18 +19,18 @@ var (
redisFile = flag.String("redis.file", getEnv("REDIS_FILE", ""), "Path to file containing one or more redis nodes, separated by newline. NOTE: mutually exclusive with redis.addr")
redisPassword = flag.String("redis.password", getEnv("REDIS_PASSWORD", ""), "Password for one or more redis nodes, separated by separator")
redisAlias = flag.String("redis.alias", getEnv("REDIS_ALIAS", ""), "Redis instance alias for one or more redis nodes, separated by separator")
namespace = flag.String("namespace", "redis", "Namespace for metrics")
checkKeys = flag.String("check-keys", "", "Comma separated list of key-patterns to export value and length/size, searched for with SCAN")
checkSingleKeys = flag.String("check-single-keys", "", "Comma separated list of single keys to export value and length/size")
scriptPath = flag.String("script", "", "Path to Lua Redis script for collecting extra metrics")
separator = flag.String("separator", ",", "separator used to split redis.addr, redis.password and redis.alias into several elements.")
listenAddress = flag.String("web.listen-address", ":9121", "Address to listen on for web interface and telemetry.")
metricPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
isDebug = flag.Bool("debug", false, "Output verbose debug information")
logFormat = flag.String("log-format", "txt", "Log format, valid options are txt and json")
namespace = flag.String("namespace", getEnv("REDIS_EXPORTER_NAMESPACE", "redis"), "Namespace for metrics")
checkKeys = flag.String("check-keys", getEnv("REDIS_EXPORTER_CHECK_KEYS", ""), "Comma separated list of key-patterns to export value and length/size, searched for with SCAN")
checkSingleKeys = flag.String("check-single-keys", getEnv("REDIS_EXPORTER_CHECK_SINGLE_KEYS", ""), "Comma separated list of single keys to export value and length/size")
scriptPath = flag.String("script", getEnv("REDIS_EXPORTER_SCRIPT", ""), "Path to Lua Redis script for collecting extra metrics")
separator = flag.String("separator", getEnv("REDIS_EXPORTER_SEPARATOR", ","), "separator used to split redis.addr, redis.password and redis.alias into several elements.")
listenAddress = flag.String("web.listen-address", getEnv("REDIS_EXPORTER_WEB_LISTEN_ADDRESS", ":9121"), "Address to listen on for web interface and telemetry.")
metricPath = flag.String("web.telemetry-path", getEnv("REDIS_EXPORTER_WEB_TELEMETRY_PATH", "/metrics"), "Path under which to expose metrics.")
isDebug = flag.Bool("debug", getEnvBool("REDIS_EXPORTER_DEBUG"), "Output verbose debug information")
logFormat = flag.String("log-format", getEnv("REDIS_EXPORTER_LOG_FORMAT", "txt"), "Log format, valid options are txt and json")
showVersion = flag.Bool("version", false, "Show version information and exit")
useCfBindings = flag.Bool("use-cf-bindings", false, "Use Cloud Foundry service bindings")
redisMetricsOnly = flag.Bool("redis-only-metrics", false, "Whether to export go runtime metrics also")
useCfBindings = flag.Bool("use-cf-bindings", getEnvBool("REDIS_EXPORTER_USE-CF-BINDINGS"), "Use Cloud Foundry service bindings")
redisMetricsOnly = flag.Bool("redis-only-metrics", getEnvBool("REDIS_EXPORTER_REDIS_ONLY_METRICS"), "Whether to export go runtime metrics also")

// VERSION, BUILD_DATE, GIT_COMMIT are filled in by the build script
VERSION = "<<< filled in by build >>>"
Expand All @@ -44,6 +45,13 @@ func getEnv(key string, defaultVal string) string {
return defaultVal
}

func getEnvBool(key string) (envValBool bool) {
if envVal, ok := os.LookupEnv(key); ok {
envValBool, _ = strconv.ParseBool(envVal)
}
return
}

func main() {
flag.Parse()

Expand Down

0 comments on commit 46c1470

Please sign in to comment.