diff --git a/Documentation/api.md b/Documentation/api.md index 6a76ace1d..18749a1a4 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -1000,6 +1000,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>labelLimit</code><br/> <em> uint64 @@ -1408,6 +1423,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>labelLimit</code><br/> <em> uint64 @@ -1964,6 +1994,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>externalLabels</code><br/> <em> map[string]string @@ -3652,6 +3697,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>targetLimit</code><br/> <em> uint64 @@ -6969,6 +7029,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>externalLabels</code><br/> <em> map[string]string @@ -10545,6 +10620,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>labelLimit</code><br/> <em> uint64 @@ -10904,6 +10994,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>labelLimit</code><br/> <em> uint64 @@ -11746,6 +11851,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>externalLabels</code><br/> <em> map[string]string @@ -15367,6 +15487,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>targetLimit</code><br/> <em> uint64 @@ -18409,6 +18544,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>externalLabels</code><br/> <em> map[string]string @@ -19977,6 +20127,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>honorTimestamps</code><br/> <em> bool @@ -26294,6 +26459,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>externalLabels</code><br/> <em> map[string]string @@ -29039,6 +29219,21 @@ protocols supported by Prometheus in order of preference (from most to least pre </tr> <tr> <td> +<code>scrapeFallbackProtocol</code><br/> +<em> +<a href="#monitoring.coreos.com/v1.ScrapeProtocol"> +ScrapeProtocol +</a> +</em> +</td> +<td> +<em>(Optional)</em> +<p>The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.</p> +<p>It requires Prometheus >= v3.0.0.</p> +</td> +</tr> +<tr> +<td> <code>honorTimestamps</code><br/> <em> bool diff --git a/bundle.yaml b/bundle.yaml index fee45e15e..a7e62a3bc 100644 --- a/bundle.yaml +++ b/bundle.yaml @@ -19690,6 +19690,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the @@ -20462,6 +20474,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the @@ -27746,6 +27770,18 @@ spec: type: object type: object x-kubernetes-map-type: atomic + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: default: 30s description: |- @@ -40041,6 +40077,18 @@ spec: type: object type: object x-kubernetes-map-type: atomic + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: default: 30s description: |- @@ -55805,6 +55853,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: description: ScrapeInterval is the interval between consecutive scrapes. pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$ @@ -57157,6 +57217,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_podmonitors.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_podmonitors.yaml index 493066dda..f7b4a8566 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_podmonitors.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_podmonitors.yaml @@ -1086,6 +1086,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_probes.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_probes.yaml index 2f2d320a7..28c324ac7 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_probes.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_probes.yaml @@ -681,6 +681,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml index be9616887..b6e3ba257 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheusagents.yaml @@ -6803,6 +6803,18 @@ spec: type: object type: object x-kubernetes-map-type: atomic + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: default: 30s description: |- diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml index 52daccb57..e8e0b5a2b 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_prometheuses.yaml @@ -8450,6 +8450,18 @@ spec: type: object type: object x-kubernetes-map-type: atomic + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: default: 30s description: |- diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_scrapeconfigs.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_scrapeconfigs.yaml index b7d33373d..24d9c673f 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_scrapeconfigs.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_scrapeconfigs.yaml @@ -11248,6 +11248,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: description: ScrapeInterval is the interval between consecutive scrapes. pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$ diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_servicemonitors.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_servicemonitors.yaml index 07ad3c462..53436d90a 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_servicemonitors.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_servicemonitors.yaml @@ -1106,6 +1106,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml index 36b1fff27..d1e99dbb7 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml @@ -1087,6 +1087,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml index d91a39ba6..c0884425a 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml @@ -682,6 +682,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml index 438555baf..1d2b98923 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_prometheusagents.yaml @@ -6804,6 +6804,18 @@ spec: type: object type: object x-kubernetes-map-type: atomic + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: default: 30s description: |- diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml index a17603cb1..ce25478be 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml @@ -8451,6 +8451,18 @@ spec: type: object type: object x-kubernetes-map-type: atomic + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: default: 30s description: |- diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml index 993186012..8ee01807a 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml @@ -11249,6 +11249,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeInterval: description: ScrapeInterval is the interval between consecutive scrapes. pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$ diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml index 2c1980119..74bf3d775 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml @@ -1107,6 +1107,18 @@ spec: Whether to scrape a classic histogram that is also exposed as a native histogram. It requires Prometheus >= v2.45.0. type: boolean + scrapeFallbackProtocol: + description: |- + The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + + It requires Prometheus >= v3.0.0. + enum: + - PrometheusProto + - OpenMetricsText0.0.1 + - OpenMetricsText1.0.0 + - PrometheusText0.0.4 + - PrometheusText1.0.0 + type: string scrapeProtocols: description: |- `scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the diff --git a/jsonnet/prometheus-operator/podmonitors-crd.json b/jsonnet/prometheus-operator/podmonitors-crd.json index 3fb6af3ff..282297fbb 100644 --- a/jsonnet/prometheus-operator/podmonitors-crd.json +++ b/jsonnet/prometheus-operator/podmonitors-crd.json @@ -942,6 +942,17 @@ "description": "Whether to scrape a classic histogram that is also exposed as a native histogram.\nIt requires Prometheus >= v2.45.0.", "type": "boolean" }, + "scrapeFallbackProtocol": { + "description": "The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.\n\nIt requires Prometheus >= v3.0.0.", + "enum": [ + "PrometheusProto", + "OpenMetricsText0.0.1", + "OpenMetricsText1.0.0", + "PrometheusText0.0.4", + "PrometheusText1.0.0" + ], + "type": "string" + }, "scrapeProtocols": { "description": "`scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the\nprotocols supported by Prometheus in order of preference (from most to least preferred).\n\nIf unset, Prometheus uses its default value.\n\nIt requires Prometheus >= v2.49.0.", "items": { diff --git a/jsonnet/prometheus-operator/probes-crd.json b/jsonnet/prometheus-operator/probes-crd.json index a85f31588..119a7f8d7 100644 --- a/jsonnet/prometheus-operator/probes-crd.json +++ b/jsonnet/prometheus-operator/probes-crd.json @@ -626,6 +626,17 @@ "description": "Whether to scrape a classic histogram that is also exposed as a native histogram.\nIt requires Prometheus >= v2.45.0.", "type": "boolean" }, + "scrapeFallbackProtocol": { + "description": "The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.\n\nIt requires Prometheus >= v3.0.0.", + "enum": [ + "PrometheusProto", + "OpenMetricsText0.0.1", + "OpenMetricsText1.0.0", + "PrometheusText0.0.4", + "PrometheusText1.0.0" + ], + "type": "string" + }, "scrapeProtocols": { "description": "`scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the\nprotocols supported by Prometheus in order of preference (from most to least preferred).\n\nIf unset, Prometheus uses its default value.\n\nIt requires Prometheus >= v2.49.0.", "items": { diff --git a/jsonnet/prometheus-operator/prometheusagents-crd.json b/jsonnet/prometheus-operator/prometheusagents-crd.json index bde1b3b2c..2d4c32409 100644 --- a/jsonnet/prometheus-operator/prometheusagents-crd.json +++ b/jsonnet/prometheus-operator/prometheusagents-crd.json @@ -5826,6 +5826,17 @@ "type": "object", "x-kubernetes-map-type": "atomic" }, + "scrapeFallbackProtocol": { + "description": "The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.\n\nIt requires Prometheus >= v3.0.0.", + "enum": [ + "PrometheusProto", + "OpenMetricsText0.0.1", + "OpenMetricsText1.0.0", + "PrometheusText0.0.4", + "PrometheusText1.0.0" + ], + "type": "string" + }, "scrapeInterval": { "default": "30s", "description": "Interval between consecutive scrapes.\n\nDefault: \"30s\"", diff --git a/jsonnet/prometheus-operator/prometheuses-crd.json b/jsonnet/prometheus-operator/prometheuses-crd.json index 2a75a0b3f..117de9164 100644 --- a/jsonnet/prometheus-operator/prometheuses-crd.json +++ b/jsonnet/prometheus-operator/prometheuses-crd.json @@ -7284,6 +7284,17 @@ "type": "object", "x-kubernetes-map-type": "atomic" }, + "scrapeFallbackProtocol": { + "description": "The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.\n\nIt requires Prometheus >= v3.0.0.", + "enum": [ + "PrometheusProto", + "OpenMetricsText0.0.1", + "OpenMetricsText1.0.0", + "PrometheusText0.0.4", + "PrometheusText1.0.0" + ], + "type": "string" + }, "scrapeInterval": { "default": "30s", "description": "Interval between consecutive scrapes.\n\nDefault: \"30s\"", diff --git a/jsonnet/prometheus-operator/scrapeconfigs-crd.json b/jsonnet/prometheus-operator/scrapeconfigs-crd.json index a0f556e2b..04faae11b 100644 --- a/jsonnet/prometheus-operator/scrapeconfigs-crd.json +++ b/jsonnet/prometheus-operator/scrapeconfigs-crd.json @@ -10675,6 +10675,17 @@ "description": "Whether to scrape a classic histogram that is also exposed as a native histogram.\nIt requires Prometheus >= v2.45.0.", "type": "boolean" }, + "scrapeFallbackProtocol": { + "description": "The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.\n\nIt requires Prometheus >= v3.0.0.", + "enum": [ + "PrometheusProto", + "OpenMetricsText0.0.1", + "OpenMetricsText1.0.0", + "PrometheusText0.0.4", + "PrometheusText1.0.0" + ], + "type": "string" + }, "scrapeInterval": { "description": "ScrapeInterval is the interval between consecutive scrapes.", "pattern": "^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$", diff --git a/jsonnet/prometheus-operator/servicemonitors-crd.json b/jsonnet/prometheus-operator/servicemonitors-crd.json index 3cdd501dd..eca91bbf6 100644 --- a/jsonnet/prometheus-operator/servicemonitors-crd.json +++ b/jsonnet/prometheus-operator/servicemonitors-crd.json @@ -958,6 +958,17 @@ "description": "Whether to scrape a classic histogram that is also exposed as a native histogram.\nIt requires Prometheus >= v2.45.0.", "type": "boolean" }, + "scrapeFallbackProtocol": { + "description": "The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type.\n\nIt requires Prometheus >= v3.0.0.", + "enum": [ + "PrometheusProto", + "OpenMetricsText0.0.1", + "OpenMetricsText1.0.0", + "PrometheusText0.0.4", + "PrometheusText1.0.0" + ], + "type": "string" + }, "scrapeProtocols": { "description": "`scrapeProtocols` defines the protocols to negotiate during a scrape. It tells clients the\nprotocols supported by Prometheus in order of preference (from most to least preferred).\n\nIf unset, Prometheus uses its default value.\n\nIt requires Prometheus >= v2.49.0.", "items": { diff --git a/pkg/apis/monitoring/v1/podmonitor_types.go b/pkg/apis/monitoring/v1/podmonitor_types.go index a6e2c1605..b73593147 100644 --- a/pkg/apis/monitoring/v1/podmonitor_types.go +++ b/pkg/apis/monitoring/v1/podmonitor_types.go @@ -105,6 +105,12 @@ type PodMonitorSpec struct { // +optional ScrapeProtocols []ScrapeProtocol `json:"scrapeProtocols,omitempty"` + // The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + // + // It requires Prometheus >= v3.0.0. + // +optional + ScrapeFallbackProtocol *ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` + // Per-scrape limit on number of labels that will be accepted for a sample. // // It requires Prometheus >= v2.27.0. diff --git a/pkg/apis/monitoring/v1/probe_types.go b/pkg/apis/monitoring/v1/probe_types.go index 16c927ad6..3212cf01f 100644 --- a/pkg/apis/monitoring/v1/probe_types.go +++ b/pkg/apis/monitoring/v1/probe_types.go @@ -100,6 +100,11 @@ type ProbeSpec struct { // +listType=set // +optional ScrapeProtocols []ScrapeProtocol `json:"scrapeProtocols,omitempty"` + // The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + // + // It requires Prometheus >= v3.0.0. + // +optional + ScrapeFallbackProtocol *ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` // Per-scrape limit on number of labels that will be accepted for a sample. // Only valid in Prometheus versions 2.27.0 and newer. // +optional diff --git a/pkg/apis/monitoring/v1/prometheus_types.go b/pkg/apis/monitoring/v1/prometheus_types.go index 29f178c2e..360a84b32 100644 --- a/pkg/apis/monitoring/v1/prometheus_types.go +++ b/pkg/apis/monitoring/v1/prometheus_types.go @@ -300,6 +300,12 @@ type CommonPrometheusFields struct { // +optional ScrapeProtocols []ScrapeProtocol `json:"scrapeProtocols,omitempty"` + // The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + // + // It requires Prometheus >= v3.0.0. + // +optional + ScrapeFallbackProtocol *ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` + // The labels to add to any time series or alerts when communicating with // external systems (federation, remote storage, Alertmanager). // Labels defined by `spec.replicaExternalLabelName` and diff --git a/pkg/apis/monitoring/v1/servicemonitor_types.go b/pkg/apis/monitoring/v1/servicemonitor_types.go index 0b40e4a9e..792160cca 100644 --- a/pkg/apis/monitoring/v1/servicemonitor_types.go +++ b/pkg/apis/monitoring/v1/servicemonitor_types.go @@ -104,6 +104,12 @@ type ServiceMonitorSpec struct { // +optional ScrapeProtocols []ScrapeProtocol `json:"scrapeProtocols,omitempty"` + // The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + // + // It requires Prometheus >= v3.0.0. + // +optional + ScrapeFallbackProtocol *ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` + // `targetLimit` defines a limit on the number of scraped targets that will // be accepted. // diff --git a/pkg/apis/monitoring/v1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1/zz_generated.deepcopy.go index f4f430f81..90fb9cbe1 100644 --- a/pkg/apis/monitoring/v1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1/zz_generated.deepcopy.go @@ -745,6 +745,11 @@ func (in *CommonPrometheusFields) DeepCopyInto(out *CommonPrometheusFields) { *out = make([]ScrapeProtocol, len(*in)) copy(*out, *in) } + if in.ScrapeFallbackProtocol != nil { + in, out := &in.ScrapeFallbackProtocol, &out.ScrapeFallbackProtocol + *out = new(ScrapeProtocol) + **out = **in + } if in.ExternalLabels != nil { in, out := &in.ExternalLabels, &out.ExternalLabels *out = make(map[string]string, len(*in)) @@ -1807,6 +1812,11 @@ func (in *PodMonitorSpec) DeepCopyInto(out *PodMonitorSpec) { *out = make([]ScrapeProtocol, len(*in)) copy(*out, *in) } + if in.ScrapeFallbackProtocol != nil { + in, out := &in.ScrapeFallbackProtocol, &out.ScrapeFallbackProtocol + *out = new(ScrapeProtocol) + **out = **in + } if in.LabelLimit != nil { in, out := &in.LabelLimit, &out.LabelLimit *out = new(uint64) @@ -1949,6 +1959,11 @@ func (in *ProbeSpec) DeepCopyInto(out *ProbeSpec) { *out = make([]ScrapeProtocol, len(*in)) copy(*out, *in) } + if in.ScrapeFallbackProtocol != nil { + in, out := &in.ScrapeFallbackProtocol, &out.ScrapeFallbackProtocol + *out = new(ScrapeProtocol) + **out = **in + } if in.LabelLimit != nil { in, out := &in.LabelLimit, &out.LabelLimit *out = new(uint64) @@ -3064,6 +3079,11 @@ func (in *ServiceMonitorSpec) DeepCopyInto(out *ServiceMonitorSpec) { *out = make([]ScrapeProtocol, len(*in)) copy(*out, *in) } + if in.ScrapeFallbackProtocol != nil { + in, out := &in.ScrapeFallbackProtocol, &out.ScrapeFallbackProtocol + *out = new(ScrapeProtocol) + **out = **in + } if in.TargetLimit != nil { in, out := &in.TargetLimit, &out.TargetLimit *out = new(uint64) diff --git a/pkg/apis/monitoring/v1alpha1/scrapeconfig_types.go b/pkg/apis/monitoring/v1alpha1/scrapeconfig_types.go index 5bb4a6dad..8c7416076 100644 --- a/pkg/apis/monitoring/v1alpha1/scrapeconfig_types.go +++ b/pkg/apis/monitoring/v1alpha1/scrapeconfig_types.go @@ -251,6 +251,11 @@ type ScrapeConfigSpec struct { // +kubebuilder:validation:MinItems:=1 // +optional ScrapeProtocols []v1.ScrapeProtocol `json:"scrapeProtocols,omitempty"` + // The protocol to use if a scrape returns blank, unparseable, or otherwise invalid Content-Type. + // + // It requires Prometheus >= v3.0.0. + // +optional + ScrapeFallbackProtocol *v1.ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` // HonorTimestamps controls whether Prometheus respects the timestamps present in scraped data. // +optional HonorTimestamps *bool `json:"honorTimestamps,omitempty"` diff --git a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go index d4a3c7589..fb335f035 100644 --- a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go @@ -2492,6 +2492,11 @@ func (in *ScrapeConfigSpec) DeepCopyInto(out *ScrapeConfigSpec) { *out = make([]monitoringv1.ScrapeProtocol, len(*in)) copy(*out, *in) } + if in.ScrapeFallbackProtocol != nil { + in, out := &in.ScrapeFallbackProtocol, &out.ScrapeFallbackProtocol + *out = new(monitoringv1.ScrapeProtocol) + **out = **in + } if in.HonorTimestamps != nil { in, out := &in.HonorTimestamps, &out.HonorTimestamps *out = new(bool) diff --git a/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go b/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go index 8fdd50bd6..e9426e529 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go +++ b/pkg/client/applyconfiguration/monitoring/v1/commonprometheusfields.go @@ -49,6 +49,7 @@ type CommonPrometheusFieldsApplyConfiguration struct { ScrapeInterval *monitoringv1.Duration `json:"scrapeInterval,omitempty"` ScrapeTimeout *monitoringv1.Duration `json:"scrapeTimeout,omitempty"` ScrapeProtocols []monitoringv1.ScrapeProtocol `json:"scrapeProtocols,omitempty"` + ScrapeFallbackProtocol *monitoringv1.ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` ExternalLabels map[string]string `json:"externalLabels,omitempty"` EnableRemoteWriteReceiver *bool `json:"enableRemoteWriteReceiver,omitempty"` EnableOTLPReceiver *bool `json:"enableOTLPReceiver,omitempty"` @@ -312,6 +313,14 @@ func (b *CommonPrometheusFieldsApplyConfiguration) WithScrapeProtocols(values .. return b } +// WithScrapeFallbackProtocol sets the ScrapeFallbackProtocol 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 ScrapeFallbackProtocol field is set to the value of the last call. +func (b *CommonPrometheusFieldsApplyConfiguration) WithScrapeFallbackProtocol(value monitoringv1.ScrapeProtocol) *CommonPrometheusFieldsApplyConfiguration { + b.ScrapeFallbackProtocol = &value + return b +} + // WithExternalLabels puts the entries into the ExternalLabels field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, the entries provided by each call will be put on the ExternalLabels field, diff --git a/pkg/client/applyconfiguration/monitoring/v1/podmonitorspec.go b/pkg/client/applyconfiguration/monitoring/v1/podmonitorspec.go index d2e0a5cc6..e34922abf 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/podmonitorspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1/podmonitorspec.go @@ -33,6 +33,7 @@ type PodMonitorSpecApplyConfiguration struct { SampleLimit *uint64 `json:"sampleLimit,omitempty"` TargetLimit *uint64 `json:"targetLimit,omitempty"` ScrapeProtocols []monitoringv1.ScrapeProtocol `json:"scrapeProtocols,omitempty"` + ScrapeFallbackProtocol *monitoringv1.ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` LabelLimit *uint64 `json:"labelLimit,omitempty"` LabelNameLengthLimit *uint64 `json:"labelNameLengthLimit,omitempty"` LabelValueLengthLimit *uint64 `json:"labelValueLengthLimit,omitempty"` @@ -122,6 +123,14 @@ func (b *PodMonitorSpecApplyConfiguration) WithScrapeProtocols(values ...monitor return b } +// WithScrapeFallbackProtocol sets the ScrapeFallbackProtocol 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 ScrapeFallbackProtocol field is set to the value of the last call. +func (b *PodMonitorSpecApplyConfiguration) WithScrapeFallbackProtocol(value monitoringv1.ScrapeProtocol) *PodMonitorSpecApplyConfiguration { + b.ScrapeFallbackProtocol = &value + return b +} + // WithLabelLimit sets the LabelLimit 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 LabelLimit field is set to the value of the last call. diff --git a/pkg/client/applyconfiguration/monitoring/v1/probespec.go b/pkg/client/applyconfiguration/monitoring/v1/probespec.go index cd65bf29b..2367562a4 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/probespec.go +++ b/pkg/client/applyconfiguration/monitoring/v1/probespec.go @@ -40,6 +40,7 @@ type ProbeSpecApplyConfiguration struct { SampleLimit *uint64 `json:"sampleLimit,omitempty"` TargetLimit *uint64 `json:"targetLimit,omitempty"` ScrapeProtocols []monitoringv1.ScrapeProtocol `json:"scrapeProtocols,omitempty"` + ScrapeFallbackProtocol *monitoringv1.ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` LabelLimit *uint64 `json:"labelLimit,omitempty"` LabelNameLengthLimit *uint64 `json:"labelNameLengthLimit,omitempty"` LabelValueLengthLimit *uint64 `json:"labelValueLengthLimit,omitempty"` @@ -181,6 +182,14 @@ func (b *ProbeSpecApplyConfiguration) WithScrapeProtocols(values ...monitoringv1 return b } +// WithScrapeFallbackProtocol sets the ScrapeFallbackProtocol 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 ScrapeFallbackProtocol field is set to the value of the last call. +func (b *ProbeSpecApplyConfiguration) WithScrapeFallbackProtocol(value monitoringv1.ScrapeProtocol) *ProbeSpecApplyConfiguration { + b.ScrapeFallbackProtocol = &value + return b +} + // WithLabelLimit sets the LabelLimit 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 LabelLimit field is set to the value of the last call. diff --git a/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go b/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go index 77708e1ab..aca8ea894 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1/prometheusspec.go @@ -245,6 +245,14 @@ func (b *PrometheusSpecApplyConfiguration) WithScrapeProtocols(values ...monitor return b } +// WithScrapeFallbackProtocol sets the ScrapeFallbackProtocol 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 ScrapeFallbackProtocol field is set to the value of the last call. +func (b *PrometheusSpecApplyConfiguration) WithScrapeFallbackProtocol(value monitoringv1.ScrapeProtocol) *PrometheusSpecApplyConfiguration { + b.ScrapeFallbackProtocol = &value + return b +} + // WithExternalLabels puts the entries into the ExternalLabels field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, the entries provided by each call will be put on the ExternalLabels field, diff --git a/pkg/client/applyconfiguration/monitoring/v1/servicemonitorspec.go b/pkg/client/applyconfiguration/monitoring/v1/servicemonitorspec.go index 9c3cf14d6..d93aecdc1 100644 --- a/pkg/client/applyconfiguration/monitoring/v1/servicemonitorspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1/servicemonitorspec.go @@ -33,6 +33,7 @@ type ServiceMonitorSpecApplyConfiguration struct { NamespaceSelector *NamespaceSelectorApplyConfiguration `json:"namespaceSelector,omitempty"` SampleLimit *uint64 `json:"sampleLimit,omitempty"` ScrapeProtocols []monitoringv1.ScrapeProtocol `json:"scrapeProtocols,omitempty"` + ScrapeFallbackProtocol *monitoringv1.ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` TargetLimit *uint64 `json:"targetLimit,omitempty"` LabelLimit *uint64 `json:"labelLimit,omitempty"` LabelNameLengthLimit *uint64 `json:"labelNameLengthLimit,omitempty"` @@ -125,6 +126,14 @@ func (b *ServiceMonitorSpecApplyConfiguration) WithScrapeProtocols(values ...mon return b } +// WithScrapeFallbackProtocol sets the ScrapeFallbackProtocol 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 ScrapeFallbackProtocol field is set to the value of the last call. +func (b *ServiceMonitorSpecApplyConfiguration) WithScrapeFallbackProtocol(value monitoringv1.ScrapeProtocol) *ServiceMonitorSpecApplyConfiguration { + b.ScrapeFallbackProtocol = &value + return b +} + // WithTargetLimit sets the TargetLimit 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 TargetLimit field is set to the value of the last call. diff --git a/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go b/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go index 3ee632630..c0d7a8835 100644 --- a/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1alpha1/prometheusagentspec.go @@ -233,6 +233,14 @@ func (b *PrometheusAgentSpecApplyConfiguration) WithScrapeProtocols(values ...mo return b } +// WithScrapeFallbackProtocol sets the ScrapeFallbackProtocol 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 ScrapeFallbackProtocol field is set to the value of the last call. +func (b *PrometheusAgentSpecApplyConfiguration) WithScrapeFallbackProtocol(value monitoringv1.ScrapeProtocol) *PrometheusAgentSpecApplyConfiguration { + b.ScrapeFallbackProtocol = &value + return b +} + // WithExternalLabels puts the entries into the ExternalLabels field in the declarative configuration // and returns the receiver, so that objects can be build by chaining "With" function invocations. // If called multiple times, the entries provided by each call will be put on the ExternalLabels field, diff --git a/pkg/client/applyconfiguration/monitoring/v1alpha1/scrapeconfigspec.go b/pkg/client/applyconfiguration/monitoring/v1alpha1/scrapeconfigspec.go index 3f3a9a955..e5f417b53 100644 --- a/pkg/client/applyconfiguration/monitoring/v1alpha1/scrapeconfigspec.go +++ b/pkg/client/applyconfiguration/monitoring/v1alpha1/scrapeconfigspec.go @@ -55,6 +55,7 @@ type ScrapeConfigSpecApplyConfiguration struct { ScrapeInterval *monitoringv1.Duration `json:"scrapeInterval,omitempty"` ScrapeTimeout *monitoringv1.Duration `json:"scrapeTimeout,omitempty"` ScrapeProtocols []monitoringv1.ScrapeProtocol `json:"scrapeProtocols,omitempty"` + ScrapeFallbackProtocol *monitoringv1.ScrapeProtocol `json:"scrapeFallbackProtocol,omitempty"` HonorTimestamps *bool `json:"honorTimestamps,omitempty"` TrackTimestampsStaleness *bool `json:"trackTimestampsStaleness,omitempty"` HonorLabels *bool `json:"honorLabels,omitempty"` @@ -438,6 +439,14 @@ func (b *ScrapeConfigSpecApplyConfiguration) WithScrapeProtocols(values ...monit return b } +// WithScrapeFallbackProtocol sets the ScrapeFallbackProtocol 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 ScrapeFallbackProtocol field is set to the value of the last call. +func (b *ScrapeConfigSpecApplyConfiguration) WithScrapeFallbackProtocol(value monitoringv1.ScrapeProtocol) *ScrapeConfigSpecApplyConfiguration { + b.ScrapeFallbackProtocol = &value + return b +} + // WithHonorTimestamps sets the HonorTimestamps 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 HonorTimestamps field is set to the value of the last call. diff --git a/pkg/prometheus/promcfg.go b/pkg/prometheus/promcfg.go index fb490d780..b6dc71518 100644 --- a/pkg/prometheus/promcfg.go +++ b/pkg/prometheus/promcfg.go @@ -385,6 +385,15 @@ func (cg *ConfigGenerator) addScrapeProtocols(cfg yaml.MapSlice, scrapeProtocols return cg.WithMinimumVersion("2.49.0").AppendMapItem(cfg, "scrape_protocols", sps) } +// addScrapeFallbackProtocol adds the fallback_scrape_protocol field into the configuration. +func (cg *ConfigGenerator) addScrapeFallbackProtocol(cfg yaml.MapSlice, scrapeFallbackProtocol *monitoringv1.ScrapeProtocol) yaml.MapSlice { + if scrapeFallbackProtocol == nil { + return cfg + } + + return cg.WithMinimumVersion("3.0.0-rc.0").AppendMapItem(cfg, "fallback_scrape_protocol", scrapeFallbackProtocol) +} + // AddHonorLabels adds the honor_labels field into scrape configurations. // if OverrideHonorLabels is true then honor_labels is always false. func (cg *ConfigGenerator) AddHonorLabels(cfg yaml.MapSlice, honorLabels bool) yaml.MapSlice { @@ -1372,6 +1381,7 @@ func (cg *ConfigGenerator) generatePodMonitorConfig( cfg = cg.AddLimitsToYAML(cfg, keepDroppedTargetsKey, m.Spec.KeepDroppedTargets, cpf.EnforcedKeepDroppedTargets) cfg = cg.addNativeHistogramConfig(cfg, m.Spec.NativeHistogramConfig) cfg = cg.addScrapeProtocols(cfg, m.Spec.ScrapeProtocols) + cfg = cg.addScrapeFallbackProtocol(cfg, m.Spec.ScrapeFallbackProtocol) if bodySizeLimit := getLowerByteSize(m.Spec.BodySizeLimit, &cpf); !isByteSizeEmpty(bodySizeLimit) { cfg = cg.WithMinimumVersion("2.28.0").AppendMapItem(cfg, "body_size_limit", bodySizeLimit) @@ -1440,6 +1450,7 @@ func (cg *ConfigGenerator) generateProbeConfig( cfg = cg.AddLimitsToYAML(cfg, keepDroppedTargetsKey, m.Spec.KeepDroppedTargets, cpf.EnforcedKeepDroppedTargets) cfg = cg.addNativeHistogramConfig(cfg, m.Spec.NativeHistogramConfig) cfg = cg.addScrapeProtocols(cfg, m.Spec.ScrapeProtocols) + cfg = cg.addScrapeFallbackProtocol(cfg, m.Spec.ScrapeFallbackProtocol) if cpf.EnforcedBodySizeLimit != "" { cfg = cg.WithMinimumVersion("2.28.0").AppendMapItem(cfg, "body_size_limit", cpf.EnforcedBodySizeLimit) @@ -1889,6 +1900,7 @@ func (cg *ConfigGenerator) generateServiceMonitorConfig( cfg = cg.AddLimitsToYAML(cfg, keepDroppedTargetsKey, m.Spec.KeepDroppedTargets, cpf.EnforcedKeepDroppedTargets) cfg = cg.addNativeHistogramConfig(cfg, m.Spec.NativeHistogramConfig) cfg = cg.addScrapeProtocols(cfg, m.Spec.ScrapeProtocols) + cfg = cg.addScrapeFallbackProtocol(cfg, m.Spec.ScrapeFallbackProtocol) if bodySizeLimit := getLowerByteSize(m.Spec.BodySizeLimit, &cpf); !isByteSizeEmpty(bodySizeLimit) { cfg = cg.WithMinimumVersion("2.28.0").AppendMapItem(cfg, "body_size_limit", bodySizeLimit) @@ -2949,6 +2961,7 @@ func (cg *ConfigGenerator) generateScrapeConfig( } cfg = cg.addScrapeProtocols(cfg, sc.Spec.ScrapeProtocols) + cfg = cg.addScrapeFallbackProtocol(cfg, sc.Spec.ScrapeFallbackProtocol) if sc.Spec.Scheme != nil { cfg = append(cfg, yaml.MapItem{Key: "scheme", Value: strings.ToLower(*sc.Spec.Scheme)}) @@ -4674,6 +4687,7 @@ func (cg *ConfigGenerator) buildGlobalConfig() yaml.MapSlice { cfg := yaml.MapSlice{} cfg = cg.appendScrapeIntervals(cfg) cfg = cg.addScrapeProtocols(cfg, cg.prom.GetCommonPrometheusFields().ScrapeProtocols) + cfg = cg.addScrapeFallbackProtocol(cfg, cg.prom.GetCommonPrometheusFields().ScrapeFallbackProtocol) cfg = cg.appendExternalLabels(cfg) cfg = cg.appendScrapeLimits(cfg) if cpf.NameValidationScheme != nil { diff --git a/pkg/prometheus/promcfg_test.go b/pkg/prometheus/promcfg_test.go index 0a1663a8c..cf2870227 100644 --- a/pkg/prometheus/promcfg_test.go +++ b/pkg/prometheus/promcfg_test.go @@ -125,6 +125,7 @@ func TestGlobalSettings(t *testing.T) { ScrapeInterval monitoringv1.Duration ScrapeTimeout monitoringv1.Duration ScrapeProtocols []monitoringv1.ScrapeProtocol + ScrapeFallbackProtocol *monitoringv1.ScrapeProtocol ExternalLabels map[string]string PrometheusExternalLabelName *string ReplicaExternalLabelName *string @@ -264,6 +265,22 @@ func TestGlobalSettings(t *testing.T) { }, Golden: "valid_global_config_with_unsupported_scrape_protocols.golden", }, + { + Scenario: "valid global config with scrape fallback protocol", + Version: "v3.0.0-rc.0", + ScrapeInterval: "30s", + EvaluationInterval: "30s", + ScrapeFallbackProtocol: ptr.To(monitoringv1.PrometheusText1_0_0), + Golden: "valid_global_config_with_scrape_fallback_protocol.golden", + }, + { + Scenario: "valid global config scrape protocols with unsupported version", + Version: "v2.55.0", + ScrapeInterval: "30s", + EvaluationInterval: "30s", + ScrapeFallbackProtocol: ptr.To(monitoringv1.PrometheusProto), + Golden: "valid_global_config_with_unsupported_scrape_fallback_protocols.golden", + }, { Scenario: "valid global config without rule query offset if prometheus version less required", Version: "v2.52.0", @@ -292,6 +309,7 @@ func TestGlobalSettings(t *testing.T) { ScrapeInterval: tc.ScrapeInterval, ScrapeTimeout: tc.ScrapeTimeout, ScrapeProtocols: tc.ScrapeProtocols, + ScrapeFallbackProtocol: tc.ScrapeFallbackProtocol, ExternalLabels: tc.ExternalLabels, PrometheusExternalLabelName: tc.PrometheusExternalLabelName, ReplicaExternalLabelName: tc.ReplicaExternalLabelName, @@ -2157,6 +2175,67 @@ func TestSettingScrapeProtocolsInServiceMonitor(t *testing.T) { } } +func TestSettingScrapeFallbackProtocolInServiceMonitor(t *testing.T) { + for _, tc := range []struct { + name string + version string + scrapeFallbackProtocol *monitoringv1.ScrapeProtocol + golden string + }{ + { + name: "setting ScrapeFallbackProtocol in ServiceMonitor with prometheus old version", + version: "v2.55.0", + scrapeFallbackProtocol: ptr.To(monitoringv1.OpenMetricsText1_0_0), + golden: "SettingScrapeFallbackProtocolInServiceMonitor_OldVersion.golden", + }, + { + name: "setting ScrapeFallbackProtocol in ServiceMonitor with prometheus new version", + version: "v3.0.0", + scrapeFallbackProtocol: ptr.To(monitoringv1.OpenMetricsText0_0_1), + golden: "SettingScrapeFallbackProtocolInServiceMonitor_NewVersion.golden", + }, + } { + t.Run(tc.name, func(t *testing.T) { + p := defaultPrometheus() + p.Spec.CommonPrometheusFields.Version = tc.version + + cg := mustNewConfigGenerator(t, p) + cfg, err := cg.GenerateServerConfiguration( + p, + map[string]*monitoringv1.ServiceMonitor{ + "testservicemonitor1": { + ObjectMeta: metav1.ObjectMeta{ + Name: "testservicemonitor1", + Namespace: "default", + }, + Spec: monitoringv1.ServiceMonitorSpec{ + TargetLabels: []string{"example", "env"}, + ScrapeFallbackProtocol: tc.scrapeFallbackProtocol, + Endpoints: []monitoringv1.Endpoint{ + { + HonorTimestamps: ptr.To(false), + Port: "web", + Interval: "30s", + }, + }, + }, + }, + }, + nil, + nil, + nil, + &assets.StoreBuilder{}, + nil, + nil, + nil, + nil, + ) + require.NoError(t, err) + golden.Assert(t, string(cfg), tc.golden) + }) + } +} + func TestSettingScrapeProtocolsInPodMonitor(t *testing.T) { for _, tc := range []struct { name string @@ -2224,6 +2303,67 @@ func TestSettingScrapeProtocolsInPodMonitor(t *testing.T) { } } +func TestSettingScrapeFallbackProtocolInPodMonitor(t *testing.T) { + for _, tc := range []struct { + name string + version string + scrapeFallbackProtocol *monitoringv1.ScrapeProtocol + golden string + }{ + { + name: "setting ScrapeFallbackProtocol in PodMonitor with prometheus old version", + version: "v2.55.0", + scrapeFallbackProtocol: ptr.To(monitoringv1.OpenMetricsText0_0_1), + golden: "SettingScrapeFallbackProtocolInPodMonitor_OldVersion.golden", + }, + { + name: "setting ScrapeFallbackProtocol in PodMonitor with prometheus new version", + version: "v3.0.0", + scrapeFallbackProtocol: ptr.To(monitoringv1.OpenMetricsText1_0_0), + golden: "SettingScrapeFallbackProtocolInPodMonitor_NewVersion.golden", + }, + } { + t.Run(tc.name, func(t *testing.T) { + p := defaultPrometheus() + p.Spec.CommonPrometheusFields.Version = tc.version + + cg := mustNewConfigGenerator(t, p) + cfg, err := cg.GenerateServerConfiguration( + p, + nil, + map[string]*monitoringv1.PodMonitor{ + "testpodmonitor1": { + ObjectMeta: metav1.ObjectMeta{ + Name: "testpodmonitor1", + Namespace: "default", + }, + Spec: monitoringv1.PodMonitorSpec{ + PodTargetLabels: []string{"example", "env"}, + ScrapeFallbackProtocol: tc.scrapeFallbackProtocol, + PodMetricsEndpoints: []monitoringv1.PodMetricsEndpoint{ + { + TrackTimestampsStaleness: ptr.To(false), + Port: "web", + Interval: "30s", + }, + }, + }, + }, + }, + nil, + nil, + &assets.StoreBuilder{}, + nil, + nil, + nil, + nil, + ) + require.NoError(t, err) + golden.Assert(t, string(cfg), tc.golden) + }) + } +} + func TestHonorTimestampsOverriding(t *testing.T) { p := defaultPrometheus() p.Spec.CommonPrometheusFields.OverrideHonorTimestamps = true @@ -5960,6 +6100,22 @@ func TestScrapeConfigSpecConfig(t *testing.T) { }, golden: "ScrapeConfigSpecConfig_ScrapeProtocols.golden", }, + { + name: "fallback_scrape_protocol", + version: "v3.0.0", + scSpec: monitoringv1alpha1.ScrapeConfigSpec{ + ScrapeFallbackProtocol: ptr.To(monitoringv1.OpenMetricsText1_0_0), + }, + golden: "ScrapeConfigSpecConfig_ScrapeFallbackProtocol.golden", + }, + { + name: "fallback_scrape_protocol_with_unsupported_version", + version: "v2.55.0", + scSpec: monitoringv1alpha1.ScrapeConfigSpec{ + ScrapeFallbackProtocol: ptr.To(monitoringv1.OpenMetricsText1_0_0), + }, + golden: "ScrapeConfigSpecConfig_ScrapeFallbackProtocol_OldVersion.golden", + }, { name: "non_empty_metric_relabel_config", scSpec: monitoringv1alpha1.ScrapeConfigSpec{ diff --git a/pkg/prometheus/testdata/ScrapeConfigSpecConfig_ScrapeFallbackProtocol.golden b/pkg/prometheus/testdata/ScrapeConfigSpecConfig_ScrapeFallbackProtocol.golden new file mode 100644 index 000000000..5c717b792 --- /dev/null +++ b/pkg/prometheus/testdata/ScrapeConfigSpecConfig_ScrapeFallbackProtocol.golden @@ -0,0 +1,13 @@ +global: + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: +- job_name: scrapeConfig/default/testscrapeconfig1 + fallback_scrape_protocol: OpenMetricsText1.0.0 + relabel_configs: + - source_labels: + - job + target_label: __tmp_prometheus_job_name diff --git a/pkg/prometheus/testdata/ScrapeConfigSpecConfig_ScrapeFallbackProtocol_OldVersion.golden b/pkg/prometheus/testdata/ScrapeConfigSpecConfig_ScrapeFallbackProtocol_OldVersion.golden new file mode 100644 index 000000000..26f7d0393 --- /dev/null +++ b/pkg/prometheus/testdata/ScrapeConfigSpecConfig_ScrapeFallbackProtocol_OldVersion.golden @@ -0,0 +1,12 @@ +global: + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: +- job_name: scrapeConfig/default/testscrapeconfig1 + relabel_configs: + - source_labels: + - job + target_label: __tmp_prometheus_job_name diff --git a/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInPodMonitor_NewVersion.golden b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInPodMonitor_NewVersion.golden new file mode 100644 index 000000000..e7acce3bb --- /dev/null +++ b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInPodMonitor_NewVersion.golden @@ -0,0 +1,61 @@ +global: + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: +- job_name: podMonitor/default/testpodmonitor1/0 + honor_labels: false + track_timestamps_staleness: false + kubernetes_sd_configs: + - role: pod + namespaces: + names: + - default + scrape_interval: 30s + relabel_configs: + - source_labels: + - job + target_label: __tmp_prometheus_job_name + - action: drop + source_labels: + - __meta_kubernetes_pod_phase + regex: (Failed|Succeeded) + - action: keep + source_labels: + - __meta_kubernetes_pod_container_port_name + regex: web + - source_labels: + - __meta_kubernetes_namespace + target_label: namespace + - source_labels: + - __meta_kubernetes_pod_container_name + target_label: container + - source_labels: + - __meta_kubernetes_pod_name + target_label: pod + - source_labels: + - __meta_kubernetes_pod_label_example + target_label: example + regex: (.+) + replacement: ${1} + - source_labels: + - __meta_kubernetes_pod_label_env + target_label: env + regex: (.+) + replacement: ${1} + - target_label: job + replacement: default/testpodmonitor1 + - target_label: endpoint + replacement: web + - source_labels: + - __address__ + target_label: __tmp_hash + modulus: 1 + action: hashmod + - source_labels: + - __tmp_hash + regex: $(SHARD) + action: keep + fallback_scrape_protocol: OpenMetricsText1.0.0 diff --git a/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInPodMonitor_OldVersion.golden b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInPodMonitor_OldVersion.golden new file mode 100644 index 000000000..94d3561b2 --- /dev/null +++ b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInPodMonitor_OldVersion.golden @@ -0,0 +1,60 @@ +global: + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: +- job_name: podMonitor/default/testpodmonitor1/0 + honor_labels: false + track_timestamps_staleness: false + kubernetes_sd_configs: + - role: pod + namespaces: + names: + - default + scrape_interval: 30s + relabel_configs: + - source_labels: + - job + target_label: __tmp_prometheus_job_name + - action: drop + source_labels: + - __meta_kubernetes_pod_phase + regex: (Failed|Succeeded) + - action: keep + source_labels: + - __meta_kubernetes_pod_container_port_name + regex: web + - source_labels: + - __meta_kubernetes_namespace + target_label: namespace + - source_labels: + - __meta_kubernetes_pod_container_name + target_label: container + - source_labels: + - __meta_kubernetes_pod_name + target_label: pod + - source_labels: + - __meta_kubernetes_pod_label_example + target_label: example + regex: (.+) + replacement: ${1} + - source_labels: + - __meta_kubernetes_pod_label_env + target_label: env + regex: (.+) + replacement: ${1} + - target_label: job + replacement: default/testpodmonitor1 + - target_label: endpoint + replacement: web + - source_labels: + - __address__ + target_label: __tmp_hash + modulus: 1 + action: hashmod + - source_labels: + - __tmp_hash + regex: $(SHARD) + action: keep diff --git a/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInServiceMonitor_NewVersion.golden b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInServiceMonitor_NewVersion.golden new file mode 100644 index 000000000..44d94d3cf --- /dev/null +++ b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInServiceMonitor_NewVersion.golden @@ -0,0 +1,80 @@ +global: + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: +- job_name: serviceMonitor/default/testservicemonitor1/0 + honor_labels: false + honor_timestamps: false + kubernetes_sd_configs: + - role: endpoints + namespaces: + names: + - default + scrape_interval: 30s + relabel_configs: + - source_labels: + - job + target_label: __tmp_prometheus_job_name + - action: keep + source_labels: + - __meta_kubernetes_endpoint_port_name + regex: web + - source_labels: + - __meta_kubernetes_endpoint_address_target_kind + - __meta_kubernetes_endpoint_address_target_name + separator: ; + regex: Node;(.*) + replacement: ${1} + target_label: node + - source_labels: + - __meta_kubernetes_endpoint_address_target_kind + - __meta_kubernetes_endpoint_address_target_name + separator: ; + regex: Pod;(.*) + replacement: ${1} + target_label: pod + - source_labels: + - __meta_kubernetes_namespace + target_label: namespace + - source_labels: + - __meta_kubernetes_service_name + target_label: service + - source_labels: + - __meta_kubernetes_pod_name + target_label: pod + - source_labels: + - __meta_kubernetes_pod_container_name + target_label: container + - action: drop + source_labels: + - __meta_kubernetes_pod_phase + regex: (Failed|Succeeded) + - source_labels: + - __meta_kubernetes_service_label_example + target_label: example + regex: (.+) + replacement: ${1} + - source_labels: + - __meta_kubernetes_service_label_env + target_label: env + regex: (.+) + replacement: ${1} + - source_labels: + - __meta_kubernetes_service_name + target_label: job + replacement: ${1} + - target_label: endpoint + replacement: web + - source_labels: + - __address__ + target_label: __tmp_hash + modulus: 1 + action: hashmod + - source_labels: + - __tmp_hash + regex: $(SHARD) + action: keep + fallback_scrape_protocol: OpenMetricsText0.0.1 diff --git a/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInServiceMonitor_OldVersion.golden b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInServiceMonitor_OldVersion.golden new file mode 100644 index 000000000..1f47cc680 --- /dev/null +++ b/pkg/prometheus/testdata/SettingScrapeFallbackProtocolInServiceMonitor_OldVersion.golden @@ -0,0 +1,79 @@ +global: + scrape_interval: 30s + external_labels: + prometheus: default/test + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: +- job_name: serviceMonitor/default/testservicemonitor1/0 + honor_labels: false + honor_timestamps: false + kubernetes_sd_configs: + - role: endpoints + namespaces: + names: + - default + scrape_interval: 30s + relabel_configs: + - source_labels: + - job + target_label: __tmp_prometheus_job_name + - action: keep + source_labels: + - __meta_kubernetes_endpoint_port_name + regex: web + - source_labels: + - __meta_kubernetes_endpoint_address_target_kind + - __meta_kubernetes_endpoint_address_target_name + separator: ; + regex: Node;(.*) + replacement: ${1} + target_label: node + - source_labels: + - __meta_kubernetes_endpoint_address_target_kind + - __meta_kubernetes_endpoint_address_target_name + separator: ; + regex: Pod;(.*) + replacement: ${1} + target_label: pod + - source_labels: + - __meta_kubernetes_namespace + target_label: namespace + - source_labels: + - __meta_kubernetes_service_name + target_label: service + - source_labels: + - __meta_kubernetes_pod_name + target_label: pod + - source_labels: + - __meta_kubernetes_pod_container_name + target_label: container + - action: drop + source_labels: + - __meta_kubernetes_pod_phase + regex: (Failed|Succeeded) + - source_labels: + - __meta_kubernetes_service_label_example + target_label: example + regex: (.+) + replacement: ${1} + - source_labels: + - __meta_kubernetes_service_label_env + target_label: env + regex: (.+) + replacement: ${1} + - source_labels: + - __meta_kubernetes_service_name + target_label: job + replacement: ${1} + - target_label: endpoint + replacement: web + - source_labels: + - __address__ + target_label: __tmp_hash + modulus: 1 + action: hashmod + - source_labels: + - __tmp_hash + regex: $(SHARD) + action: keep diff --git a/pkg/prometheus/testdata/valid_global_config_with_scrape_fallback_protocol.golden b/pkg/prometheus/testdata/valid_global_config_with_scrape_fallback_protocol.golden new file mode 100644 index 000000000..9a6959035 --- /dev/null +++ b/pkg/prometheus/testdata/valid_global_config_with_scrape_fallback_protocol.golden @@ -0,0 +1,8 @@ +global: + scrape_interval: 30s + fallback_scrape_protocol: PrometheusText1.0.0 + external_labels: + prometheus: test/example + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: [] diff --git a/pkg/prometheus/testdata/valid_global_config_with_unsupported_scrape_fallback_protocols.golden b/pkg/prometheus/testdata/valid_global_config_with_unsupported_scrape_fallback_protocols.golden new file mode 100644 index 000000000..14f383870 --- /dev/null +++ b/pkg/prometheus/testdata/valid_global_config_with_unsupported_scrape_fallback_protocols.golden @@ -0,0 +1,7 @@ +global: + scrape_interval: 30s + external_labels: + prometheus: test/example + prometheus_replica: $(POD_NAME) + evaluation_interval: 30s +scrape_configs: [] diff --git a/test/e2e/scrapeconfig_test.go b/test/e2e/scrapeconfig_test.go index b3240ad69..b00aed3c2 100644 --- a/test/e2e/scrapeconfig_test.go +++ b/test/e2e/scrapeconfig_test.go @@ -1778,6 +1778,27 @@ var ScrapeConfigCRDTestCases = []scrapeCRDTestCase{ }, expectedError: false, }, + { + name: "ScrapeFallbackProtocol: Valid Value", + scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{ + ScrapeFallbackProtocol: ptr.To(monitoringv1.OpenMetricsText0_0_1), + }, + expectedError: false, + }, + { + name: "ScrapeFallbackProtocol: Invalid Protocol", + scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{ + ScrapeFallbackProtocol: ptr.To(monitoringv1.ScrapeProtocol("InvalidProtocol")), + }, + expectedError: true, + }, + { + name: "ScrapeFallbackProtocol: Setting nil", + scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{ + ScrapeFallbackProtocol: nil, + }, + expectedError: false, + }, } var staticConfigTestCases = []scrapeCRDTestCase{