Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add option to skip collecting latency histogram metric #913

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading