Project-defined metrics dashboards always show 'No Data Found' state

Summary

When a correctly-defined project dashboard is committed to a project, & loaded from the metrics dashboard, the charts do not render, even though the prometheus api is returning data.

It's behind a feature flag? Why is this important?

  1. This is preventing us from enabling the feature flag.
  2. This blocks https://gitlab.com/gitlab-org/gitlab-ce/issues/30423 from being enabled.

Steps to reproduce

  1. Pre-req: A project with auto-deploy configured & prometheus installed.
  2. Enable the environment_metrics_use_prometheus_endpoint and environment_metrics_show_multiple_dashboards feature flags.
  3. Commit a suitable dashboard to .gitlab/dashboards & re-deploy. This one will work: gitlab_dashboards_test_dashboard.yml
  4. Navigate to > Operations > *Metrics.
  5. Select the dashboard from the dropdown menu.
  6. No charts will render, but if you look it the network tab, the prometheus endpoint returns results for all of the queries.

Example Project

On staging: https://staging.gitlab.com/syasonik-admin/autodevops-deploy/environments/176851/metrics?dashboard=.gitlab/dashboards/test_dashboard.yml

What is the current bug behavior?

Only the 'No Data' empty state renders.

What is the expected correct behavior?

The charts should render for each query.

Relevant logs and/or screenshots

Screen_Shot_2019-07-12_at_12.07.01_PM

Possible fixes

Metrics from dashboards do not have a DB id associated with them. So filtering out any metrics without a metricId will filter any metric from a dashboard.

This happens here: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/monitoring/stores/mutations.js#L53