Grafana: Using Prometheus

How to configure Grafana to use Prometheus as a data source

👋 Welcome to the Stackhero documentation!

Stackhero gives you a ready-to-use Grafana cloud environment built for quick setup and reliable performance:

  • Unlimited users, dashboards, and alerts: scale your monitoring as needed, without artificial limits.
  • Dedicated SMTP email server included, so you can send all the notifications you want, with no quotas to track.
  • One-click plugin installation streamlines adding new features to Grafana.
  • Built-in SSO support for GitLab, GitHub, Google, and any generic OAuth2 provider. User management stays simple and secure.
  • One-click updates keep your Grafana instance current, with no downtime or maintenance hassle.
  • Use your own custom domain with automated HTTPS provisioning for secure, branded access (for example, https://grafana.your-company.com).
  • High performance and strong security are standard, running on your own private, dedicated infrastructure.

Get started faster and save setup time: a secure Grafana cloud hosting instance is ready in about 5 minutes.

Integrating Prometheus with Grafana enhances your ability to visualize metrics effectively. Follow this guide for a straightforward setup process.

  1. Open the Grafana web user interface (UI).
  2. Navigate to Configuration > Data Sources.
  3. Click on Add Data Source.
  4. From the list of available sources, select Prometheus.

Example of Prometheus configuration as data sourceExample of Prometheus configuration as data source

Follow these steps to properly set up Prometheus as a data source:

  • URL: Provide the Prometheus service URL, such as https://<XXXXXX>.stackhero-network.com or your custom domain.
  • Authentication: Enable Basic Auth, set admin as the username, and provide your Prometheus password. You can find this password in the Stackhero dashboard under the Prometheus service settings.
  • Scrape Interval: Ensure the Scrape Interval aligns with your Prometheus server configuration. The default is 15s unless it has been adjusted.

After entering these details, click Save & Test to verify the connection is functional.

If your Prometheus server includes a Node Exporter target, you can quickly import a pre-built dashboard into Grafana to monitor its metrics:

  1. In the Grafana UI, navigate to Create > Import.
  2. Under Import via grafana.com, input the ID 1860 and click Load.
  3. Select your Prometheus data source.
  4. Click Import to add the dashboard.

Example of a dashboard generated by Grafana, based on Prometheus Node Exporter dataExample of a dashboard generated by Grafana, based on Prometheus Node Exporter data

You now have a Grafana dashboard displaying metrics from the Node Exporter. Use the Job selector in the top left to switch between instances.

Grafana supports pre-configured dashboards for the Blackbox Exporter. To add one:

  1. In the Grafana UI, go to Create > Import.
  2. Enter one of the following IDs: 7587, 11175, 11529, or 13659, and click Load.
  3. Select your Prometheus data source and click Import.

This process adds a dashboard designed for Blackbox Exporter data visualization. Use the Job selector at the top left to focus on specific instances.

Example of pre-configured dashboard ID 7587Example of pre-configured dashboard ID 7587 Example of pre-configured dashboard ID 11175Example of pre-configured dashboard ID 11175 Example of pre-configured dashboard ID 11529Example of pre-configured dashboard ID 11529 Example of pre-configured dashboard ID 13659Example of pre-configured dashboard ID 13659

Are you noticing gaps in your Grafana charts? A common cause is a mismatch in scrape intervals between Prometheus and Grafana. Here is how you can address this:

  1. Open your Prometheus configuration file and check the global/scrape_interval setting. For Stackhero's Prometheus instance, the default is typically 15s.

Prometheus default configurationPrometheus default configuration

  1. In the Grafana UI, navigate to Configuration > Data Sources and select Prometheus.
  2. Ensure the Scrape Interval in Grafana matches the scrape_interval in your Prometheus configuration.

Prometheus data source configuration in GrafanaPrometheus data source configuration in Grafana

By aligning the scrape intervals, you can resolve most issues related to missing data points in your dashboards.