1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 03:38:43 +00:00

Merge pull request from nicolastakashi/main

[FEATURE] Adding Prometheus Tracing Support
This commit is contained in:
Arthur Silva Sens 2023-05-31 15:57:01 -03:00 committed by GitHub
commit f76fe5ac89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1332 additions and 6 deletions
Documentation
bundle.yaml
example
jsonnet/prometheus-operator
pkg

View file

@ -2573,6 +2573,20 @@ TSDBSpec
(TSDB).</p>
</td>
</tr>
<tr>
<td>
<code>tracingConfig</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.PrometheusTracingConfig">
PrometheusTracingConfig
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>TracingConfig configures tracing in Prometheus. This is an experimental feature, it may change in any upcoming release in a breaking way.</p>
</td>
</tr>
</table>
</td>
</tr>
@ -6296,7 +6310,7 @@ The possible status values for this condition type are:
<h3 id="monitoring.coreos.com/v1.Duration">Duration
(<code>string</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#monitoring.coreos.com/v1.AlertmanagerEndpoints">AlertmanagerEndpoints</a>, <a href="#monitoring.coreos.com/v1.AlertmanagerGlobalConfig">AlertmanagerGlobalConfig</a>, <a href="#monitoring.coreos.com/v1.CommonPrometheusFields">CommonPrometheusFields</a>, <a href="#monitoring.coreos.com/v1.Endpoint">Endpoint</a>, <a href="#monitoring.coreos.com/v1.MetadataConfig">MetadataConfig</a>, <a href="#monitoring.coreos.com/v1.PodMetricsEndpoint">PodMetricsEndpoint</a>, <a href="#monitoring.coreos.com/v1.ProbeSpec">ProbeSpec</a>, <a href="#monitoring.coreos.com/v1.PrometheusSpec">PrometheusSpec</a>, <a href="#monitoring.coreos.com/v1.QuerySpec">QuerySpec</a>, <a href="#monitoring.coreos.com/v1.RemoteReadSpec">RemoteReadSpec</a>, <a href="#monitoring.coreos.com/v1.RemoteWriteSpec">RemoteWriteSpec</a>, <a href="#monitoring.coreos.com/v1.Rule">Rule</a>, <a href="#monitoring.coreos.com/v1.RuleGroup">RuleGroup</a>, <a href="#monitoring.coreos.com/v1.TSDBSpec">TSDBSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosRulerSpec">ThanosRulerSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosSpec">ThanosSpec</a>, <a href="#monitoring.coreos.com/v1alpha1.FileSDConfig">FileSDConfig</a>, <a href="#monitoring.coreos.com/v1alpha1.HTTPSDConfig">HTTPSDConfig</a>)
(<em>Appears on:</em><a href="#monitoring.coreos.com/v1.AlertmanagerEndpoints">AlertmanagerEndpoints</a>, <a href="#monitoring.coreos.com/v1.AlertmanagerGlobalConfig">AlertmanagerGlobalConfig</a>, <a href="#monitoring.coreos.com/v1.CommonPrometheusFields">CommonPrometheusFields</a>, <a href="#monitoring.coreos.com/v1.Endpoint">Endpoint</a>, <a href="#monitoring.coreos.com/v1.MetadataConfig">MetadataConfig</a>, <a href="#monitoring.coreos.com/v1.PodMetricsEndpoint">PodMetricsEndpoint</a>, <a href="#monitoring.coreos.com/v1.ProbeSpec">ProbeSpec</a>, <a href="#monitoring.coreos.com/v1.PrometheusSpec">PrometheusSpec</a>, <a href="#monitoring.coreos.com/v1.PrometheusTracingConfig">PrometheusTracingConfig</a>, <a href="#monitoring.coreos.com/v1.QuerySpec">QuerySpec</a>, <a href="#monitoring.coreos.com/v1.RemoteReadSpec">RemoteReadSpec</a>, <a href="#monitoring.coreos.com/v1.RemoteWriteSpec">RemoteWriteSpec</a>, <a href="#monitoring.coreos.com/v1.Rule">Rule</a>, <a href="#monitoring.coreos.com/v1.RuleGroup">RuleGroup</a>, <a href="#monitoring.coreos.com/v1.TSDBSpec">TSDBSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosRulerSpec">ThanosRulerSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosSpec">ThanosSpec</a>, <a href="#monitoring.coreos.com/v1alpha1.FileSDConfig">FileSDConfig</a>, <a href="#monitoring.coreos.com/v1alpha1.HTTPSDConfig">HTTPSDConfig</a>)
</p>
<div>
<p>Duration is a valid time duration that can be parsed by Prometheus model.ParseDuration() function.
@ -9782,6 +9796,20 @@ TSDBSpec
(TSDB).</p>
</td>
</tr>
<tr>
<td>
<code>tracingConfig</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.PrometheusTracingConfig">
PrometheusTracingConfig
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>TracingConfig configures tracing in Prometheus. This is an experimental feature, it may change in any upcoming release in a breaking way.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="monitoring.coreos.com/v1.PrometheusStatus">PrometheusStatus
@ -9891,6 +9919,122 @@ int32
</tr>
</tbody>
</table>
<h3 id="monitoring.coreos.com/v1.PrometheusTracingConfig">PrometheusTracingConfig
</h3>
<p>
(<em>Appears on:</em><a href="#monitoring.coreos.com/v1.PrometheusSpec">PrometheusSpec</a>)
</p>
<div>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>clientType</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Client used to export the traces. Options are &ldquo;http&rdquo; or &ldquo;grpc&rdquo;.</p>
</td>
</tr>
<tr>
<td>
<code>endpoint</code><br/>
<em>
string
</em>
</td>
<td>
<p>Endpoint to send the traces to. Should be provided in format <host>:<port>.</p>
</td>
</tr>
<tr>
<td>
<code>samplingFraction</code><br/>
<em>
k8s.io/apimachinery/pkg/api/resource.Quantity
</em>
</td>
<td>
<em>(Optional)</em>
<p>Sets the probability a given trace will be sampled. Must be a float from 0 through 1.</p>
</td>
</tr>
<tr>
<td>
<code>insecure</code><br/>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>If disabled, the client will use a secure connection.</p>
</td>
</tr>
<tr>
<td>
<code>headers</code><br/>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Key-value pairs to be used as headers associated with gRPC or HTTP requests.</p>
</td>
</tr>
<tr>
<td>
<code>compression</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Compression key for supported compression types. Supported compression: gzip</p>
</td>
</tr>
<tr>
<td>
<code>timeout</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.Duration">
Duration
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Maximum time the exporter will wait for each batch export. Default &lsquo;10s&rsquo;</p>
</td>
</tr>
<tr>
<td>
<code>tlsConfig</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.TLSConfig">
TLSConfig
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>TLS Config to use when sending traces.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="monitoring.coreos.com/v1.PrometheusWebSpec">PrometheusWebSpec
</h3>
<p>
@ -11512,7 +11656,7 @@ EmbeddedPersistentVolumeClaim
<h3 id="monitoring.coreos.com/v1.TLSConfig">TLSConfig
</h3>
<p>
(<em>Appears on:</em><a href="#monitoring.coreos.com/v1.APIServerConfig">APIServerConfig</a>, <a href="#monitoring.coreos.com/v1.AlertmanagerEndpoints">AlertmanagerEndpoints</a>, <a href="#monitoring.coreos.com/v1.Endpoint">Endpoint</a>, <a href="#monitoring.coreos.com/v1.RemoteReadSpec">RemoteReadSpec</a>, <a href="#monitoring.coreos.com/v1.RemoteWriteSpec">RemoteWriteSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosRulerSpec">ThanosRulerSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosSpec">ThanosSpec</a>)
(<em>Appears on:</em><a href="#monitoring.coreos.com/v1.APIServerConfig">APIServerConfig</a>, <a href="#monitoring.coreos.com/v1.AlertmanagerEndpoints">AlertmanagerEndpoints</a>, <a href="#monitoring.coreos.com/v1.Endpoint">Endpoint</a>, <a href="#monitoring.coreos.com/v1.PrometheusTracingConfig">PrometheusTracingConfig</a>, <a href="#monitoring.coreos.com/v1.RemoteReadSpec">RemoteReadSpec</a>, <a href="#monitoring.coreos.com/v1.RemoteWriteSpec">RemoteWriteSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosRulerSpec">ThanosRulerSpec</a>, <a href="#monitoring.coreos.com/v1.ThanosSpec">ThanosSpec</a>)
</p>
<div>
<p>TLSConfig extends the safe TLS configuration with file parameters.</p>

View file

@ -28586,6 +28586,184 @@ spec:
- whenUnsatisfiable
type: object
type: array
tracingConfig:
description: TracingConfig configures tracing in Prometheus. This
is an experimental feature, it may change in any upcoming release
in a breaking way.
properties:
clientType:
description: Client used to export the traces. Options are "http"
or "grpc".
enum:
- http
- grpc
type: string
compression:
description: 'Compression key for supported compression types.
Supported compression: gzip'
enum:
- gzip
type: string
endpoint:
description: Endpoint to send the traces to. Should be provided
in format <host>:<port>.
type: string
headers:
additionalProperties:
type: string
description: Key-value pairs to be used as headers associated
with gRPC or HTTP requests.
type: object
insecure:
description: If disabled, the client will use a secure connection.
type: boolean
samplingFraction:
anyOf:
- type: integer
- type: string
description: Sets the probability a given trace will be sampled.
Must be a float from 0 through 1.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
timeout:
description: Maximum time the exporter will wait for each batch
export. Default '10s'
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
tlsConfig:
description: TLS Config to use when sending traces.
properties:
ca:
description: Certificate authority used when verifying server
certificates.
properties:
configMap:
description: ConfigMap containing data to use for the
targets.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
secret:
description: Secret containing data to use for the targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
caFile:
description: Path to the CA cert in the Prometheus container
to use for the targets.
type: string
cert:
description: Client certificate to present when doing client-authentication.
properties:
configMap:
description: ConfigMap containing data to use for the
targets.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
secret:
description: Secret containing data to use for the targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
certFile:
description: Path to the client cert file in the Prometheus
container for the targets.
type: string
insecureSkipVerify:
description: Disable target certificate validation.
type: boolean
keyFile:
description: Path to the client key file in the Prometheus
container for the targets.
type: string
keySecret:
description: Secret containing the client key file for the
targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
serverName:
description: Used to verify the hostname for the targets.
type: string
type: object
required:
- endpoint
type: object
tsdb:
description: Defines the runtime reloadable configuration of the timeseries
database (TSDB).

View file

@ -7413,6 +7413,184 @@ spec:
- whenUnsatisfiable
type: object
type: array
tracingConfig:
description: TracingConfig configures tracing in Prometheus. This
is an experimental feature, it may change in any upcoming release
in a breaking way.
properties:
clientType:
description: Client used to export the traces. Options are "http"
or "grpc".
enum:
- http
- grpc
type: string
compression:
description: 'Compression key for supported compression types.
Supported compression: gzip'
enum:
- gzip
type: string
endpoint:
description: Endpoint to send the traces to. Should be provided
in format <host>:<port>.
type: string
headers:
additionalProperties:
type: string
description: Key-value pairs to be used as headers associated
with gRPC or HTTP requests.
type: object
insecure:
description: If disabled, the client will use a secure connection.
type: boolean
samplingFraction:
anyOf:
- type: integer
- type: string
description: Sets the probability a given trace will be sampled.
Must be a float from 0 through 1.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
timeout:
description: Maximum time the exporter will wait for each batch
export. Default '10s'
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
tlsConfig:
description: TLS Config to use when sending traces.
properties:
ca:
description: Certificate authority used when verifying server
certificates.
properties:
configMap:
description: ConfigMap containing data to use for the
targets.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
secret:
description: Secret containing data to use for the targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
caFile:
description: Path to the CA cert in the Prometheus container
to use for the targets.
type: string
cert:
description: Client certificate to present when doing client-authentication.
properties:
configMap:
description: ConfigMap containing data to use for the
targets.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
secret:
description: Secret containing data to use for the targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
certFile:
description: Path to the client cert file in the Prometheus
container for the targets.
type: string
insecureSkipVerify:
description: Disable target certificate validation.
type: boolean
keyFile:
description: Path to the client key file in the Prometheus
container for the targets.
type: string
keySecret:
description: Secret containing the client key file for the
targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
serverName:
description: Used to verify the hostname for the targets.
type: string
type: object
required:
- endpoint
type: object
tsdb:
description: Defines the runtime reloadable configuration of the timeseries
database (TSDB).

View file

@ -7413,6 +7413,184 @@ spec:
- whenUnsatisfiable
type: object
type: array
tracingConfig:
description: TracingConfig configures tracing in Prometheus. This
is an experimental feature, it may change in any upcoming release
in a breaking way.
properties:
clientType:
description: Client used to export the traces. Options are "http"
or "grpc".
enum:
- http
- grpc
type: string
compression:
description: 'Compression key for supported compression types.
Supported compression: gzip'
enum:
- gzip
type: string
endpoint:
description: Endpoint to send the traces to. Should be provided
in format <host>:<port>.
type: string
headers:
additionalProperties:
type: string
description: Key-value pairs to be used as headers associated
with gRPC or HTTP requests.
type: object
insecure:
description: If disabled, the client will use a secure connection.
type: boolean
samplingFraction:
anyOf:
- type: integer
- type: string
description: Sets the probability a given trace will be sampled.
Must be a float from 0 through 1.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
timeout:
description: Maximum time the exporter will wait for each batch
export. Default '10s'
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
tlsConfig:
description: TLS Config to use when sending traces.
properties:
ca:
description: Certificate authority used when verifying server
certificates.
properties:
configMap:
description: ConfigMap containing data to use for the
targets.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
secret:
description: Secret containing data to use for the targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
caFile:
description: Path to the CA cert in the Prometheus container
to use for the targets.
type: string
cert:
description: Client certificate to present when doing client-authentication.
properties:
configMap:
description: ConfigMap containing data to use for the
targets.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
secret:
description: Secret containing data to use for the targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
certFile:
description: Path to the client cert file in the Prometheus
container for the targets.
type: string
insecureSkipVerify:
description: Disable target certificate validation.
type: boolean
keyFile:
description: Path to the client key file in the Prometheus
container for the targets.
type: string
keySecret:
description: Secret containing the client key file for the
targets.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
serverName:
description: Used to verify the hostname for the targets.
type: string
type: object
required:
- endpoint
type: object
tsdb:
description: Defines the runtime reloadable configuration of the timeseries
database (TSDB).

View file

@ -6812,6 +6812,211 @@
},
"type": "array"
},
"tracingConfig": {
"description": "TracingConfig configures tracing in Prometheus. This is an experimental feature, it may change in any upcoming release in a breaking way.",
"properties": {
"clientType": {
"description": "Client used to export the traces. Options are \"http\" or \"grpc\".",
"enum": [
"http",
"grpc"
],
"type": "string"
},
"compression": {
"description": "Compression key for supported compression types. Supported compression: gzip",
"enum": [
"gzip"
],
"type": "string"
},
"endpoint": {
"description": "Endpoint to send the traces to. Should be provided in format <host>:<port>.",
"type": "string"
},
"headers": {
"additionalProperties": {
"type": "string"
},
"description": "Key-value pairs to be used as headers associated with gRPC or HTTP requests.",
"type": "object"
},
"insecure": {
"description": "If disabled, the client will use a secure connection.",
"type": "boolean"
},
"samplingFraction": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"description": "Sets the probability a given trace will be sampled. Must be a float from 0 through 1.",
"pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
"x-kubernetes-int-or-string": true
},
"timeout": {
"description": "Maximum time the exporter will wait for each batch export. Default '10s'",
"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"
},
"tlsConfig": {
"description": "TLS Config to use when sending traces.",
"properties": {
"ca": {
"description": "Certificate authority used when verifying server certificates.",
"properties": {
"configMap": {
"description": "ConfigMap containing data to use for the targets.",
"properties": {
"key": {
"description": "The key to select.",
"type": "string"
},
"name": {
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?",
"type": "string"
},
"optional": {
"description": "Specify whether the ConfigMap or its key must be defined",
"type": "boolean"
}
},
"required": [
"key"
],
"type": "object",
"x-kubernetes-map-type": "atomic"
},
"secret": {
"description": "Secret containing data to use for the targets.",
"properties": {
"key": {
"description": "The key of the secret to select from. Must be a valid secret key.",
"type": "string"
},
"name": {
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?",
"type": "string"
},
"optional": {
"description": "Specify whether the Secret or its key must be defined",
"type": "boolean"
}
},
"required": [
"key"
],
"type": "object",
"x-kubernetes-map-type": "atomic"
}
},
"type": "object"
},
"caFile": {
"description": "Path to the CA cert in the Prometheus container to use for the targets.",
"type": "string"
},
"cert": {
"description": "Client certificate to present when doing client-authentication.",
"properties": {
"configMap": {
"description": "ConfigMap containing data to use for the targets.",
"properties": {
"key": {
"description": "The key to select.",
"type": "string"
},
"name": {
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?",
"type": "string"
},
"optional": {
"description": "Specify whether the ConfigMap or its key must be defined",
"type": "boolean"
}
},
"required": [
"key"
],
"type": "object",
"x-kubernetes-map-type": "atomic"
},
"secret": {
"description": "Secret containing data to use for the targets.",
"properties": {
"key": {
"description": "The key of the secret to select from. Must be a valid secret key.",
"type": "string"
},
"name": {
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?",
"type": "string"
},
"optional": {
"description": "Specify whether the Secret or its key must be defined",
"type": "boolean"
}
},
"required": [
"key"
],
"type": "object",
"x-kubernetes-map-type": "atomic"
}
},
"type": "object"
},
"certFile": {
"description": "Path to the client cert file in the Prometheus container for the targets.",
"type": "string"
},
"insecureSkipVerify": {
"description": "Disable target certificate validation.",
"type": "boolean"
},
"keyFile": {
"description": "Path to the client key file in the Prometheus container for the targets.",
"type": "string"
},
"keySecret": {
"description": "Secret containing the client key file for the targets.",
"properties": {
"key": {
"description": "The key of the secret to select from. Must be a valid secret key.",
"type": "string"
},
"name": {
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?",
"type": "string"
},
"optional": {
"description": "Specify whether the Secret or its key must be defined",
"type": "boolean"
}
},
"required": [
"key"
],
"type": "object",
"x-kubernetes-map-type": "atomic"
},
"serverName": {
"description": "Used to verify the hostname for the targets.",
"type": "string"
}
},
"type": "object"
}
},
"required": [
"endpoint"
],
"type": "object"
},
"tsdb": {
"description": "Defines the runtime reloadable configuration of the timeseries database (TSDB).",
"properties": {

View file

@ -18,6 +18,7 @@ import (
"strings"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
@ -526,6 +527,45 @@ type PrometheusSpec struct {
// Defines the runtime reloadable configuration of the timeseries database
// (TSDB).
TSDB TSDBSpec `json:"tsdb,omitempty"`
// TracingConfig configures tracing in Prometheus. This is an experimental feature, it may change in any upcoming release in a breaking way.
// +optional
TracingConfig *PrometheusTracingConfig `json:"tracingConfig,omitempty"`
}
type PrometheusTracingConfig struct {
// Client used to export the traces. Options are "http" or "grpc".
//+kubebuilder:validation:Enum=http;grpc
// +optional
ClientType *string `json:"clientType"`
// Endpoint to send the traces to. Should be provided in format <host>:<port>.
//+required
Endpoint string `json:"endpoint"`
// Sets the probability a given trace will be sampled. Must be a float from 0 through 1.
// +optional
SamplingFraction *resource.Quantity `json:"samplingFraction"`
// If disabled, the client will use a secure connection.
// +optional
Insecure *bool `json:"insecure"`
// Key-value pairs to be used as headers associated with gRPC or HTTP requests.
// +optional
Headers map[string]string `json:"headers"`
// Compression key for supported compression types. Supported compression: gzip
//+kubebuilder:validation:Enum=gzip
// +optional
Compression *string `json:"compression"`
// Maximum time the exporter will wait for each batch export. Default '10s'
// +optional
Timeout *Duration `json:"timeout"`
// TLS Config to use when sending traces.
// +optional
TLSConfig *TLSConfig `json:"tlsConfig"`
}
// PrometheusStatus is the most recent observed status of the Prometheus cluster.

View file

@ -1754,6 +1754,11 @@ func (in *PrometheusSpec) DeepCopyInto(out *PrometheusSpec) {
(*in).DeepCopyInto(*out)
}
out.TSDB = in.TSDB
if in.TracingConfig != nil {
in, out := &in.TracingConfig, &out.TracingConfig
*out = new(PrometheusTracingConfig)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusSpec.
@ -1793,6 +1798,58 @@ func (in *PrometheusStatus) DeepCopy() *PrometheusStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PrometheusTracingConfig) DeepCopyInto(out *PrometheusTracingConfig) {
*out = *in
if in.ClientType != nil {
in, out := &in.ClientType, &out.ClientType
*out = new(string)
**out = **in
}
if in.SamplingFraction != nil {
in, out := &in.SamplingFraction, &out.SamplingFraction
x := (*in).DeepCopy()
*out = &x
}
if in.Insecure != nil {
in, out := &in.Insecure, &out.Insecure
*out = new(bool)
**out = **in
}
if in.Headers != nil {
in, out := &in.Headers, &out.Headers
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.Compression != nil {
in, out := &in.Compression, &out.Compression
*out = new(string)
**out = **in
}
if in.Timeout != nil {
in, out := &in.Timeout, &out.Timeout
*out = new(Duration)
**out = **in
}
if in.TLSConfig != nil {
in, out := &in.TLSConfig, &out.TLSConfig
*out = new(TLSConfig)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrometheusTracingConfig.
func (in *PrometheusTracingConfig) DeepCopy() *PrometheusTracingConfig {
if in == nil {
return nil
}
out := new(PrometheusTracingConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PrometheusWebSpec) DeepCopyInto(out *PrometheusWebSpec) {
*out = *in

View file

@ -48,6 +48,7 @@ type PrometheusSpecApplyConfiguration struct {
EvaluationInterval *monitoringv1.Duration `json:"evaluationInterval,omitempty"`
EnableAdminAPI *bool `json:"enableAdminAPI,omitempty"`
TSDB *TSDBSpecApplyConfiguration `json:"tsdb,omitempty"`
TracingConfig *PrometheusTracingConfigApplyConfiguration `json:"tracingConfig,omitempty"`
}
// PrometheusSpecApplyConfiguration constructs an declarative configuration of the PrometheusSpec type for use with
@ -823,3 +824,11 @@ func (b *PrometheusSpecApplyConfiguration) WithTSDB(value *TSDBSpecApplyConfigur
b.TSDB = value
return b
}
// WithTracingConfig sets the TracingConfig 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 TracingConfig field is set to the value of the last call.
func (b *PrometheusSpecApplyConfiguration) WithTracingConfig(value *PrometheusTracingConfigApplyConfiguration) *PrometheusSpecApplyConfiguration {
b.TracingConfig = value
return b
}

View file

@ -0,0 +1,111 @@
// Copyright The prometheus-operator Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
)
// PrometheusTracingConfigApplyConfiguration represents an declarative configuration of the PrometheusTracingConfig type for use
// with apply.
type PrometheusTracingConfigApplyConfiguration struct {
ClientType *string `json:"clientType,omitempty"`
Endpoint *string `json:"endpoint,omitempty"`
SamplingFraction *resource.Quantity `json:"samplingFraction,omitempty"`
Insecure *bool `json:"insecure,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Compression *string `json:"compression,omitempty"`
Timeout *v1.Duration `json:"timeout,omitempty"`
TLSConfig *TLSConfigApplyConfiguration `json:"tlsConfig,omitempty"`
}
// PrometheusTracingConfigApplyConfiguration constructs an declarative configuration of the PrometheusTracingConfig type for use with
// apply.
func PrometheusTracingConfig() *PrometheusTracingConfigApplyConfiguration {
return &PrometheusTracingConfigApplyConfiguration{}
}
// WithClientType sets the ClientType 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 ClientType field is set to the value of the last call.
func (b *PrometheusTracingConfigApplyConfiguration) WithClientType(value string) *PrometheusTracingConfigApplyConfiguration {
b.ClientType = &value
return b
}
// WithEndpoint sets the Endpoint 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 Endpoint field is set to the value of the last call.
func (b *PrometheusTracingConfigApplyConfiguration) WithEndpoint(value string) *PrometheusTracingConfigApplyConfiguration {
b.Endpoint = &value
return b
}
// WithSamplingFraction sets the SamplingFraction 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 SamplingFraction field is set to the value of the last call.
func (b *PrometheusTracingConfigApplyConfiguration) WithSamplingFraction(value resource.Quantity) *PrometheusTracingConfigApplyConfiguration {
b.SamplingFraction = &value
return b
}
// WithInsecure sets the Insecure 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 Insecure field is set to the value of the last call.
func (b *PrometheusTracingConfigApplyConfiguration) WithInsecure(value bool) *PrometheusTracingConfigApplyConfiguration {
b.Insecure = &value
return b
}
// WithHeaders puts the entries into the Headers 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 Headers field,
// overwriting an existing map entries in Headers field with the same key.
func (b *PrometheusTracingConfigApplyConfiguration) WithHeaders(entries map[string]string) *PrometheusTracingConfigApplyConfiguration {
if b.Headers == nil && len(entries) > 0 {
b.Headers = make(map[string]string, len(entries))
}
for k, v := range entries {
b.Headers[k] = v
}
return b
}
// WithCompression sets the Compression 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 Compression field is set to the value of the last call.
func (b *PrometheusTracingConfigApplyConfiguration) WithCompression(value string) *PrometheusTracingConfigApplyConfiguration {
b.Compression = &value
return b
}
// WithTimeout sets the Timeout 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 Timeout field is set to the value of the last call.
func (b *PrometheusTracingConfigApplyConfiguration) WithTimeout(value v1.Duration) *PrometheusTracingConfigApplyConfiguration {
b.Timeout = &value
return b
}
// WithTLSConfig sets the TLSConfig 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 TLSConfig field is set to the value of the last call.
func (b *PrometheusTracingConfigApplyConfiguration) WithTLSConfig(value *TLSConfigApplyConfiguration) *PrometheusTracingConfigApplyConfiguration {
b.TLSConfig = value
return b
}

View file

@ -119,6 +119,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &monitoringv1.PrometheusSpecApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("PrometheusStatus"):
return &monitoringv1.PrometheusStatusApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("PrometheusTracingConfig"):
return &monitoringv1.PrometheusTracingConfigApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("PrometheusWebSpec"):
return &monitoringv1.PrometheusWebSpecApplyConfiguration{}
case v1.SchemeGroupVersion.WithKind("QuerySpec"):

View file

@ -435,6 +435,7 @@ func (cg *ConfigGenerator) GenerateServerConfiguration(
tsdb monitoringv1.TSDBSpec,
alerting *monitoringv1.AlertingSpec,
remoteRead []monitoringv1.RemoteReadSpec,
tracingConfig *monitoringv1.PrometheusTracingConfig,
sMons map[string]*monitoringv1.ServiceMonitor,
pMons map[string]*monitoringv1.PodMonitor,
probes map[string]*monitoringv1.Probe,
@ -510,6 +511,15 @@ func (cg *ConfigGenerator) GenerateServerConfiguration(
cfg = append(cfg, cg.generateRemoteReadConfig(remoteRead, store))
}
if tracingConfig != nil {
tracingcfg, err := cg.generateTracingConfig(tracingConfig)
if err != nil {
return nil, errors.Wrap(err, "generating tracing configuration failed")
}
cfg = append(cfg, tracingcfg)
}
return yaml.Marshal(cfg)
}
@ -2222,3 +2232,72 @@ func (cg *ConfigGenerator) generateScrapeConfig(
}
return cfg
}
func (cg *ConfigGenerator) generateTracingConfig(tracingConfig *monitoringv1.PrometheusTracingConfig) (yaml.MapItem, error) {
cfg := yaml.MapSlice{}
objMeta := cg.prom.GetObjectMeta()
cfg = append(cfg, yaml.MapItem{
Key: "endpoint",
Value: tracingConfig.Endpoint,
})
if tracingConfig.ClientType != nil {
cfg = append(cfg, yaml.MapItem{
Key: "client_type",
Value: tracingConfig.ClientType,
})
}
if tracingConfig.SamplingFraction != nil {
cfg = append(cfg, yaml.MapItem{
Key: "sampling_fraction",
Value: tracingConfig.SamplingFraction.AsApproximateFloat64(),
})
}
if tracingConfig.Insecure != nil {
cfg = append(cfg, yaml.MapItem{
Key: "insecure",
Value: tracingConfig.Insecure,
})
}
if len(tracingConfig.Headers) > 0 {
headers := yaml.MapSlice{}
for key, value := range tracingConfig.Headers {
headers = append(headers, yaml.MapItem{
Key: key,
Value: value,
})
}
cfg = append(cfg, yaml.MapItem{
Key: "headers",
Value: headers,
})
}
if tracingConfig.Compression != nil {
cfg = append(cfg, yaml.MapItem{
Key: "compression",
Value: tracingConfig.Compression,
})
}
if tracingConfig.Timeout != nil {
cfg = append(cfg, yaml.MapItem{
Key: "timeout",
Value: tracingConfig.Timeout,
})
}
if tracingConfig.TLSConfig != nil {
cfg = addTLStoYaml(cfg, objMeta.GetNamespace(), tracingConfig.TLSConfig)
}
return yaml.MapItem{
Key: "tracing",
Value: cfg,
}, nil
}

View file

@ -210,6 +210,7 @@ scrape_configs: []
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{},
nil,
nil,
@ -422,7 +423,6 @@ func TestProbeStaticTargetsConfigGeneration(t *testing.T) {
p := defaultPrometheus()
cg := mustNewConfigGenerator(t, p)
cfg, err := cg.GenerateServerConfiguration(
p.Spec.EvaluationInterval,
p.Spec.QueryLogFile,
@ -433,6 +433,7 @@ func TestProbeStaticTargetsConfigGeneration(t *testing.T) {
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"probe1": {
ObjectMeta: metav1.ObjectMeta{
@ -528,7 +529,6 @@ func TestProbeStaticTargetsConfigGenerationWithLabelEnforce(t *testing.T) {
p.Spec.CommonPrometheusFields.EnforcedNamespaceLabel = "namespace"
cg := mustNewConfigGenerator(t, p)
cfg, err := cg.GenerateServerConfiguration(
p.Spec.EvaluationInterval,
p.Spec.QueryLogFile,
@ -539,6 +539,7 @@ func TestProbeStaticTargetsConfigGenerationWithLabelEnforce(t *testing.T) {
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"probe1": {
ObjectMeta: metav1.ObjectMeta{
@ -644,6 +645,7 @@ func TestProbeStaticTargetsConfigGenerationWithJobName(t *testing.T) {
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"probe1": {
ObjectMeta: metav1.ObjectMeta{
@ -735,6 +737,7 @@ func TestProbeStaticTargetsConfigGenerationWithoutModule(t *testing.T) {
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"probe1": {
ObjectMeta: metav1.ObjectMeta{
@ -822,6 +825,7 @@ func TestProbeIngressSDConfigGeneration(t *testing.T) {
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"probe1": {
ObjectMeta: metav1.ObjectMeta{
@ -954,6 +958,7 @@ func TestProbeIngressSDConfigGenerationWithShards(t *testing.T) {
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"probe1": {
ObjectMeta: metav1.ObjectMeta{
@ -1085,6 +1090,7 @@ func TestProbeIngressSDConfigGenerationWithLabelEnforce(t *testing.T) {
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"probe1": {
ObjectMeta: metav1.ObjectMeta{
@ -1329,6 +1335,7 @@ func TestAlertmanagerBearerToken(t *testing.T) {
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
nil,
@ -1502,6 +1509,7 @@ alerting:
nil,
nil,
nil,
nil,
&assets.Store{BasicAuthAssets: map[string]assets.BasicAuthCredentials{
"alertmanager/auth/0": {
Username: "bob",
@ -1547,6 +1555,7 @@ func TestAlertmanagerAPIVersion(t *testing.T) {
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
nil,
@ -1619,6 +1628,7 @@ func TestAlertmanagerTimeoutConfig(t *testing.T) {
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
nil,
@ -1815,6 +1825,7 @@ alerting:
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
nil,
@ -1845,6 +1856,7 @@ func TestAdditionalScrapeConfigs(t *testing.T) {
nil,
nil,
nil,
nil,
&assets.Store{},
[]byte(`- job_name: prometheus
scrape_interval: 15s
@ -2010,6 +2022,7 @@ func TestAdditionalAlertRelabelConfigs(t *testing.T) {
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
[]byte(`- action: drop
@ -2071,6 +2084,7 @@ func TestNoEnforcedNamespaceLabelServiceMonitor(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"test": {
ObjectMeta: metav1.ObjectMeta{
@ -2223,7 +2237,6 @@ func TestServiceMonitorWithEndpointSliceEnable(t *testing.T) {
cg := mustNewConfigGenerator(t, p)
cg.endpointSliceSupported = true
cfg, err := cg.GenerateServerConfiguration(
p.Spec.EvaluationInterval,
p.Spec.QueryLogFile,
@ -2232,6 +2245,7 @@ func TestServiceMonitorWithEndpointSliceEnable(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"test": {
ObjectMeta: metav1.ObjectMeta{
@ -2399,6 +2413,7 @@ func TestEnforcedNamespaceLabelPodMonitor(t *testing.T) {
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -2545,6 +2560,7 @@ func TestEnforcedNamespaceLabelOnExcludedPodMonitor(t *testing.T) {
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -2683,6 +2699,7 @@ func TestEnforcedNamespaceLabelServiceMonitor(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"test": {
ObjectMeta: metav1.ObjectMeta{
@ -2856,6 +2873,7 @@ func TestEnforcedNamespaceLabelOnExcludedServiceMonitor(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"test": {
ObjectMeta: metav1.ObjectMeta{
@ -3026,6 +3044,7 @@ func TestAdditionalAlertmanagers(t *testing.T) {
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
nil,
@ -3085,6 +3104,7 @@ func TestSettingHonorTimestampsInServiceMonitor(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -3212,6 +3232,7 @@ func TestSettingHonorTimestampsInPodMonitor(t *testing.T) {
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -3319,6 +3340,7 @@ func TestHonorTimestampsOverriding(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -3445,6 +3467,7 @@ func TestSettingHonorLabels(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -3574,6 +3597,7 @@ func TestHonorLabelsOverriding(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -3702,6 +3726,7 @@ func TestTargetLabels(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -3961,6 +3986,7 @@ oauth2:
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
tt.sMons,
tt.pMons,
tt.probes,
@ -3997,6 +4023,7 @@ func TestPodTargetLabels(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -4125,6 +4152,7 @@ func TestPodTargetLabelsFromPodMonitor(t *testing.T) {
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -4234,6 +4262,7 @@ func TestPodTargetLabelsFromPodMonitorAndGlobal(t *testing.T) {
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -4341,6 +4370,7 @@ func TestEmptyEndpointPorts(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"test": {
ObjectMeta: metav1.ObjectMeta{
@ -4501,7 +4531,6 @@ func generateTestConfig(t *testing.T, version string) ([]byte, error) {
},
}
cg := mustNewConfigGenerator(t, p)
return cg.GenerateServerConfiguration(
p.Spec.EvaluationInterval,
p.Spec.QueryLogFile,
@ -4510,6 +4539,7 @@ func generateTestConfig(t *testing.T, version string) ([]byte, error) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
makeServiceMonitors(),
makePodMonitors(),
nil,
@ -5144,6 +5174,7 @@ scrape_configs:
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": &serviceMonitor,
},
@ -5400,6 +5431,7 @@ scrape_configs:
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": &serviceMonitor,
},
@ -5598,6 +5630,7 @@ remote_read:
nil,
nil,
nil,
nil,
&assets.Store{
BasicAuthAssets: map[string]assets.BasicAuthCredentials{},
OAuth2Assets: map[string]assets.OAuth2Credentials{
@ -6114,6 +6147,7 @@ remote_write:
nil,
nil,
nil,
nil,
store,
nil,
nil,
@ -6367,6 +6401,7 @@ scrape_configs:
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": &serviceMonitor,
},
@ -6585,6 +6620,7 @@ scrape_configs:
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": &podMonitor,
},
@ -6785,6 +6821,7 @@ scrape_configs:
p.Spec.RemoteRead,
nil,
nil,
nil,
map[string]*monitoringv1.Probe{
"testprobe1": &probe,
},
@ -7002,6 +7039,7 @@ scrape_configs:
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": &serviceMonitor,
},
@ -7038,6 +7076,7 @@ func TestMatchExpressionsServiceMonitor(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"test": {
ObjectMeta: metav1.ObjectMeta{
@ -7072,6 +7111,7 @@ func TestMatchExpressionsServiceMonitor(t *testing.T) {
nil,
nil,
)
require.NoError(t, err)
expected := `global:
@ -7426,6 +7466,7 @@ scrape_configs:
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": &serviceMonitor,
},
@ -7662,6 +7703,7 @@ scrape_configs:
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": &podMonitor,
},
@ -7952,6 +7994,7 @@ scrape_configs:
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"testservicemonitor1": &serviceMonitor,
},
@ -7983,6 +8026,7 @@ func TestPodMonitorPhaseFilter(t *testing.T) {
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": {
ObjectMeta: metav1.ObjectMeta{
@ -8279,6 +8323,7 @@ scrape_configs:
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
nil,
map[string]*monitoringv1.PodMonitor{
"testpodmonitor1": &podMonitor,
},
@ -8369,6 +8414,7 @@ scrape_configs: []
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
nil,
@ -8455,6 +8501,7 @@ storage:
nil,
nil,
nil,
nil,
&assets.Store{},
nil,
nil,
@ -8479,6 +8526,7 @@ func TestGenerateRelabelConfig(t *testing.T) {
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
nil,
map[string]*monitoringv1.ServiceMonitor{
"test": {
ObjectMeta: metav1.ObjectMeta{
@ -8861,6 +8909,7 @@ scrape_configs:
nil,
nil,
nil,
nil,
scs,
nil,
nil,
@ -8874,3 +8923,98 @@ scrape_configs:
}
}
func TestTracingConfig(t *testing.T) {
samplingTwo := resource.MustParse("0.5")
testCases := []struct {
tracingConfig *monitoringv1.PrometheusTracingConfig
name string
expectedConfig string
expectedErr bool
}{
{
name: "Config only with endpoint",
tracingConfig: &monitoringv1.PrometheusTracingConfig{
Endpoint: "https://otel-collector.default.svc.local:3333",
},
expectedConfig: `global:
evaluation_interval: 30s
scrape_interval: 30s
external_labels:
prometheus: default/test
prometheus_replica: $(POD_NAME)
scrape_configs: []
tracing:
endpoint: https://otel-collector.default.svc.local:3333
`,
expectedErr: false,
},
{
tracingConfig: &monitoringv1.PrometheusTracingConfig{
ClientType: pointer.String("grpc"),
Endpoint: "https://otel-collector.default.svc.local:3333",
SamplingFraction: &samplingTwo,
Headers: map[string]string{
"custom": "header",
},
Compression: pointer.String("gzip"),
Timeout: (*monitoringv1.Duration)(pointer.String("10s")),
Insecure: pointer.Bool(false),
},
name: "Expect valid config",
expectedErr: false,
expectedConfig: `global:
evaluation_interval: 30s
scrape_interval: 30s
external_labels:
prometheus: default/test
prometheus_replica: $(POD_NAME)
scrape_configs: []
tracing:
endpoint: https://otel-collector.default.svc.local:3333
client_type: grpc
sampling_fraction: 0.5
insecure: false
headers:
custom: header
compression: gzip
timeout: 10s
`,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
p := defaultPrometheus()
p.Spec.TracingConfig = tc.tracingConfig
cg := mustNewConfigGenerator(t, p)
cfg, err := cg.GenerateServerConfiguration(
p.Spec.EvaluationInterval,
p.Spec.QueryLogFile,
p.Spec.RuleSelector,
p.Spec.Exemplars,
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
p.Spec.TracingConfig,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
)
if tc.expectedErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
require.Equal(t, tc.expectedConfig, string(cfg))
})
}
}

View file

@ -1717,6 +1717,7 @@ func (c *Operator) createOrUpdateConfigurationSecret(ctx context.Context, p *mon
p.Spec.TSDB,
p.Spec.Alerting,
p.Spec.RemoteRead,
p.Spec.TracingConfig,
smons,
pmons,
bmons,