Grafana: Using Prometheus
How to configure Grafana to use Prometheus as a data source
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use Grafana cloud solution that provides a host of benefits, including:
- Unlimited users, dashboards, and alerts.
- Unlimited and dedicated SMTP email server included.
- Plugins installable in one click.
- Seamless SSO support, compatible with
GitLab,GitHub,OAuth2protocols.- Effortless updates with just a click.
- Customisable domain name secured with HTTPS (for example, https://grafana.your-company.com).
- Optimal performance and robust security powered by a private and dedicated VM.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's Grafana cloud hosting solution!
How to configure Prometheus as a data source in Grafana
Integrating Prometheus with Grafana enhances your ability to visualise metrics effectively. Follow this guide for a straightforward setup process.
Accessing the data source configuration
- Open the Grafana web user interface (UI).
- Navigate to
Configuration>Data Sources. - Click on
Add Data Source. - From the list of available sources, select
Prometheus.
Example of Prometheus configuration as data source
Configuring the Prometheus 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.comor your custom domain. - Authentication: Enable
Basic Auth, setadminas 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 Intervalaligns with your Prometheus server configuration. The default is15sunless it has been adjusted.
After entering these details, click Save & Test to verify the connection is functional.
Adding a Node Exporter dashboard
If your Prometheus server includes a Node Exporter target, you can quickly import a pre-built dashboard into Grafana to monitor its metrics:
- In the Grafana UI, navigate to
Create>Import. - Under
Import via grafana.com, input the ID1860and clickLoad. - Select your Prometheus data source.
- Click
Importto add the dashboard.
Example 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.
Adding a Blackbox Exporter dashboard
Grafana supports pre-configured dashboards for the Blackbox Exporter. To add one:
- In the Grafana UI, go to
Create>Import. - Enter one of the following IDs:
7587,11175,11529, or13659, and clickLoad. - Select your Prometheus data source and click
Import.
This process adds a dashboard designed for Blackbox Exporter data visualisation. Use the Job selector at the top left to focus on specific instances.
Example of pre-configured dashboard ID 7587
Example of pre-configured dashboard ID 11175
Example of pre-configured dashboard ID 11529
Example of pre-configured dashboard ID 13659
Troubleshooting missing data points in Grafana charts
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:
- Open your Prometheus configuration file and check the
global/scrape_intervalsetting. For Stackhero's Prometheus instance, the default is typically15s.
Prometheus default configuration
- In the Grafana UI, navigate to
Configuration>Data Sourcesand selectPrometheus. - Ensure the
Scrape Intervalin Grafana matches thescrape_intervalin your Prometheus configuration.
Prometheus data source configuration in Grafana
By aligning the scrape intervals, you can resolve most issues related to missing data points in your dashboards.