Skip to content

Commit

Permalink
Update selector documentation for Target Allocator (#3001)
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm authored May 31, 2024
1 parent dac4774 commit db15980
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 33 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ spec:
serviceAccount: everything-prometheus-operator-needs
prometheusCR:
enabled: true
serviceMonitorSelector: {}
podMonitorSelector: {}
config:
receivers:
prometheus:
Expand Down
10 changes: 6 additions & 4 deletions apis/v1beta1/targetallocator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ type TargetAllocatorPrometheusCR struct {
// +kubebuilder:validation:Format:=duration
ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"`
// PodMonitors to be selected for target discovery.
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
// PodMonitor's meta labels. The requirements are ANDed.
// A label selector is a label query over a set of resources. The result of matchLabels and
// matchExpressions are ANDed. An empty label selector matches all objects. A null
// label selector matches no objects.
// +optional
PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"`
// ServiceMonitors to be selected for target discovery.
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
// ServiceMonitor's meta labels. The requirements are ANDed.
// A label selector is a label query over a set of resources. The result of matchLabels and
// matchExpressions are ANDed. An empty label selector matches all objects. A null
// label selector matches no objects.
// +optional
ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
}
Expand Down
21 changes: 0 additions & 21 deletions cmd/otel-allocator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,29 +131,8 @@ and jobs on the `/scrape_configs` and `/jobs` endpoints respectively.

The CRs can be filtered by labels as documented here: [api.md#opentelemetrycollectorspectargetallocatorprometheuscr](../../docs/api.md#opentelemetrycollectorspectargetallocatorprometheuscr)

The Prometheus Receiver in the deployed Collector also has to know where the Allocator service exists. This is done by a
OpenTelemetry Collector Operator-specific config.

```yaml
config: |
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
target_allocator:
endpoint: http://my-targetallocator-service
interval: 30s
collector_id: "${POD_NAME}"
```

Upstream documentation here: [PrometheusReceiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/prometheusreceiver#opentelemetry-operator)

The TargetAllocator service is named based on the `OpenTelemetryCollector` CR name. For example, if your Collector CR name is `my-collector`, then the TargetAllocator `service` and `deployment` will each be named `my-collector-targetallocator`, and the `pod` will be named `my-collector-targetallocator-<pod_id>`. `collector_id` should be unique per
collector instance, such as the pod name. The `POD_NAME` environment variable is convenient since this is supplied
to collector instance pods by default.


### RBAC

Before the TargetAllocator can start scraping, you need to set up Kubernetes RBAC (role-based access controls) resources. This means that you need to have a `ServiceAccount` and corresponding cluster roles so that the TargetAllocator has access to all of the necessary resources to pull metrics from.
Expand Down
20 changes: 12 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43103,8 +43103,9 @@ All CR instances which the ServiceAccount has access to will be retrieved. This
<td>object</td>
<td>
PodMonitors to be selected for target discovery.
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
PodMonitor's meta labels. The requirements are ANDed.<br/>
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.<br/>
</td>
<td>false</td>
</tr><tr>
Expand All @@ -43126,8 +43127,9 @@ Default: "30s"<br/>
<td>object</td>
<td>
ServiceMonitors to be selected for target discovery.
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
ServiceMonitor's meta labels. The requirements are ANDed.<br/>
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.<br/>
</td>
<td>false</td>
</tr></tbody>
Expand All @@ -43140,8 +43142,9 @@ ServiceMonitor's meta labels. The requirements are ANDed.<br/>


PodMonitors to be selected for target discovery.
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
PodMonitor's meta labels. The requirements are ANDed.
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.

<table>
<thead>
Expand Down Expand Up @@ -43224,8 +43227,9 @@ merge patch.<br/>


ServiceMonitors to be selected for target discovery.
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
ServiceMonitor's meta labels. The requirements are ANDed.
A label selector is a label query over a set of resources. The result of matchLabels and
matchExpressions are ANDed. An empty label selector matches all objects. A null
label selector matches no objects.

<table>
<thead>
Expand Down
3 changes: 3 additions & 0 deletions docs/crd-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ spec:
key: value
```

> [!NOTE]
> A `nil` selector now selects no resources, while an empty selector selects all of them. To get the old default behaviour, it's necessary to set `serviceMonitorSelector: {}`.

### Default Collector image

The OpenTelemetry Collector maintainers recently introduced a [Collector distribution][k8s_distro] specifically aimed at
Expand Down

0 comments on commit db15980

Please sign in to comment.