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

Support verbatim prometheus configurations #4980

Closed
dashpole opened this issue Nov 17, 2020 · 6 comments
Closed

Support verbatim prometheus configurations #4980

dashpole opened this issue Nov 17, 2020 · 6 comments
Labels

Comments

@dashpole
Copy link
Contributor

Is your feature request related to a problem? Please describe.

As a new user, I copied the example configuration for kuberntes from prometheus/prometheus (see my copy here), but it produced errors when trying to scrape my workloads. For example:

2020-11-16T20:48:03.756Z	debug	scrape/scrape.go:1124	Scrape failed	{"component_kind": "receiver",
"component_type": "prometheus", "component_name": "prometheus", "scrape_pool": "kubernetes-service-endpoints",
"target": "http://:/metrics", "err": "Get \"http:///metrics\": http: no Host in request URL"}

Eventually, I found another opentelemetry config, and noticed the double $ before variables, which led me to open-telemetry/opentelemetry-collector#1112. After substituting $$ for $ in this commit, everything worked fine.

I believe being able to reference a verbatim prometheus configuration would make the opentelemetry collector much easier to adopt, as it would more easily enable sharing between the two ecosystems.

Describe the solution you'd like

I'd like to be able to reference an existing prometheus configuration file as an alternative to embedding it in the collector configuration file. Instead of:

receivers:
  prometheus:
    config:
      global:
        scrape_interval: 15s
      scrape_configs:
      - job_name: 'foo'
        ...

I can instead do:

receivers:
  prometheus:
    config_file: prometheus-kubernetes.yaml

Describe alternatives you've considered
Better documentation around using prometheus configurations. I think this will help, but can only go so far.

cc @nilebox @james-bebbington

@nilebox
Copy link
Member

nilebox commented Nov 17, 2020

It sounds like this could be a generic feature supported by the collector rather than specific to Prometheus, allowing any section of the config to be extracted to a separate file.

Adding support for Prometheus config specifically via a dedicated config field is easier to implement / justify though, as it doesn't affect the rest of the codebase.

@serathius
Copy link

I think having config separated into multiple files would be also beneficial. On Kubernetes configmaps have limit of 4KB, which would also limit maximum size of configuration for OT collector.

@brianpham
Copy link

Ran into a similar issue with my prometheus config. Works on prometheus, but didn't work on the opentelemetry-collector. I updated $ to $$ and its working now.

@bogdandrutu bogdandrutu transferred this issue from open-telemetry/opentelemetry-collector Aug 30, 2021
@alolita alolita added the comp:prometheus Prometheus related issues label Sep 2, 2021
@odeke-em
Copy link
Member

odeke-em commented Sep 5, 2021

I've mailed out this PR #5080, please take a look.

odeke-em referenced this issue in orijtech/opentelemetry-collector-contrib Sep 8, 2021
… referenced file

Allows reading Prometheus configurations verbatim from referenced files.
This ensures that users can share their Prometheus configuration files
as is with Kubernetes, Prometheus etc, without having to sweat with
indentation or formatting.

While here also fixed fmt.Errorf("...%s", err) calls to instead wrap err
so fmt.Errorf("...%w", err) which is the way errors should be propagated.

With this change, we can now do

```yaml
receivers:
    prometheus:
      config_file: "./prom.yaml"
```

where the contents of "prom.yaml" are:

```yaml
scrape_configs:
  - job_name: 'otel-collector'
    scrape_interval: 5s
    static_configs:
      - targets: ['0.0.0.0:8888']
  - job_name: k8s
    kubernetes_sd_configs:
    - role: pod
    relabel_configs:
    - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
      regex: "true"
      action: keep
    metric_relabel_configs:
    - source_labels: [__name__]
      regex: "(request_duration_seconds.*|response_duration_seconds.*)"
      action: keep
```

Fixes #4980
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2022

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

@github-actions github-actions bot added the Stale label Nov 4, 2022
@github-actions
Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants