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

gce_sd has full url in zone meta data #3042

Closed
mkm85 opened this Issue Aug 9, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@mkm85
Copy link

mkm85 commented Aug 9, 2017

What did you do?
I created a gce sd config like

scrape_configs:
  - job_name: 'nodes'
    gce_sd_configs:
      - project: 'project'
        port: 9100
        zone: 'asia-southeast1-a'
    relabel_configs:
      - source_labels: ['__meta_gce_zone']
        target_label: region
        regex: '(.*)-[a-z]'

and started prometheus, then I can see that the __meta_gce_zone contains much more than just the zone, it contains an url which ends with the zone"

This is also a problem for '__meta_gce_network' and '__meta_gce_subnetwork'

What did you expect to see?

Labels: region="asia-southeast1"

What did you see instead? Under which circumstances?
Labels: region="https://www.googleapis.com/compute/v1/projects/project/zones/asia-southeast1"

Environment

Version	1.7.1
Revision	3afb3fffa3a29c3de865e1172fb740442e9d0133
Branch	master
BuildUser	root@0aa1b7fc430d
BuildDate	20170612-11:44:05
GoVersion	go1.8.3

Running on google compute engine (GCE) in a docker container. It's the official 1.7.1 docker image

  • System information:
    Linux 4.10.0-30-generic x86_64
@mkm85

This comment has been minimized.

Copy link
Author

mkm85 commented Aug 9, 2017

The zone is taken from the go compute api https://godoc.org/google.golang.org/api/compute/v1#Instance
The documentation for that call states:

 // Zone: [Output Only] URL of the zone where the instance resides.

So that's where url's are coming from.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Aug 9, 2017

We generally just take whatever the SD API gives us, you could extract out a shorter version using relabelling.

@mkm85

This comment has been minimized.

Copy link
Author

mkm85 commented Aug 9, 2017

Is it possible to update the documentation with example output? It was not expected that it would be an url, but being an url is fine if it's expected

I'm using the following relabelling rule now:

      - source_labels: ['__meta_gce_zone']
        target_label: region
        regex: '.*/([0-9a-zA-Z-]*)-[a-z]'
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Aug 9, 2017

Sure, I'd be happy to take a PR clarifying the docs.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.