Skip to content
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

Target allocator example from readme fails #2867

Closed
pavolloffay opened this issue Apr 17, 2024 · 2 comments · Fixed by #2872
Closed

Target allocator example from readme fails #2867

pavolloffay opened this issue Apr 17, 2024 · 2 comments · Fixed by #2872
Assignees
Labels
area:target-allocator Issues for target-allocator bug Something isn't working

Comments

@pavolloffay
Copy link
Member

Component(s)

target allocator

What happened?

https://github.com/open-telemetry/opentelemetry-operator?tab=readme-ov-file#target-allocator

kubectl apply -f - <<EOF
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: collector-with-ta
spec:
  mode: statefulset
  targetAllocator:
    enabled: true
  config: |
    receivers:
      prometheus:
        config:
          scrape_configs:
          - job_name: 'otel-collector'
            scrape_interval: 10s
            static_configs:
            - targets: [ '0.0.0.0:8888' ]
            metric_relabel_configs:
            - action: labeldrop
              regex: (id|name)
            - action: labelmap
              regex: label_(.+)
              replacement: $$1

    exporters:
      debug: {}

    service:
      pipelines:
        metrics:
          receivers: [prometheus]
          processors: []
          exporters: [debug]
EOF

Kubernetes Version

minikube version: v1.30.1

Operator version

main

Collector version

0.98.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

Log output

k get pods                                                                                                                                                                                                                                                                                                                                                1 ↵ ploffay@fedora
NAME                                                 READY   STATUS             RESTARTS      AGE
collector-with-ta-collector-0                        0/1     CrashLoopBackOff   4 (8s ago)    104s
collector-with-ta-targetallocator-5bcd4d4fb5-cwq2t   0/1     CrashLoopBackOff   4 (17s ago)   104s

k logs collector-with-ta-targetallocator-5bcd4d4fb5-cwq2t ploffay@fedora
Failed to load config: error unmarshaling YAML: "69141" is invalid 'replacement' for labelmap action%




### Additional context

_No response_
@pavolloffay pavolloffay added bug Something isn't working needs triage area:target-allocator Issues for target-allocator labels Apr 17, 2024
@pavolloffay
Copy link
Member Author

k get cm collector-with-ta-targetallocator -o yaml                                                                                                                                                                                                                                                                                                            ploffay@fedora
apiVersion: v1
data:
  targetallocator.yaml: |
    allocation_strategy: consistent-hashing
    collector_selector:
      matchlabels:
        app.kubernetes.io/component: opentelemetry-collector
        app.kubernetes.io/instance: default.collector-with-ta
        app.kubernetes.io/managed-by: opentelemetry-operator
        app.kubernetes.io/part-of: opentelemetry
      matchexpressions: []
    config:
      scrape_configs:
      - job_name: otel-collector
        metric_relabel_configs:
        - action: labeldrop
          regex: (id|name)
        - action: labelmap
          regex: label_(.+)
          replacement: 69141
        scrape_interval: 10s
        static_configs:
        - targets:
          - 0.0.0.0:8888
    filter_strategy: relabel-config
    prometheus_cr:
      pod_monitor_selector:
        matchlabels: {}
        matchexpressions: []
      scrape_interval: 30s
      service_monitor_selector:
        matchlabels: {}
        matchexpressions: []
kind: ConfigMap
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"opentelemetry.io/v1alpha1","kind":"OpenTelemetryCollector","metadata":{"annotations":{},"name":"collector-with-ta","namespace":"default"},"spec":{"config":"receivers:\n  prometheus:\n    config:\n      scrape_configs:\n      - job_name: 'otel-collector'\n        scrape_interval: 10s\n        static_configs:\n        - targets: [ '0.0.0.0:8888' ]\n        metric_relabel_configs:\n        - action: labeldrop\n          regex: (id|name)\n        - action: labelmap\n          regex: label_(.+)\n          replacement: 69141\n\nexporters:\n  debug: {}\n\nservice:\n  pipelines:\n    metrics:\n      receivers: [prometheus]\n      processors: []\n      exporters: [debug]\n","mode":"statefulset","targetAllocator":{"enabled":true}}}
  creationTimestamp: "2024-04-17T12:34:53Z"
  labels:
    app.kubernetes.io/component: opentelemetry-targetallocator
    app.kubernetes.io/instance: default.collector-with-ta
    app.kubernetes.io/managed-by: opentelemetry-operator
    app.kubernetes.io/name: collector-with-ta-targetallocator
    app.kubernetes.io/part-of: opentelemetry
    app.kubernetes.io/version: latest
  name: collector-with-ta-targetallocator
  namespace: default
  ownerReferences:
  - apiVersion: opentelemetry.io/v1beta1
    blockOwnerDeletion: true
    controller: true
    kind: OpenTelemetryCollector
    name: collector-with-ta
    uid: 5fd19ef0-0427-4c5f-962f-bed3ccb83d56
  resourceVersion: "1319"
  uid: b3ad2c67-4edb-4b51-b87c-410919a80d5c

@swiatekm-sumo
Copy link
Contributor

This is a bug in the unescaping code. If there's no relabel_configs section, we skip processing the scrape config even though there might be a metric_relabel_configs section afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:target-allocator Issues for target-allocator bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants