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

Ordering of targets in a group is not consistent #5155

Closed
martinhanzik opened this Issue Jan 30, 2019 · 6 comments

Comments

Projects
None yet
5 participants
@martinhanzik
Copy link

martinhanzik commented Jan 30, 2019

Bug Report

What did you do?
I added a file scraper using swarm-discovery that automatically generates the file from the docker API.
I opened the 'Targets' page.

What did you expect to see?
Targets in a consistent order, ordered by job first, then label, as specified by #4898

What did you see instead? Under which circumstances?
When refreshing the page, the target order in the group changes. Targets for one job seem to always be ordered by instance, but they mix with the other jobs.

I don't know why https://github.com/prometheus/prometheus/blob/v2.7.0/web/web.go#L698 is using the OR operation for the 2 conditions, normally one would do something like this:

if (a.L1 == a.L1)
  return a.L2 < b.L2;
return a.L1 < b.L1;

Environment

  • Prometheus version:

    2.7.0

  • Prometheus configuration file:

scrape_configs:
  - job_name: swarm-service-endpoints
    file_sd_configs:
      - files:
        - /etc/swarm-endpoints/swarm-endpoints.json
    # node exporter + container exporter
    metric_relabel_configs:
    # Set the instance to the hostname
    - source_labels: [__meta_swarm_node_hostname]
      target_label: instance
    # scrap only running tasks
    - source_labels: [__meta_swarm_task_desired_state]
      regex: running
      action: keep
    # Add a task label
    - source_labels: [__meta_swarm_task_name]
      target_label: task
@martinhanzik

This comment has been minimized.

Copy link
Author

martinhanzik commented Jan 30, 2019

I forgot to provide the labels for this problem:

  • instance=swarm1, job=A
  • instance=swarm2, job=A
  • instance=swarm3, job=A
  • instance=swarm1, job=B
  • instance=swarm2, job=B
  • instance=swarm3, job=B
  • instance=swarm1, job=C

@codesome codesome added the kind/bug label Jan 30, 2019

@yeya24

This comment has been minimized.

Copy link

yeya24 commented Jan 30, 2019

Yeah the logic is a little bit wrong. But I can't reproduce this error. How to reproduce it? Here in my webui the targets are always ordered

@codesome

This comment has been minimized.

Copy link
Member

codesome commented Jan 31, 2019

If the labels come sorted with instance first and then job, then it will stay like that and won't be sorted by job first.

@codesome

This comment has been minimized.

Copy link
Member

codesome commented Jan 31, 2019

Opening a PR with the fix in a bit.

@cstyan

This comment has been minimized.

Copy link
Contributor

cstyan commented Jan 31, 2019

@codesome looks like this can be closed?

@martinhanzik

This comment has been minimized.

Copy link
Author

martinhanzik commented Jan 31, 2019

Looks that way

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.