1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-15 16:56:24 +00:00

feat: Support OutOfOrderTimeWindow field for PrometheusAgent (#6851)

* update PrometheusAgent

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
---------

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
This commit is contained in:
dongjiang 2024-08-21 21:46:19 +08:00 committed by GitHub
parent fabf336014
commit 50d94c0e2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 290 additions and 60 deletions

107
Documentation/api.md generated
View file

@ -2826,6 +2826,21 @@ If unset, the operator assumes the &ldquo;Endpoints&rdquo; role.</p>
</tr>
<tr>
<td>
<code>tsdb</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TSDBSpec">
TSDBSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus &gt;= v2.39.0 or PrometheusAgent &gt;= v2.54.0.</p>
</td>
</tr>
<tr>
<td>
<code>baseImage</code><br/>
<em>
string
@ -3140,20 +3155,6 @@ ensure only clients authorized to perform these actions can do so.</p>
<a href="https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis">https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis</a></p>
</td>
</tr>
<tr>
<td>
<code>tsdb</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TSDBSpec">
TSDBSpec
</a>
</em>
</td>
<td>
<p>Defines the runtime reloadable configuration of the timeseries database
(TSDB).</p>
</td>
</tr>
</table>
</td>
</tr>
@ -7573,6 +7574,21 @@ ServiceDiscoveryRole
If unset, the operator assumes the &ldquo;Endpoints&rdquo; role.</p>
</td>
</tr>
<tr>
<td>
<code>tsdb</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TSDBSpec">
TSDBSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus &gt;= v2.39.0 or PrometheusAgent &gt;= v2.54.0.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="monitoring.coreos.com/v1.Condition">Condition
@ -11883,6 +11899,21 @@ If unset, the operator assumes the &ldquo;Endpoints&rdquo; role.</p>
</tr>
<tr>
<td>
<code>tsdb</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TSDBSpec">
TSDBSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus &gt;= v2.39.0 or PrometheusAgent &gt;= v2.54.0.</p>
</td>
</tr>
<tr>
<td>
<code>baseImage</code><br/>
<em>
string
@ -12197,20 +12228,6 @@ ensure only clients authorized to perform these actions can do so.</p>
<a href="https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis">https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis</a></p>
</td>
</tr>
<tr>
<td>
<code>tsdb</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TSDBSpec">
TSDBSpec
</a>
</em>
</td>
<td>
<p>Defines the runtime reloadable configuration of the timeseries database
(TSDB).</p>
</td>
</tr>
</tbody>
</table>
<h3 id="monitoring.coreos.com/v1.PrometheusStatus">PrometheusStatus
@ -14829,7 +14846,7 @@ string
<h3 id="monitoring.coreos.com/v1.TSDBSpec">TSDBSpec
</h3>
<p>
(<em>Appears on:</em><a href="#monitoring.coreos.com/v1.PrometheusSpec">PrometheusSpec</a>)
(<em>Appears on:</em><a href="#monitoring.coreos.com/v1.CommonPrometheusFields">CommonPrometheusFields</a>)
</p>
<div>
</div>
@ -14857,7 +14874,7 @@ respect to the TSDB max time.</p>
the timestamp of the sample is &gt;= (TSDB.MaxTime - outOfOrderTimeWindow).</p>
<p>This is an <em>experimental feature</em>, it may change in any upcoming release
in a breaking way.</p>
<p>It requires Prometheus &gt;= v2.39.0.</p>
<p>It requires Prometheus &gt;= v2.39.0 or PrometheusAgent &gt;= v2.54.0.</p>
</td>
</tr>
</tbody>
@ -18144,6 +18161,21 @@ ServiceDiscoveryRole
If unset, the operator assumes the &ldquo;Endpoints&rdquo; role.</p>
</td>
</tr>
<tr>
<td>
<code>tsdb</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TSDBSpec">
TSDBSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus &gt;= v2.39.0 or PrometheusAgent &gt;= v2.54.0.</p>
</td>
</tr>
</table>
</td>
</tr>
@ -25606,6 +25638,21 @@ ServiceDiscoveryRole
If unset, the operator assumes the &ldquo;Endpoints&rdquo; role.</p>
</td>
</tr>
<tr>
<td>
<code>tsdb</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TSDBSpec">
TSDBSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus &gt;= v2.39.0 or PrometheusAgent &gt;= v2.54.0.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="monitoring.coreos.com/v1alpha1.PuppetDBSDConfig">PuppetDBSDConfig

26
bundle.yaml generated
View file

@ -28422,6 +28422,26 @@ spec:
required:
- endpoint
type: object
tsdb:
description: |-
Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
properties:
outOfOrderTimeWindow:
description: |-
Configures how old an out-of-order/out-of-bounds sample can be with
respect to the TSDB max time.
An out-of-order/out-of-bounds sample is ingested into the TSDB as long as
the timestamp of the sample is >= (TSDB.MaxTime - outOfOrderTimeWindow).
This is an *experimental feature*, it may change in any upcoming release
in a breaking way.
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object
version:
description: |-
Version of Prometheus being deployed. The operator uses this information
@ -41074,8 +41094,8 @@ spec:
type: object
tsdb:
description: |-
Defines the runtime reloadable configuration of the timeseries database
(TSDB).
Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
properties:
outOfOrderTimeWindow:
description: |-
@ -41088,7 +41108,7 @@ spec:
This is an *experimental feature*, it may change in any upcoming release
in a breaking way.
It requires Prometheus >= v2.39.0.
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object

View file

@ -8249,6 +8249,26 @@ spec:
required:
- endpoint
type: object
tsdb:
description: |-
Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
properties:
outOfOrderTimeWindow:
description: |-
Configures how old an out-of-order/out-of-bounds sample can be with
respect to the TSDB max time.
An out-of-order/out-of-bounds sample is ingested into the TSDB as long as
the timestamp of the sample is >= (TSDB.MaxTime - outOfOrderTimeWindow).
This is an *experimental feature*, it may change in any upcoming release
in a breaking way.
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object
version:
description: |-
Version of Prometheus being deployed. The operator uses this information

View file

@ -10414,8 +10414,8 @@ spec:
type: object
tsdb:
description: |-
Defines the runtime reloadable configuration of the timeseries database
(TSDB).
Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
properties:
outOfOrderTimeWindow:
description: |-
@ -10428,7 +10428,7 @@ spec:
This is an *experimental feature*, it may change in any upcoming release
in a breaking way.
It requires Prometheus >= v2.39.0.
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object

View file

@ -8250,6 +8250,26 @@ spec:
required:
- endpoint
type: object
tsdb:
description: |-
Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
properties:
outOfOrderTimeWindow:
description: |-
Configures how old an out-of-order/out-of-bounds sample can be with
respect to the TSDB max time.
An out-of-order/out-of-bounds sample is ingested into the TSDB as long as
the timestamp of the sample is >= (TSDB.MaxTime - outOfOrderTimeWindow).
This is an *experimental feature*, it may change in any upcoming release
in a breaking way.
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object
version:
description: |-
Version of Prometheus being deployed. The operator uses this information

View file

@ -10415,8 +10415,8 @@ spec:
type: object
tsdb:
description: |-
Defines the runtime reloadable configuration of the timeseries database
(TSDB).
Defines the runtime reloadable configuration of the timeseries database(TSDB).
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
properties:
outOfOrderTimeWindow:
description: |-
@ -10429,7 +10429,7 @@ spec:
This is an *experimental feature*, it may change in any upcoming release
in a breaking way.
It requires Prometheus >= v2.39.0.
It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object

View file

@ -6901,6 +6901,17 @@
],
"type": "object"
},
"tsdb": {
"description": "Defines the runtime reloadable configuration of the timeseries database(TSDB).\nIt requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.",
"properties": {
"outOfOrderTimeWindow": {
"description": "Configures how old an out-of-order/out-of-bounds sample can be with\nrespect to the TSDB max time.\n\nAn out-of-order/out-of-bounds sample is ingested into the TSDB as long as\nthe timestamp of the sample is >= (TSDB.MaxTime - outOfOrderTimeWindow).\n\nThis is an *experimental feature*, it may change in any upcoming release\nin a breaking way.\n\nIt requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.",
"pattern": "^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$",
"type": "string"
}
},
"type": "object"
},
"version": {
"description": "Version of Prometheus being deployed. The operator uses this information\nto generate the Prometheus StatefulSet + configuration files.\n\nIf not specified, the operator assumes the latest upstream version of\nPrometheus available at the time when the version of the operator was\nreleased.",
"type": "string"

View file

@ -8800,10 +8800,10 @@
"type": "object"
},
"tsdb": {
"description": "Defines the runtime reloadable configuration of the timeseries database\n(TSDB).",
"description": "Defines the runtime reloadable configuration of the timeseries database(TSDB).\nIt requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.",
"properties": {
"outOfOrderTimeWindow": {
"description": "Configures how old an out-of-order/out-of-bounds sample can be with\nrespect to the TSDB max time.\n\nAn out-of-order/out-of-bounds sample is ingested into the TSDB as long as\nthe timestamp of the sample is >= (TSDB.MaxTime - outOfOrderTimeWindow).\n\nThis is an *experimental feature*, it may change in any upcoming release\nin a breaking way.\n\nIt requires Prometheus >= v2.39.0.",
"description": "Configures how old an out-of-order/out-of-bounds sample can be with\nrespect to the TSDB max time.\n\nAn out-of-order/out-of-bounds sample is ingested into the TSDB as long as\nthe timestamp of the sample is >= (TSDB.MaxTime - outOfOrderTimeWindow).\n\nThis is an *experimental feature*, it may change in any upcoming release\nin a breaking way.\n\nIt requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.",
"pattern": "^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$",
"type": "string"
}

View file

@ -787,6 +787,12 @@ type CommonPrometheusFields struct {
//
// +optional
ServiceDiscoveryRole *ServiceDiscoveryRole `json:"serviceDiscoveryRole,omitempty"`
// Defines the runtime reloadable configuration of the timeseries database(TSDB).
// It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
//
// +optional
TSDB *TSDBSpec `json:"tsdb,omitempty"`
}
// +kubebuilder:validation:Enum=HTTP;ProcessSignal
@ -1009,10 +1015,6 @@ type PrometheusSpec struct {
// For more information:
// https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis
EnableAdminAPI bool `json:"enableAdminAPI,omitempty"`
// Defines the runtime reloadable configuration of the timeseries database
// (TSDB).
TSDB TSDBSpec `json:"tsdb,omitempty"`
}
type PrometheusTracingConfig struct {
@ -1881,7 +1883,7 @@ type TSDBSpec struct {
// This is an *experimental feature*, it may change in any upcoming release
// in a breaking way.
//
// It requires Prometheus >= v2.39.0.
// It requires Prometheus >= v2.39.0 or PrometheusAgent >= v2.54.0.
OutOfOrderTimeWindow Duration `json:"outOfOrderTimeWindow,omitempty"`
}

View file

@ -984,6 +984,11 @@ func (in *CommonPrometheusFields) DeepCopyInto(out *CommonPrometheusFields) {
*out = new(ServiceDiscoveryRole)
**out = **in
}
if in.TSDB != nil {
in, out := &in.TSDB, &out.TSDB
*out = new(TSDBSpec)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CommonPrometheusFields.
@ -2152,7 +2157,6 @@ func (in *PrometheusSpec) DeepCopyInto(out *PrometheusSpec) {
*out = new(Exemplars)
(*in).DeepCopyInto(*out)
}
out.TSDB = in.TSDB
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusSpec.

View file

@ -109,6 +109,7 @@ type CommonPrometheusFieldsApplyConfiguration struct {
MaximumStartupDurationSeconds *int32 `json:"maximumStartupDurationSeconds,omitempty"`
ScrapeClasses []ScrapeClassApplyConfiguration `json:"scrapeClasses,omitempty"`
ServiceDiscoveryRole *monitoringv1.ServiceDiscoveryRole `json:"serviceDiscoveryRole,omitempty"`
TSDB *TSDBSpecApplyConfiguration `json:"tsdb,omitempty"`
}
// CommonPrometheusFieldsApplyConfiguration constructs a declarative configuration of the CommonPrometheusFields type for use with
@ -844,3 +845,11 @@ func (b *CommonPrometheusFieldsApplyConfiguration) WithServiceDiscoveryRole(valu
b.ServiceDiscoveryRole = &value
return b
}
// WithTSDB sets the TSDB field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the TSDB field is set to the value of the last call.
func (b *CommonPrometheusFieldsApplyConfiguration) WithTSDB(value *TSDBSpecApplyConfiguration) *CommonPrometheusFieldsApplyConfiguration {
b.TSDB = value
return b
}

View file

@ -48,7 +48,6 @@ type PrometheusSpecApplyConfiguration struct {
Exemplars *ExemplarsApplyConfiguration `json:"exemplars,omitempty"`
EvaluationInterval *monitoringv1.Duration `json:"evaluationInterval,omitempty"`
EnableAdminAPI *bool `json:"enableAdminAPI,omitempty"`
TSDB *TSDBSpecApplyConfiguration `json:"tsdb,omitempty"`
}
// PrometheusSpecApplyConfiguration constructs a declarative configuration of the PrometheusSpec type for use with
@ -785,6 +784,14 @@ func (b *PrometheusSpecApplyConfiguration) WithServiceDiscoveryRole(value monito
return b
}
// WithTSDB sets the TSDB field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the TSDB field is set to the value of the last call.
func (b *PrometheusSpecApplyConfiguration) WithTSDB(value *TSDBSpecApplyConfiguration) *PrometheusSpecApplyConfiguration {
b.TSDB = value
return b
}
// WithBaseImage sets the BaseImage field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the BaseImage field is set to the value of the last call.
@ -962,11 +969,3 @@ func (b *PrometheusSpecApplyConfiguration) WithEnableAdminAPI(value bool) *Prome
b.EnableAdminAPI = &value
return b
}
// WithTSDB sets the TSDB field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the TSDB field is set to the value of the last call.
func (b *PrometheusSpecApplyConfiguration) WithTSDB(value *TSDBSpecApplyConfiguration) *PrometheusSpecApplyConfiguration {
b.TSDB = value
return b
}

View file

@ -772,3 +772,11 @@ func (b *PrometheusAgentSpecApplyConfiguration) WithServiceDiscoveryRole(value m
b.ServiceDiscoveryRole = &value
return b
}
// WithTSDB sets the TSDB field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the TSDB field is set to the value of the last call.
func (b *PrometheusAgentSpecApplyConfiguration) WithTSDB(value *v1.TSDBSpecApplyConfiguration) *PrometheusAgentSpecApplyConfiguration {
b.TSDB = value
return b
}

View file

@ -909,6 +909,7 @@ func (c *Operator) createOrUpdateConfigurationSecret(ctx context.Context, p *mon
pmons,
bmons,
scrapeConfigs,
p.Spec.TSDB,
store,
additionalScrapeConfigs,
)

View file

@ -704,7 +704,7 @@ func (cg *ConfigGenerator) GenerateServerConfiguration(
queryLogFile string,
ruleSelector *metav1.LabelSelector,
exemplars *monitoringv1.Exemplars,
tsdb monitoringv1.TSDBSpec,
tsdb *monitoringv1.TSDBSpec,
alerting *monitoringv1.AlertingSpec,
remoteRead []monitoringv1.RemoteReadSpec,
sMons map[string]*monitoringv1.ServiceMonitor,
@ -808,7 +808,7 @@ func (cg *ConfigGenerator) GenerateServerConfiguration(
return yaml.Marshal(cfg)
}
func (cg *ConfigGenerator) appendStorageSettingsConfig(cfg yaml.MapSlice, exemplars *monitoringv1.Exemplars, tsdb monitoringv1.TSDBSpec) (yaml.MapSlice, error) {
func (cg *ConfigGenerator) appendStorageSettingsConfig(cfg yaml.MapSlice, exemplars *monitoringv1.Exemplars, tsdb *monitoringv1.TSDBSpec) (yaml.MapSlice, error) {
var (
storage yaml.MapSlice
cgStorage = cg.WithMinimumVersion("2.29.0")
@ -823,7 +823,7 @@ func (cg *ConfigGenerator) appendStorageSettingsConfig(cfg yaml.MapSlice, exempl
})
}
if tsdb.OutOfOrderTimeWindow != "" {
if tsdb != nil && tsdb.OutOfOrderTimeWindow != "" {
storage = cg.WithMinimumVersion("2.39.0").AppendMapItem(storage, "tsdb", yaml.MapSlice{
{
Key: "out_of_order_time_window",
@ -2519,6 +2519,7 @@ func (cg *ConfigGenerator) GenerateAgentConfiguration(
pMons map[string]*monitoringv1.PodMonitor,
probes map[string]*monitoringv1.Probe,
sCons map[string]*monitoringv1alpha1.ScrapeConfig,
tsdb *monitoringv1.TSDBSpec,
store *assets.StoreBuilder,
additionalScrapeConfigs []byte,
) ([]byte, error) {
@ -2564,6 +2565,18 @@ func (cg *ConfigGenerator) GenerateAgentConfiguration(
Value: scrapeConfigs,
})
// TSDB
if tsdb != nil && tsdb.OutOfOrderTimeWindow != "" {
var storage yaml.MapSlice
storage = cg.AppendMapItem(storage, "tsdb", yaml.MapSlice{
{
Key: "out_of_order_time_window",
Value: tsdb.OutOfOrderTimeWindow,
},
})
cfg = cg.WithMinimumVersion("2.54.0").AppendMapItem(cfg, "storage", storage)
}
// Remote write config
if len(cpf.RemoteWrite) > 0 {
cfg = append(cfg, cg.generateRemoteWriteConfig(store))

View file

@ -5396,7 +5396,7 @@ func TestTSDBConfig(t *testing.T) {
p.Spec.CommonPrometheusFields.Version = tc.version
}
if tc.tsdb != nil {
p.Spec.TSDB = *tc.tsdb
p.Spec.TSDB = tc.tsdb
}
cg := mustNewConfigGenerator(t, p)
@ -5424,6 +5424,61 @@ func TestTSDBConfig(t *testing.T) {
}
}
func TestTSDBConfigPrometheusAgent(t *testing.T) {
for _, tc := range []struct {
name string
p *monitoringv1.Prometheus
version string
tsdb *monitoringv1.TSDBSpec
golden string
}{
{
name: "PrometheusAgent no TSDB config",
golden: "PrometheusAgent_no_TSDB_config.golden",
},
{
name: "PrometheusAgent TSDB config < v2.54.0",
version: "v2.53.0",
tsdb: &monitoringv1.TSDBSpec{
OutOfOrderTimeWindow: monitoringv1.Duration("10m"),
},
golden: "PrometheusAgent_TSDB_config_less_than_v2.53.0.golden",
},
{
name: "PrometheusAgent TSDB config >= v2.54.0",
version: "v2.54.0",
tsdb: &monitoringv1.TSDBSpec{
OutOfOrderTimeWindow: monitoringv1.Duration("10m"),
},
golden: "PrometheusAgent_TSDB_config_greater_than_or_equal_to_v2.54.0.golden",
},
} {
t.Run(tc.name, func(t *testing.T) {
p := defaultPrometheus()
if tc.version != "" {
p.Spec.CommonPrometheusFields.Version = tc.version
}
if tc.tsdb != nil {
p.Spec.TSDB = tc.tsdb
}
cg := mustNewConfigGenerator(t, p)
cfg, err := cg.GenerateAgentConfiguration(
nil,
nil,
nil,
nil,
tc.tsdb,
&assets.StoreBuilder{},
nil,
)
require.NoError(t, err)
golden.Assert(t, string(cfg), tc.golden)
})
}
}
func TestGenerateRelabelConfig(t *testing.T) {
p := defaultPrometheus()

View file

@ -0,0 +1,9 @@
global:
scrape_interval: 30s
external_labels:
prometheus: default/test
prometheus_replica: $(POD_NAME)
scrape_configs: []
storage:
tsdb:
out_of_order_time_window: 10m

View file

@ -0,0 +1,6 @@
global:
scrape_interval: 30s
external_labels:
prometheus: default/test
prometheus_replica: $(POD_NAME)
scrape_configs: []

View file

@ -0,0 +1,6 @@
global:
scrape_interval: 30s
external_labels:
prometheus: default/test
prometheus_replica: $(POD_NAME)
scrape_configs: []