-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[receivercreator/discovery] Add support for default annotation-equivalent config in receivercreator #40195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[receivercreator/discovery] Add support for default annotation-equivalent config in receivercreator #40195
Conversation
6e57b74
to
7b31072
Compare
Signed-off-by: ChrsMark <[email protected]>
7b31072
to
7ff5fd3
Compare
dca96c0
to
f9fa364
Compare
@dmitryax please take a look when you get the chance. |
Signed-off-by: ChrsMark <[email protected]>
f9fa364
to
6aac5a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The comment isn't blocking 👍
IgnoreReceivers []string `mapstructure:"ignore_receivers"` | ||
Enabled bool `mapstructure:"enabled"` | ||
IgnoreReceivers []string `mapstructure:"ignore_receivers"` | ||
DefaultAnnotations map[string]string `mapstructure:"default_annotations"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how simple the interface is 👍
.chloggen/add_support_for_default_log_collection_receivercreator.yaml
Outdated
Show resolved
Hide resolved
…or.yaml Co-authored-by: Dmitry Anoshin <[email protected]>
# | ||
# Example: Enable log collection for all discovered Pods/containers unless they are explicitly | ||
# annotated with `io.opentelemetry.discovery.logs/enabled: "false"`. | ||
# (to avoid collecting Collector's own logs make sure that Collector Pods are properly annotated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for mentioning this in the documentation 👍
…lent config in receivercreator (open-telemetry#40195) #### Description This PR adds support for defining default annotation-equivalent configuration. This can be useful when a default behaviour is required for all discovered Pods/containers without having to explicitly annotate all Pods. Example: Enable log collection for all discovered Pods/containers unless they are explicitly annotated with `io.opentelemetry.discovery.logs/enabled: "false"`. (to avoid collecting Collector's own logs make sure that Collector Pods are properly annotated with `io.opentelemetry.discovery.logs/enabled: "false"`) <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#37436 <!--Describe what testing was performed and which tests were added.--> #### Testing Added <!--Describe the documentation added.--> #### Documentation Added <!--Please delete paragraphs that you did not use before submitting.--> #### How to test this manually 1. Deploy Collector helm chart: ```yaml mode: daemonset podAnnotations: io.opentelemetry.discovery.logs/enabled: "false" image: repository:otelcontribcol-dev tag: "latest" pullPolicy: IfNotPresent clusterRole: create: true rules: - apiGroups: - '' resources: - 'pods' - 'nodes' verbs: - 'get' - 'list' - 'watch' - apiGroups: [ "" ] resources: [ "nodes/proxy"] verbs: [ "get" ] - apiGroups: - "" resources: - nodes/stats verbs: - get - nonResourceURLs: - "/metrics" verbs: - get extraVolumeMounts: - name: varlogpods mountPath: /var/log/pods readOnly: true extraVolumes: - name: varlogpods hostPath: path: /var/log/pods config: extensions: k8s_observer: auth_type: serviceAccount node: ${env:K8S_NODE_NAME} health_check: endpoint: ${env:MY_POD_IP}:13133 exporters: debug/2: verbosity: basic debug: verbosity: detailed receivers: receiver_creator/logs: watch_observers: [k8s_observer] discovery: enabled: true default_annotations: io.opentelemetry.discovery.logs/enabled: "true" receivers: service: extensions: [health_check, k8s_observer] telemetry: logs: level: INFO pipelines: logs/discovery: receivers: [ receiver_creator/logs ] #processors: [ batch ] exporters: [ debug ] ``` 2. Deploy a target Pod and ensure that logs are collected by default: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: busybox-deployment labels: app: busybox spec: replicas: 1 selector: matchLabels: app: busybox template: metadata: labels: app: busybox annotations: some: foo spec: containers: - name: busybox image: busybox args: - /bin/sh - -c - while true; do echo "otel logs at $(date +%H:%M:%S)" && sleep 2s; done ``` 3. After ensuring that logs are collected by default annotate the Pod properly to ensure that log collection is explicitly disabled: `kubectl annotate pod busybox-deployment-77b9b7cfbd-5lfmh io.opentelemetry.discovery.logs/enabled="false"` --------- Signed-off-by: ChrsMark <[email protected]> Co-authored-by: Dmitry Anoshin <[email protected]>
Description
This PR adds support for defining default annotation-equivalent configuration. This can be useful when a default behaviour is required for all discovered Pods/containers without having to explicitly annotate all Pods.
Example: Enable log collection for all discovered Pods/containers unless they are explicitly annotated with
io.opentelemetry.discovery.logs/enabled: "false"
. (to avoid collecting Collector's own logs make sure that Collector Pods are properly annotated withio.opentelemetry.discovery.logs/enabled: "false"
)Link to tracking issue
Fixes #37436
Testing
Added
Documentation
Added
How to test this manually
kubectl annotate pod busybox-deployment-77b9b7cfbd-5lfmh io.opentelemetry.discovery.logs/enabled="false"