1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 11:48:53 +00:00

option to disable prometheus compaction

This commit is contained in:
Renju George 2019-11-26 16:15:30 +00:00
parent bcbf58e631
commit ecd8fd98bd
4 changed files with 11 additions and 1 deletions
Documentation
example/prometheus-operator-crd
pkg
apis/monitoring/v1
prometheus

View file

@ -361,6 +361,7 @@ PrometheusSpec is a specification of the desired behavior of the Prometheus clus
| prometheusExternalLabelName | Name of Prometheus external label used to denote Prometheus instance name. Defaults to the value of `prometheus`. External label will _not_ be added when value is set to empty string (`\"\"`). | *string | false |
| retention | Time duration Prometheus shall retain data for. Default is '24h', and must match the regular expression `[0-9]+(ms\|s\|m\|h\|d\|w\|y)` (milliseconds seconds minutes hours days weeks years). | string | false |
| retentionSize | Maximum amount of disk space used by blocks. | string | false |
| disableCompaction | Disable prometheus compaction. | bool | false |
| walCompression | Enable compression of the write-ahead log using Snappy. This flag is only available in versions of Prometheus >= 2.11.0. | *bool | false |
| logLevel | Log level for Prometheus to be configured with. | string | false |
| logFormat | Log format for Prometheus to be configured with. | string | false |

View file

@ -2100,6 +2100,9 @@ spec:
- name
type: object
type: array
disableCompaction:
description: Disable prometheus compaction.
type: boolean
enableAdminAPI:
description: 'Enable access to prometheus web admin API. Defaults to
the value of `false`. WARNING: Enabling the admin APIs enables mutating

View file

@ -131,6 +131,8 @@ type PrometheusSpec struct {
Retention string `json:"retention,omitempty"`
// Maximum amount of disk space used by blocks.
RetentionSize string `json:"retentionSize,omitempty"`
// Disable prometheus compaction.
DisableCompaction bool `json:"disableCompaction,omitempty"`
// Enable compression of the write-ahead log using Snappy. This flag is
// only available in versions of Prometheus >= 2.11.0.
WALCompression *bool `json:"walCompression,omitempty"`

View file

@ -737,6 +737,7 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
additionalContainers = append(additionalContainers, container)
}
disableCompaction := p.Spec.DisableCompaction
if p.Spec.Thanos != nil {
// Version is used by default.
// If the tag is specified, we use the tag to identify the container image.
@ -812,7 +813,7 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
})
// NOTE(bwplotka): As described in https://thanos.io/components/sidecar.md/ we have to turn off compaction of Prometheus
// to avoid races during upload, if the uploads are configured.
promArgs = append(promArgs, "--storage.tsdb.max-block-duration=2h")
disableCompaction = true
}
if p.Spec.LogLevel != "" {
@ -823,6 +824,9 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
}
additionalContainers = append(additionalContainers, container)
}
if disableCompaction {
promArgs = append(promArgs, "--storage.tsdb.max-block-duration=2h")
}
// Version is used by default.
// If the tag is specified, we use the tag to identify the container image.