New metric button not visible when Prometheus app installed on group/instance clusters
Summary
(Summarize the bug encountered concisely)
When Prometheus is installed via helm/tiller in a project cluster, a Prometheus service is initialized and activated, but the same is not done when Prometheus is installed on a group or instance cluster.
When Prometheus is installed on a group/instance cluster, the custom metrics New metric
button does not get enabled because it looks for an active Prometheus service.
Workaround:
Clicking the "New metric" button takes you to https://gitlab.com/<namespace>/<project>/prometheus/metrics/new
. It is possible to enter the URL in the browser and go directly to the above page without having to click on the "New metric" button.
Steps to reproduce
(How one can reproduce the issue - this is very important)
- Choose a project that does not have a project cluster. Or if it has a project cluster, delete the cluster so that the Prometheus service object gets destroyed.
- Install a group or instance cluster such that the above project will have access to it (Make sure the project is a part of the group. Instance clusters should be available to all projects in the instance)
- Install the Prometheus app on the group/instance cluster.
- Go to the project's Settings > Integrations > Prometheus.
- The "New metric" button will not be visible in the Custom Metrics section.
Example Project
(If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report)
(If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version)
What is the current bug behavior?
(What actually happens)
What is the expected correct behavior?
(What you should see instead)
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.)
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:env:info
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)
We can do one of the following:
- Create a Prometheus service for every project within a group when Prometheus is installed on a group cluster. Create a Prometheus service for every project in the instance when Prometheus is installed on an instance cluster - https://gitlab.com/gitlab-org/gitlab-ce/blob/f8821f828e13f16586630460f177d9de2c3e46e7/app%2Fmodels%2Fclusters%2Fapplications%2Fprometheus.rb#L24
- Do not check to see if the service is active when displaying the New metric button - https://gitlab.com/gitlab-org/gitlab-ee/blob/3c0ef74c19a3acf5b25cdb553a809348fc246d31/ee%2Fapp%2Fassets%2Fjavascripts%2Fpages%2Fprojects%2Fservices%2Fedit%2Findex.js#L13