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

Panic when using empty relabel config #4889

Closed
xocasdashdash opened this Issue Nov 20, 2018 · 7 comments

Comments

Projects
None yet
4 participants
@xocasdashdash
Copy link

xocasdashdash commented Nov 20, 2018

Bug Report

What did you do?
I added an empty relabel config like so:

relabel_configs:
            -   source_labels: [ '__meta_dns_name' ]
                regex: 'node-exporter\.(.+?).+'
                target_label: 'az'
                replacement: '$1'
            -

What did you expect to see?
Prometheus not to panic.
What did you see instead? Under which circumstances?
It panics. ie: https://imgur.com/a/aFSiz5V
Environment

  • System information:

Linux 3.10.0-862.el7.x86_64 x86_64

  • Prometheus version:

    prometheus, version 2.5.0 (branch: HEAD, revision: 67dc912)
    build user: root@578ab108d0b9
    build date: 20181106-11:40:44
    go version: go1.11.1

I also found this bug on 2.4.3

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Nov 21, 2018

Thanks for the report, looking into it!

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Nov 21, 2018

https://github.com/prometheus/prometheus/blob/master/relabel/relabel.go#L41 accesses cfg.SourceLabels, but cfg is a pointer that can actually become nil when initialized from an empty YAML object (an empty relabeling rule in this case). Either the list elements should not be pointers or we should check for nil values.

@simonpasquier

This comment has been minimized.

Copy link
Member

simonpasquier commented Nov 21, 2018

I would lean towards rejecting any empty relabeling rule at load time since it isn't a useful configuration AFAICT.

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Nov 21, 2018

@simonpasquier Good point, that would be even better :)

@infoverload

This comment has been minimized.

Copy link
Contributor

infoverload commented Nov 21, 2018

I am interested in working on this!

@simonpasquier

This comment has been minimized.

Copy link
Member

simonpasquier commented Nov 21, 2018

@infoverload go ahead!

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Dec 3, 2018

Heads-up: I'm fixing all the slice-of-pointers config nil pointer crashes in one go, so this will be covered by that.

juliusv added a commit that referenced this issue Dec 3, 2018

Fix config loading panics on nil pointer slice elements
Fixes #4902
Fixes #4889

Signed-off-by: Julius Volz <julius.volz@gmail.com>

@juliusv juliusv closed this in #4942 Dec 3, 2018

juliusv added a commit that referenced this issue Dec 3, 2018

Fix config loading panics on nil pointer slice elements (#4942)
Fixes #4902
Fixes #4889

Signed-off-by: Julius Volz <julius.volz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.