8000 Marathon SD: Set port index label by mattbostock · Pull Request #2865 · prometheus/prometheus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Marathon SD: Set port index label #2865

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

Merged

Conversation

mattbostock
Copy link
Contributor
@mattbostock mattbostock commented Jun 20, 2017

The changes 1 to Marathon service discovery to support multiple
ports mean that Prometheus now attempts to scrape all ports belonging to
a Marathon service.

You can use port definition or port mapping labels to filter out which
ports to scrape but that requires service owners to update their
Marathon configuration.

To allow for a smoother migration path, add a
__meta_marathon_port_index label, whose value is set to the port's
sequential index integer. For example, PORT0 has the value 0, PORT1
has the value 1, and so on.

This allows you to support scraping both the first available port (the
previous behaviour) in addition to ports with a metrics label.

For example, here's the relabel configuration we might use with
this patch:

- action: keep
  source_labels: ['__meta_marathon_port_definition_label_metrics', '__meta_marathon_port_mapping_label_metrics', '__meta_marathon_port_index']
  # Keep if port mapping or definition has a 'metrics' label with any
  # non-empty value, or if no 'metrics' port label exists but this is the
  # service's fir
8000
st available port
  regex: ([^;]+;;[^;]+|;[^;]+;[^;]+|;;0)

This assumes that the Marathon API returns the ports in sorted order
(matching PORT0, PORT1, etc), which it appears that it does.

@mattbostock
Copy link
Contributor Author

/cc @grobie @robsonpeixoto

@gianluca-sabena
Copy link

+1 Please merge this as soon as possible. I totally agree with this approach. Port index is common used in marathon ecosystem so it is a good idea to port it to prometheus meta data

Copy link
Member
@grobie grobie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections. Please document the new meta label in the next-release branch of https://github.com/prometheus/docs

@mattbostock
Copy link
Contributor Author

Thanks, done in prometheus/docs#773

@mattbostock
Copy link
Contributor Author
mattbostock commented Jun 21, 2017

Related PR to add missing docs for the port definition/port mapping labels: prometheus/docs#774

@fabxc
Copy link
Contributor
fabxc commented Jun 21, 2017

Mh, isn't _index more common than _ordinal? Or is ordinal a fixed term in Marathon?

@mattbostock
Copy link
Contributor Author
mattbostock commented Jun 21, 2017 via email

@mattbostock
Copy link
Contributor Author

Will change to _index and raise a PR to update the docs.

The changes [1][] to Marathon service discovery to support multiple
ports mean that Prometheus now attempts to scrape all ports belonging to
a Marathon service.

You can use port definition or port mapping labels to filter out which
ports to scrape but that requires service owners to update their
Marathon configuration.

To allow for a smoother migration path, add a
`__meta_marathon_port_index` label, whose value is set to the port's
sequential index integer. For example, PORT0 has the value `0`, PORT1
has the value `1`, and so on.

This allows you to support scraping both the first available port (the
previous behaviour) in addition to ports with a `metrics` label.

For example, here's the relabel configuration we might use with
this patch:

    - action: keep
      source_labels: ['__meta_marathon_port_definition_label_metrics', '__meta_marathon_port_mapping_label_metrics', '__meta_marathon_port_index']
      # Keep if port mapping or definition has a 'metrics' label with any
      # non-empty value, or if no 'metrics' port label exists but this is the
      # service's first available port
      regex: ([^;]+;;[^;]+|;[^;]+;[^;]+|;;0)

This assumes that the Marathon API returns the ports in sorted order
(matching PORT0, PORT1, etc), which it appears that it does.

[1]: prometheus#2506
@mattbostock mattbostock force-pushed the add_marathon_port_ordinal_label branch from d7f8e22 to ab4d649 Compare June 23, 2017 08:55
@mattbostock mattbostock changed the title Marathon SD: Set port ordinal label Marathon SD: Set port index label Jun 23, 2017
@grobie
Copy link
Member
grobie commented Jun 23, 2017

Thank you!

@grobie grobie merged commit 43075d0 into prometheus:master Jun 23, 2017
@mattbostock
Copy link
Contributor Author

This was released in version 1.7.2 via #3159.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0