Skip to content

Commit

Permalink
Feature: Add option to skip collecting latency histogram metric (#913)
Browse files Browse the repository at this point in the history
Fixes: #784
  • Loading branch information
Nklya authored May 31, 2024
1 parent 2c968d5 commit de84178
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 111 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Prometheus uses file watches and all changes to the json file are applied immedi
| redis-only-metrics | REDIS_EXPORTER_REDIS_ONLY_METRICS | Whether to also export go runtime metrics, defaults to false. |
| include-config-metrics | REDIS_EXPORTER_INCL_CONFIG_METRICS | Whether to include all config settings as metrics, defaults to false. |
| include-system-metrics | REDIS_EXPORTER_INCL_SYSTEM_METRICS | Whether to include system metrics like `total_system_memory_bytes`, defaults to false. |
| exclude-latency-histogram-metrics | REDIS_EXPORTER_EXCLUDE_LATENCY_HISTOGRAM_METRICS | Do not try to collect latency histogram metrics (to avoid `WARNING, LOGGED ONCE ONLY: cmd LATENCY HISTOGRAM` error on Redis < v7). |
| redact-config-metrics | REDIS_EXPORTER_REDACT_CONFIG_METRICS | Whether to redact config settings that include potentially sensitive information like passwords. |
| ping-on-connect | REDIS_EXPORTER_PING_ON_CONNECT | Whether to ping the redis instance after connecting and record the duration as a metric, defaults to false. |
| is-tile38 | REDIS_EXPORTER_IS_TILE38 | Whether to scrape Tile38 specific metrics, defaults to false. |
Expand Down
75 changes: 39 additions & 36 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,42 @@ type Exporter struct {
}

type Options struct {
User string
Password string
Namespace string
PasswordMap map[string]string
ConfigCommandName string
CheckKeys string
CheckSingleKeys string
CheckStreams string
CheckSingleStreams string
StreamsExcludeConsumerMetrics bool
CheckKeysBatchSize int64
CheckKeyGroups string
MaxDistinctKeyGroups int64
CountKeys string
LuaScript map[string][]byte
ClientCertFile string
ClientKeyFile string
CaCertFile string
InclConfigMetrics bool
DisableExportingKeyValues bool
RedactConfigMetrics bool
InclSystemMetrics bool
SkipTLSVerification bool
SetClientName bool
IsTile38 bool
IsCluster bool
ExportClientList bool
ExportClientsInclPort bool
ConnectionTimeouts time.Duration
MetricsPath string
RedisMetricsOnly bool
PingOnConnect bool
RedisPwdFile string
Registry *prometheus.Registry
BuildInfo BuildInfo
User string
Password string
Namespace string
PasswordMap map[string]string
ConfigCommandName string
CheckKeys string
CheckSingleKeys string
CheckStreams string
CheckSingleStreams string
StreamsExcludeConsumerMetrics bool
CheckKeysBatchSize int64
CheckKeyGroups string
MaxDistinctKeyGroups int64
CountKeys string
LuaScript map[string][]byte
ClientCertFile string
ClientKeyFile string
CaCertFile string
InclConfigMetrics bool
DisableExportingKeyValues bool
ExcludeLatencyHistogramMetrics bool
RedactConfigMetrics bool
InclSystemMetrics bool
SkipTLSVerification bool
SetClientName bool
IsTile38 bool
IsCluster bool
ExportClientList bool
ExportClientsInclPort bool
ConnectionTimeouts time.Duration
MetricsPath string
RedisMetricsOnly bool
PingOnConnect bool
RedisPwdFile string
Registry *prometheus.Registry
BuildInfo BuildInfo
}

// NewRedisExporter returns a new exporter of Redis metrics.
Expand Down Expand Up @@ -634,7 +635,9 @@ func (e *Exporter) scrapeRedisHost(ch chan<- prometheus.Metric) error {

e.extractInfoMetrics(ch, infoAll, dbCount)

e.extractLatencyMetrics(ch, infoAll, c)
if !e.options.ExcludeLatencyHistogramMetrics {
e.extractLatencyMetrics(ch, infoAll, c)
}

if e.options.IsCluster {
clusterClient, err := e.connectToRedisCluster()
Expand Down
Loading

0 comments on commit de84178

Please sign in to comment.