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

Make retention configurable

This commit is contained in:
Fabian Reinartz 2016-11-02 11:50:36 -07:00
parent 7cdba84927
commit 9e1bbd628a
2 changed files with 8 additions and 4 deletions
pkg
operator
spec

View file

@ -41,13 +41,17 @@ func makePetSet(p *spec.Prometheus, old *v1alpha1.PetSet, alertmanagers []string
if replicas < 1 {
replicas = 1
}
retention := p.Spec.Retention
if retention == "" {
retention = "24h"
}
image := fmt.Sprintf("%s:%s", baseImage, version)
petset := &v1alpha1.PetSet{
ObjectMeta: v1.ObjectMeta{
Name: p.Name,
},
Spec: makePetSetSpec(p.Name, image, version, replicas, alertmanagers),
Spec: makePetSetSpec(p.Name, image, version, retention, replicas, alertmanagers),
}
if vc := p.Spec.Storage; vc == nil {
petset.Spec.Template.Spec.Volumes = append(petset.Spec.Template.Spec.Volumes, v1.Volume{
@ -120,7 +124,7 @@ func makePetSetService(p *spec.Prometheus) *v1.Service {
return svc
}
func makePetSetSpec(name, image, version string, replicas int32, alertmanagers []string) v1alpha1.PetSetSpec {
func makePetSetSpec(name, image, version, retention string, replicas int32, alertmanagers []string) v1alpha1.PetSetSpec {
// Prometheus may take quite long to shut down to checkpoint existing data.
// Allow up to 10 minutes for clean termination.
terminationGracePeriod := int64(600)
@ -151,7 +155,7 @@ func makePetSetSpec(name, image, version string, replicas int32, alertmanagers [
},
},
Args: []string{
"-storage.local.retention=12h",
"-storage.local.retention=" + retention,
"-storage.local.memory-chunks=500000",
"-storage.local.path=/var/prometheus/data",
"-config.file=/etc/prometheus/config/prometheus.yaml",

View file

@ -42,9 +42,9 @@ type PrometheusSpec struct {
Version string `json:"version"`
BaseImage string `json:"baseImage"`
Replicas int32 `json:"replicas"`
Retention string `json:"retention"`
Storage *StorageSpec `json:"storage"`
Alerting AlertingSpec `json:"alerting"`
// Retention string `json:"retention"`
// Replicas int `json:"replicas"`
// Resources apiV1.ResourceRequirements `json:"resources"`
// Alerting AlertingSpec `json:"alerting"`